Index: .bzrignore
===================================================================
--- .bzrignore	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ .bzrignore	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -28,4 +28,5 @@
 uspace/app/dnsres/dnsres
 uspace/app/edit/edit
+uspace/app/fontviewer/fontviewer
 uspace/app/getterm/getterm
 uspace/app/inet/inet
@@ -79,4 +80,5 @@
 uspace/dist/app/dnsres
 uspace/dist/app/edit
+uspace/dist/app/fontviewer
 uspace/dist/app/getterm
 uspace/dist/app/inet
@@ -134,5 +136,5 @@
 uspace/dist/drv/root/
 uspace/dist/drv/rootpc/
-uspace/dist/drv/rootvirt/
+uspace/dist/drv/virt/
 uspace/dist/drv/rtl8139/
 uspace/dist/drv/rtl8169/
@@ -202,7 +204,7 @@
 uspace/drv/char/xtkbd/xtkbd
 uspace/drv/fb/kfb/kfb
-uspace/drv/infrastructure/root/root
-uspace/drv/infrastructure/rootpc/rootpc
-uspace/drv/infrastructure/rootvirt/rootvirt
+uspace/drv/root/root/root
+uspace/drv/root/virt/virt
+uspace/drv/platform/rootpc/rootpc
 uspace/drv/nic/e1k/e1k
 uspace/drv/nic/ne2k/ne2k
Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ HelenOS.config	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,5 +37,4 @@
 @ "ia64" IA-64 64-bit
 @ "mips32" MIPS 32-bit
-@ "mips64" MIPS 64-bit
 @ "ppc32" PowerPC 32-bit
 @ "sparc32" SPARCv8 32-bit
@@ -48,8 +47,4 @@
 @ "lmalta" MIPS Malta Development Board little endian
 ! [PLATFORM=mips32] MACHINE (choice)
-
-% Machine type
-@ "msim" MSIM
-! [PLATFORM=mips64] MACHINE (choice)
 
 % Machine type
@@ -179,8 +174,4 @@
 
 % Kernel architecture
-@ "mips64"
-! [PLATFORM=mips64] KARCH (choice)
-
-% Kernel architecture
 @ "ppc32"
 ! [PLATFORM=ppc32] KARCH (choice)
@@ -230,8 +221,4 @@
 
 % User space architecture
-@ "mips64"
-! [PLATFORM=mips64] UARCH (choice)
-
-% User space architecture
 @ "ppc32"
 ! [PLATFORM=ppc32] UARCH (choice)
@@ -279,8 +266,4 @@
 @ "mips32"
 ! [PLATFORM=mips32] BARCH (choice)
-
-% Boot architecture
-@ "mips64"
-! [PLATFORM=mips64] BARCH (choice)
 
 % Boot architecture
@@ -310,8 +293,4 @@
 @ "elf"
 ! [PLATFORM=mips32&(MACHINE=bmalta|MACHINE=lmalta)] IMAGE (choice)
-
-% Image format
-@ "binary"
-! [PLATFORM=mips64] IMAGE (choice)
 
 
@@ -337,5 +316,5 @@
 @ "gcc_native" GNU C Compiler (native)
 @ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
-! [PLATFORM=mips32|PLATFORM=mips64|PLATFORM=ppc32] COMPILER (choice)
+! [PLATFORM=mips32|PLATFORM=ppc32] COMPILER (choice)
 
 % Compiler
@@ -367,4 +346,10 @@
 ! [PLATFORM=amd64] CONFIG_FENCES_P4 (y)
 
+% IOMAP bitmap support
+! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_IOMAP_BITMAP (y)
+
+% IOMAP dummy support
+! [PLATFORM=abs32le|PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc32|PLATFORM=sparc64] CONFIG_IOMAP_DUMMY (y)
+
 % ACPI support
 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_ACPI (y)
@@ -374,14 +359,14 @@
 
 % Page hash table support
-! [PLATFORM=ia64|PLATFORM=mips64|PLATFORM=sparc64] CONFIG_PAGE_HT (y)
+! [PLATFORM=ia64|PLATFORM=sparc64] CONFIG_PAGE_HT (y)
 
 % Software integer division support
-! [PLATFORM=abs32le|PLATFORM=ia32|PLATFORM=arm32|PLATFORM=ia64|PLATFORM=mips32|PLATFORM=mips64|PLATFORM=ppc32|PLATFORM=sparc32] CONFIG_SOFTINT (y)
+! [PLATFORM=abs32le|PLATFORM=ia32|PLATFORM=arm32|PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc32] CONFIG_SOFTINT (y)
 
 % ASID support
-! [PLATFORM=ia64|PLATFORM=mips32|PLATFORM=mips64|PLATFORM=ppc32|PLATFORM=sparc32|PLATFORM=sparc64] CONFIG_ASID (y)
+! [PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc32|PLATFORM=sparc64] CONFIG_ASID (y)
 
 % ASID FIFO support
-! [PLATFORM=ia64|PLATFORM=mips32|PLATFORM=mips64|PLATFORM=ppc32|PLATFORM=sparc32|PLATFORM=sparc64] CONFIG_ASID_FIFO (y)
+! [PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc32|PLATFORM=sparc64] CONFIG_ASID_FIFO (y)
 
 % OpenFirmware tree support
@@ -396,4 +381,7 @@
 % FPU support
 ! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=ia64|PLATFORM=sparc64] CONFIG_FPU (y)
+
+% FPU support
+! [PLATFORM=ppc32] CONFIG_FPU (n/y)
 
 ## ARMv7 made FPU hardware compulsory
@@ -408,5 +396,5 @@
 
 % Support for SMP
-! [(PLATFORM=ia32&PROCESSOR!=athlon_xp)|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ia64|(PLATFORM=mips32&MACHINE=msim)|(PLATFORM=mips64&MACHINE=msim)|PLATFORM=abs32le] CONFIG_SMP (y/n)
+! [(PLATFORM=ia32&PROCESSOR!=athlon_xp)|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ia64|(PLATFORM=mips32&MACHINE=msim)|PLATFORM=abs32le] CONFIG_SMP (y/n)
 
 % Debug build
@@ -465,5 +453,5 @@
 @ "generic" Keyboard or serial line
 @ "none" No input device
-! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=mips32|PLATFORM=mips64|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_HID_IN (choice)
+! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_HID_IN (choice)
 
 % Input device class
@@ -481,5 +469,5 @@
 @ "generic" Monitor or serial line
 @ "none" No output device
-! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ppc32|(PLATFORM=ia64&MACHINE=i460GX)|(PLATFORM=mips32&(MACHINE=msim|MACHINE=bmalta|MACHINE=lmalta))|(PLATFORM=mips64&MACHINE=msim)] CONFIG_HID_OUT (choice)
+! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ppc32|(PLATFORM=ia64&MACHINE=i460GX)|(PLATFORM=mips32&(MACHINE=msim|MACHINE=bmalta|MACHINE=lmalta))] CONFIG_HID_OUT (choice)
 
 % PC keyboard support
Index: abi/include/abi/syscall.h
===================================================================
--- abi/include/abi/syscall.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ abi/include/abi/syscall.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -74,6 +74,7 @@
 	SYS_IPC_CONNECT_KBOX,
 	
-	SYS_EVENT_SUBSCRIBE,
-	SYS_EVENT_UNMASK,
+	SYS_IPC_EVENT_SUBSCRIBE,
+	SYS_IPC_EVENT_UNSUBSCRIBE,
+	SYS_IPC_EVENT_UNMASK,
 	
 	SYS_CAP_GRANT,
@@ -87,6 +88,7 @@
 	SYS_IOSPACE_ENABLE,
 	SYS_IOSPACE_DISABLE,
-	SYS_IRQ_REGISTER,
-	SYS_IRQ_UNREGISTER,
+	
+	SYS_IPC_IRQ_SUBSCRIBE,
+	SYS_IPC_IRQ_UNSUBSCRIBE,
 	
 	SYS_SYSINFO_GET_KEYS_SIZE,
@@ -97,5 +99,5 @@
 	SYS_SYSINFO_GET_DATA,
 	
-	SYS_DEBUG_ACTIVATE_CONSOLE,
+	SYS_DEBUG_CONSOLE,
 	
 	SYS_KLOG,
Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ boot/Makefile.common	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -127,9 +127,9 @@
 
 RD_DRVS_ESSENTIAL = \
-	infrastructure/root
+	root/root \
+	root/virt \
+	fb/kfb 
 
 RD_DRVS_NON_ESSENTIAL = \
-	infrastructure/rootvirt \
-	fb/kfb \
 	test/test1 \
 	test/test2 \
@@ -218,5 +218,6 @@
 	$(USPACE_PATH)/app/vdemo/vdemo \
 	$(USPACE_PATH)/app/viewer/viewer \
-	$(USPACE_PATH)/app/df/df
+	$(USPACE_PATH)/app/df/df \
+	$(USPACE_PATH)/app/fontviewer/fontviewer
 
 COMPONENTS = \
Index: boot/arch/amd64/Makefile.inc
===================================================================
--- boot/arch/amd64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ boot/arch/amd64/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -35,5 +35,5 @@
 
 RD_DRVS_ESSENTIAL += \
-	infrastructure/rootpc \
+	platform/pc \
 	block/ata_bd \
 	bus/pci/pciintel \
@@ -65,6 +65,6 @@
 	$(USPACE_PATH)/app/edit/edit \
 	$(USPACE_PATH)/app/mixerctl/mixerctl \
-	$(USPACE_PATH)/app/wavplay/wavplay \
-	
+	$(USPACE_PATH)/app/wavplay/wavplay
+
 BOOT_OUTPUT = $(ROOT_PATH)/image.iso
 PREBUILD = $(INITRD).img
Index: boot/arch/arm32/Makefile.inc
===================================================================
--- boot/arch/arm32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ boot/arch/arm32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -60,12 +60,26 @@
 
 ifeq ($(MACHINE), gta02)
-RD_SRVS_ESSENTIAL += \
-	$(USPACE_PATH)/srv/hid/s3c24xx_ts/s3c24xx_ts \
-	$(USPACE_PATH)/srv/hw/char/s3c24xx_uart/s3c24ser
+	RD_SRVS_ESSENTIAL += \
+		$(USPACE_PATH)/srv/hid/s3c24xx_ts/s3c24xx_ts \
+		$(USPACE_PATH)/srv/hw/char/s3c24xx_uart/s3c24ser
+endif
+
+ifeq ($(MACHINE), $(filter $(MACHINE),beagleboardxm beaglebone))
+	RD_DRVS_ESSENTIAL += \
+		platform/amdm37x \
+		fb/amdm37x_dispc
+endif
+
+ifeq ($(MACHINE), integratorcp)
+	RD_DRVS_ESSENTIAL += \
+		char/pl050 \
+		char/xtkbd \
+		char/ps2mouse \
+		platform/icp
+	RD_SRVS_ESSENTIAL += \
+		$(USPACE_PATH)/srv/hw/irc/icp-ic/icp-ic
 endif
 
 RD_DRVS_ESSENTIAL += \
-	infrastructure/rootamdm37x \
-	fb/amdm37x_dispc \
 	bus/usb/ehci \
 	bus/usb/ohci \
Index: boot/arch/ia64/Makefile.inc
===================================================================
--- boot/arch/ia64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ boot/arch/ia64/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -66,5 +66,5 @@
 
 RD_DRVS_ESSENTIAL += \
-	infrastructure/rootpc \
+	platform/pc \
 	bus/pci/pciintel \
 	bus/isa \
Index: boot/arch/mips32/Makefile.inc
===================================================================
--- boot/arch/mips32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ boot/arch/mips32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -52,5 +52,5 @@
 ifeq ($(MACHINE), $(filter $(MACHINE),bmalta lmalta))
 	RD_DRVS_ESSENTIAL += \
-		infrastructure/rootmalta \
+		platform/malta \
 		block/ata_bd \
 		bus/pci/pciintel \
Index: ot/arch/mips64/Makefile.inc
===================================================================
--- boot/arch/mips64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,52 +1,0 @@
-#
-# Copyright (c) 2006 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.
-#
-
-BFD_ARCH = mips:4000
-BITS = 64
-EXTRA_CFLAGS = -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=64
-
-ifeq ($(MACHINE),msim)
-	BFD_NAME = elf64-tradlittlemips
-	BFD_OUTPUT = binary
-	ENDIANESS = LE
-endif
-
-SOURCES = \
-	arch/$(BARCH)/src/asm.S \
-	arch/$(BARCH)/src/main.c \
-	arch/$(BARCH)/src/putchar.c \
-	$(COMPS_C) \
-	genarch/src/division.c \
-	genarch/src/multiplication.c \
-	generic/src/memstr.c \
-	generic/src/printf_core.c \
-	generic/src/vprintf.c \
-	generic/src/printf.c \
-	generic/src/str.c \
-	generic/src/version.c \
-	generic/src/inflate.c
Index: ot/arch/mips64/_link.ld.in
===================================================================
--- boot/arch/mips64/_link.ld.in	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,30 +1,0 @@
-OUTPUT_FORMAT(elf64-tradlittlemips)
-ENTRY(start)
-
-SECTIONS {
-	. = 0xffffffffbfc00000;
-	.text : {
-		*(BOOTSTRAP);
-		*(.text);
-	}
-	.data : {
-		*(.data);       /* initialized data */
-		*(.rodata);
-		*(.rodata.*);
-		*(.sdata);
-		*(.reginfo);
-		*(.sbss);
-		*(.scommon);
-		*(.bss);        /* uninitialized static variables */
-		*(COMMON);      /* global variables */
-[[COMPONENTS]]
-	}
-	
-	/DISCARD/ : {
-		*(.gnu.*);
-		*(.mdebug*);
-		*(.pdr);
-		*(.comment);
-		*(.note);
-	}
-}
Index: ot/arch/mips64/include/arch.h
===================================================================
--- boot/arch/mips64/include/arch.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- * Copyright (c) 2006 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.
- */
-
-#ifndef BOOT_mips64_ARCH_H_
-#define BOOT_mips64_ARCH_H_
-
-#define PAGE_WIDTH  14
-#define PAGE_SIZE   (1 << PAGE_WIDTH)
-
-#define CPUMAP_OFFSET    0x00001000
-#define STACK_OFFSET     0x00002000
-#define BOOTINFO_OFFSET  0x00003000
-#define BOOT_OFFSET      0x00100000
-#define LOADER_OFFSET    0x1fc00000
-
-#define MSIM_VIDEORAM_ADDRESS  0xffffffffb0000000
-#define MSIM_DORDER_ADDRESS    0xffffffffb0000100
-
-#ifndef __ASM__
-	#define PA2KA(addr)    (((uintptr_t) (addr)) + 0xffffffff80000000)
-	#define KSEG2PA(addr)  (((uintptr_t) (addr)) - 0xffffffffa0000000)
-#else
-	#define PA2KA(addr)    ((addr) + 0xffffffff80000000)
-	#define KSEG2PA(addr)  ((addr) - 0xffffffffa0000000)
-#endif
-
-#endif
Index: ot/arch/mips64/include/asm.h
===================================================================
--- boot/arch/mips64/include/asm.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/include/asm.h
Index: ot/arch/mips64/include/main.h
===================================================================
--- boot/arch/mips64/include/main.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/include/main.h
Index: ot/arch/mips64/include/regname.h
===================================================================
--- boot/arch/mips64/include/regname.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/include/regname.h
Index: ot/arch/mips64/include/types.h
===================================================================
--- boot/arch/mips64/include/types.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2006 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.
- */
-
-#ifndef BOOT_mips64_TYPES_H_
-#define BOOT_mips64_TYPES_H_
-
-#define TASKMAP_MAX_RECORDS        32
-#define CPUMAP_MAX_RECORDS         32
-#define BOOTINFO_TASK_NAME_BUFLEN  32
-
-typedef uint64_t size_t;
-typedef uint64_t uintptr_t;
-
-typedef struct {
-	/** Address where the task was placed. */
-	void *addr;
-	/** Size of the task's binary. */
-	size_t size;
-	/** Task name. */
-	char name[BOOTINFO_TASK_NAME_BUFLEN];
-} task_t;
-
-typedef struct {
-	uint32_t cpumap;
-	size_t cnt;
-	task_t tasks[TASKMAP_MAX_RECORDS];
-} bootinfo_t;
-
-#endif
Index: ot/arch/mips64/src/asm.S
===================================================================
--- boot/arch/mips64/src/asm.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,150 +1,0 @@
-#
-# Copyright (c) 2006 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-#include <arch/arch.h>
-#include <arch/regname.h>
-
-.set noat
-.set noreorder
-.set nomacro
-
-.global start
-.global halt
-.global jump_to_kernel
-
-.section BOOTSTRAP
-
-start:
-	/*
-	 * Setup the CP0 configuration
-	 *  - Enable 64-bit kernel addressing mode
-	 *  - Enable 64-bit supervisor adressing mode
-	 *  - Enable 64-bit user addressing mode
-	 */
-	mfc0 $a0, $status
-	ori $a0, 0x00e0
-	mtc0 $a0, $status
-	
-	/*
-	 * Setup CPU map (on msim this code
-	 * is executed in parallel on all CPUs,
-	 * but it not an issue).
-	 */
-	dla $a0, PA2KA(CPUMAP_OFFSET)
-	
-	sw $zero, 0($a0)
-	sw $zero, 4($a0)
-	sw $zero, 8($a0)
-	sw $zero, 12($a0)
-	
-	sw $zero, 16($a0)
-	sw $zero, 20($a0)
-	sw $zero, 24($a0)
-	sw $zero, 28($a0)
-	
-	sw $zero, 32($a0)
-	sw $zero, 36($a0)
-	sw $zero, 40($a0)
-	sw $zero, 44($a0)
-	
-	sw $zero, 48($a0)
-	sw $zero, 52($a0)
-	sw $zero, 56($a0)
-	sw $zero, 60($a0)
-	
-	sw $zero, 64($a0)
-	sw $zero, 68($a0)
-	sw $zero, 72($a0)
-	sw $zero, 76($a0)
-	
-	sw $zero, 80($a0)
-	sw $zero, 84($a0)
-	sw $zero, 88($a0)
-	sw $zero, 92($a0)
-	
-	sw $zero, 96($a0)
-	sw $zero, 100($a0)
-	sw $zero, 104($a0)
-	sw $zero, 108($a0)
-	
-	sw $zero, 112($a0)
-	sw $zero, 116($a0)
-	sw $zero, 120($a0)
-	sw $zero, 124($a0)
-	
-	lui $a1, 1
-	
-#ifdef MACHINE_msim
-	
-	/* Read dorder value */
-	dla $k0, MSIM_DORDER_ADDRESS
-	lw $k1, ($k0)
-	
-	/*
-	 * If we are not running on BSP
-	 * then end in an infinite loop.
-	 */
-	beq $k1, $zero, bsp
-	nop
-	
-	/* Record CPU presence */
-	sll $a2, $k1, 2
-	addu $a2, $a2, $a0
-	sw $a1, ($a2)
-	
-	loop:
-		j loop
-		nop
-	
-#endif
-	
-	bsp:
-		/* Record CPU presence */
-		sw $a1, ($a0)
-		
-		/* Setup initial stack */
-		dla $sp, PA2KA(STACK_OFFSET)
-		
-		j bootstrap
-		nop
-
-.text
-
-halt:
-	j halt
-	nop
-
-jump_to_kernel:
-	/*
-	 * TODO:
-	 *
-	 * Make sure that the I-cache, D-cache and memory are mutually
-	 * coherent before passing control to the copied code.
-	 */
-	j $a0
-	nop
Index: ot/arch/mips64/src/main.c
===================================================================
--- boot/arch/mips64/src/main.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,126 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <arch/main.h>
-#include <arch/arch.h>
-#include <arch/asm.h>
-#include <arch/_components.h>
-#include <halt.h>
-#include <printf.h>
-#include <memstr.h>
-#include <version.h>
-#include <macros.h>
-#include <align.h>
-#include <str.h>
-#include <errno.h>
-#include <inflate.h>
-
-#define TOP2ADDR(top)  (((void *) PA2KA(BOOT_OFFSET)) + (top))
-
-static bootinfo_t *bootinfo = (bootinfo_t *) PA2KA(BOOTINFO_OFFSET);
-static uint32_t *cpumap = (uint32_t *) PA2KA(CPUMAP_OFFSET);
-
-void bootstrap(void)
-{
-	version_print();
-	
-	printf("\nMemory statistics\n");
-	printf(" %p|%p: CPU map\n", (void *) PA2KA(CPUMAP_OFFSET),
-	    (void *) CPUMAP_OFFSET);
-	printf(" %p|%p: bootstrap stack\n", (void *) PA2KA(STACK_OFFSET),
-	    (void *) STACK_OFFSET);
-	printf(" %p|%p: boot info structure\n",
-	    (void *) PA2KA(BOOTINFO_OFFSET), (void *) BOOTINFO_OFFSET);
-	printf(" %p|%p: kernel entry point\n", (void *) PA2KA(BOOT_OFFSET),
-	    (void *) BOOT_OFFSET);
-	printf(" %p|%p: bootloader entry point\n",
-	    (void *) PA2KA(LOADER_OFFSET), (void *) LOADER_OFFSET);
-	
-	size_t i;
-	for (i = 0; i < COMPONENTS; i++)
-		printf(" %p|%p: %s image (%zu/%zu bytes)\n", components[i].start,
-		    (void *) KSEG2PA(components[i].start), components[i].name,
-		    components[i].inflated, components[i].size);
-	
-	void *dest[COMPONENTS];
-	size_t top = 0;
-	size_t cnt = 0;
-	bootinfo->cnt = 0;
-	for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
-		top = ALIGN_UP(top, PAGE_SIZE);
-		
-		if (i > 0) {
-			bootinfo->tasks[bootinfo->cnt].addr = TOP2ADDR(top);
-			bootinfo->tasks[bootinfo->cnt].size = components[i].inflated;
-			
-			str_cpy(bootinfo->tasks[bootinfo->cnt].name,
-			    BOOTINFO_TASK_NAME_BUFLEN, components[i].name);
-			
-			bootinfo->cnt++;
-		}
-		
-		dest[i] = TOP2ADDR(top);
-		top += components[i].inflated;
-		cnt++;
-	}
-	
-	printf("\nInflating components ... ");
-	
-	for (i = cnt; i > 0; i--) {
-		void *tail = dest[i - 1] + components[i].inflated;
-		if (tail >= ((void *) PA2KA(LOADER_OFFSET))) {
-			printf("\n%s: Image too large to fit (%p >= %p), halting.\n",
-			    components[i].name, tail, (void *) PA2KA(LOADER_OFFSET));
-			halt();
-		}
-		
-		printf("%s ", components[i - 1].name);
-		
-		int err = inflate(components[i - 1].start, components[i - 1].size,
-		    dest[i - 1], components[i - 1].inflated);
-		
-		if (err != EOK) {
-			printf("\n%s: Inflating error %d, halting.\n",
-			    components[i - 1].name, err);
-			halt();
-		}
-	}
-	
-	printf(".\n");
-	
-	printf("Copying CPU map ... \n");
-	
-	bootinfo->cpumap = 0;
-	for (i = 0; i < CPUMAP_MAX_RECORDS; i++) {
-		if (cpumap[i] != 0)
-			bootinfo->cpumap |= (1 << i);
-	}
-	
-	printf("Booting the kernel ... \n");
-	jump_to_kernel((void *) PA2KA(BOOT_OFFSET), bootinfo);
-}
Index: ot/arch/mips64/src/putchar.c
===================================================================
--- boot/arch/mips64/src/putchar.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,40 +1,0 @@
-/*
- * Copyright (c) 2006 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <typedefs.h>
-#include <arch/arch.h>
-#include <putchar.h>
-#include <str.h>
-
-void putchar(const wchar_t ch)
-{
-	if (ascii_check(ch))
-		*((char *) MSIM_VIDEORAM_ADDRESS) = ch;
-	else
-		*((char *) MSIM_VIDEORAM_ADDRESS) = U_SPECIAL;
-}
Index: boot/arch/ppc32/Makefile.inc
===================================================================
--- boot/arch/ppc32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ boot/arch/ppc32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -43,5 +43,5 @@
 
 RD_DRVS_ESSENTIAL += \
-	infrastructure/rootmac \
+	platform/mac \
 	bus/pci/pciintel \
 	bus/usb/ohci \
Index: contrib/artwork/HelenOS-bw.svg
===================================================================
--- contrib/artwork/HelenOS-bw.svg	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ contrib/artwork/HelenOS-bw.svg	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,290 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   id="svg3437"
+   version="1.1"
+   inkscape:version="0.48.4 r9939"
+   width="259.225"
+   height="231.9"
+   xml:space="preserve"
+   sodipodi:docname="HelenOS-bw.svg"><metadata
+     id="metadata3443"><rdf:RDF><cc:Work
+         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+     id="defs3441"><linearGradient
+       id="linearGradient7208"><stop
+         style="stop-color:#ebeef1;stop-opacity:1;"
+         offset="0"
+         id="stop7210" /><stop
+         style="stop-color:#cad0d4;stop-opacity:1"
+         offset="1"
+         id="stop7212" /></linearGradient><clipPath
+       clipPathUnits="userSpaceOnUse"
+       id="clipPath3475"><path
+         d="m 816.738,689.309 c -41.34,0 -80.386,25.441 -96.019,66.679 L 477.898,1395.8 c -4.722,12.45 -6.89,25.24 -6.765,37.79 0.418,40.99 25.34,79.39 65.719,94.69 l 635.128,241.02 c 11.89,4.52 24.1,6.66 36.11,6.66 41.36,0 80.39,-25.4 96.01,-66.69 l 242.82,-639.72 c 4.72,-12.46 6.89,-25.27 6.76,-37.84 -0.41,-41.026 -25.35,-79.433 -65.8,-94.73 L 852.75,695.961 c -11.848,-4.512 -24.031,-6.652 -36.012,-6.652"
+         id="path3477" /></clipPath><linearGradient
+       x1="0"
+       y1="0"
+       x2="1"
+       y2="0"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(39.659,-85.0491,-85.0491,-39.659,81.4102,165.789)"
+       spreadMethod="pad"
+       id="linearGradient3479"><stop
+         style="stop-opacity:1;stop-color:#ffffff"
+         offset="0"
+         id="stop3481" /><stop
+         style="stop-opacity:1;stop-color:#cac9ca"
+         offset="1"
+         id="stop3483" /></linearGradient><filter
+       id="filter4590"
+       inkscape:label="Inner Shadow"
+       inkscape:menu="Shadows and Glows"
+       inkscape:menu-tooltip="Adds a colorizable drop shadow inside"
+       color-interpolation-filters="sRGB"><feGaussianBlur
+         id="feGaussianBlur4592"
+         stdDeviation="4"
+         result="result8" /><feOffset
+         id="feOffset4594"
+         dx="4"
+         dy="4"
+         result="result11" /><feComposite
+         id="feComposite4596"
+         in2="result11"
+         result="result6"
+         in="SourceGraphic"
+         operator="in" /><feFlood
+         id="feFlood4598"
+         result="result10"
+         in="result6"
+         flood-opacity="1"
+         flood-color="rgb(76,76,76)" /><feBlend
+         id="feBlend4600"
+         in2="result10"
+         mode="normal"
+         in="result6"
+         result="result12" /><feComposite
+         id="feComposite4602"
+         in2="SourceGraphic"
+         result="result2"
+         operator="in" /></filter><filter
+       id="filter4738"
+       style="color-interpolation-filters:sRGB;"
+       inkscape:label="Drop Shadow"><feFlood
+         id="feFlood4740"
+         flood-opacity="0.8909657320872274"
+         flood-color="rgb(0,0,0)"
+         result="flood" /><feComposite
+         id="feComposite4742"
+         in2="SourceGraphic"
+         in="flood"
+         operator="in"
+         result="composite1" /><feGaussianBlur
+         id="feGaussianBlur4744"
+         in="composite"
+         stdDeviation="2.5738461538461532"
+         result="blur" /><feOffset
+         id="feOffset4746"
+         dx="0"
+         dy="2"
+         result="offset" /><feComposite
+         id="feComposite4748"
+         in2="offset"
+         in="SourceGraphic"
+         operator="over"
+         result="composite2" /></filter><filter
+       id="filter4768"
+       inkscape:label="Drop Shadow"
+       inkscape:menu="Shadows and Glows"
+       inkscape:menu-tooltip="Adds a colorizable drop shadow inside"
+       color-interpolation-filters="sRGB"
+       style="color-interpolation-filters:sRGB;"><feGaussianBlur
+         id="feGaussianBlur4770"
+         stdDeviation="1"
+         result="result8" /><feOffset
+         id="feOffset4772"
+         dx="1"
+         dy="1"
+         result="result11" /><feComposite
+         id="feComposite4774"
+         in2="result11"
+         result="result6"
+         in="SourceGraphic"
+         operator="in" /><feFlood
+         id="feFlood4776"
+         result="result10"
+         in="result6"
+         flood-opacity="1"
+         flood-color="rgb(60,62,63)" /><feBlend
+         id="feBlend4778"
+         in2="result10"
+         mode="normal"
+         in="result6"
+         result="result12" /><feComposite
+         id="feComposite4780"
+         in2="SourceGraphic"
+         result="fbSourceGraphic"
+         operator="in" /><feColorMatrix
+         result="fbSourceGraphicAlpha"
+         in="fbSourceGraphic"
+         values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"
+         id="feColorMatrix4924" /><feFlood
+         id="feFlood4926"
+         flood-opacity="0.90537634408602152"
+         flood-color="rgb(255,255,255)"
+         result="flood"
+         in="fbSourceGraphic" /><feComposite
+         id="feComposite4928"
+         in2="fbSourceGraphic"
+         in="flood"
+         operator="in"
+         result="composite1" /><feGaussianBlur
+         id="feGaussianBlur4930"
+         in="composite"
+         stdDeviation="0.24978417266187047"
+         result="blur" /><feOffset
+         id="feOffset4932"
+         dx="1"
+         dy="1"
+         result="offset" /><feComposite
+         id="feComposite4934"
+         in2="offset"
+         in="fbSourceGraphic"
+         operator="over"
+         result="composite2" /></filter></defs><sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1276"
+     inkscape:window-height="761"
+     id="namedview3439"
+     showgrid="false"
+     inkscape:zoom="1.9910926"
+     inkscape:cx="112.16509"
+     inkscape:cy="118.08751"
+     inkscape:window-x="0"
+     inkscape:window-y="18"
+     inkscape:window-maximized="0"
+     inkscape:current-layer="layer3"
+     showguides="true"
+     inkscape:guide-bbox="true" /><g
+     inkscape:groupmode="layer"
+     id="layer2"
+     inkscape:label="Logo"
+     style="display:inline"
+     sodipodi:insensitive="true"><g
+       id="g4604"><g
+         id="g7230"
+         style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"><path
+           style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"
+           d="m 154.40625,8.03125 c -3.44489,0.1085783 -7.07954,0.887883 -10.34375,2 l -82.875,28.25 c -4.345046,1.480356 -8.907838,5.34982 -11.0625,10.4375 l -1.28125,0 0,6.25 c 0.03146,1.842787 0.416614,3.783702 1.21875,5.75 l 34.5,84.53125 c 2.357198,5.77826 9.727781,11.07791 19.8125,7.5 l 92.5,-32.8125 c 3.85958,-1.36932 8.8395,-5.83824 8.78125,-12.5 l 0.0312,0 0,-5.875 -1.3125,0 c -0.013,-0.0312 -0.018,-0.0625 -0.0312,-0.0937 l -36.625,-86.375 c -2.32772,-5.4895321 -7.57102,-7.2434638 -13.3125,-7.0625 z"
+           id="path5035"
+           inkscape:connector-curvature="0" /></g><path
+         sodipodi:nodetypes="sssssssss"
+         inkscape:connector-curvature="0"
+         id="path4485"
+         d="M 144.06902,4.0450664 61.198812,32.278932 C 53.834625,34.787909 45.731809,44.10879 50.057881,54.713409 L 84.548982,139.2624 c 2.357198,5.77826 9.755299,11.05606 19.840018,7.47815 l 92.48498,-32.81233 c 4.92096,-1.74588 11.69893,-8.51248 7.47816,-18.466475 L 167.72442,9.0813775 C 164.00007,0.29812656 152.77359,1.0794208 144.06902,4.0450664 z"
+         style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none" /><path
+         sodipodi:type="inkscape:offset"
+         inkscape:radius="-6.7012396"
+         inkscape:original="M 157.75 2.15625 C 153.38977 1.6243729 148.41478 2.5484272 144.0625 4.03125 L 61.1875 32.28125 C 53.823313 34.790227 45.736428 44.114131 50.0625 54.71875 L 84.5625 139.25 C 86.919698 145.02826 94.290281 150.32791 104.375 146.75 L 196.875 113.9375 C 201.79596 112.19162 208.56452 105.42275 204.34375 95.46875 L 167.71875 9.09375 C 165.85657 4.7021245 162.11023 2.6881271 157.75 2.15625 z "
+         style="fill:#ffffff;fill-opacity:1;stroke:none"
+         id="path7206"
+         d="m 156.9375,8.8125 c -2.82602,-0.3447281 -7.03762,0.3083377 -10.71875,1.5625 l -82.875,28.25 c -1.992244,0.678757 -4.857585,2.803885 -6.375,5.3125 -1.517415,2.508615 -2.039469,4.935882 -0.6875,8.25 l 34.5,84.53125 c 1.053105,2.5815 4.193953,6.25539 11.34375,3.71875 l 92.5,-32.8125 c 0.80096,-0.28417 2.6915,-1.58104 3.5625,-3.125 0.871,-1.54396 1.39467,-3.11714 0,-6.40625 l -36.625,-86.375 c -0.8886,-2.0956068 -1.82512,-2.5647104 -4.625,-2.90625 z" /><g
+         id="g4542"
+         style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"><path
+           inkscape:connector-curvature="0"
+           id="path4473"
+           d="m 135.03125,34.78125 a 6.750675,6.750675 0 0 0 -6.21875,9.375 l 6.4375,15.9375 -23.78125,9.5625 L 105.03125,53.75 A 6.750675,6.750675 0 0 0 98.75,49.4375 6.750675,6.750675 0 0 0 92.53125,58.8125 L 110,102.03125 a 6.7576093,6.7576093 0 1 0 12.53125,-5.0625 l -6.5625,-16.1875 23.78125,-9.5625 6.53125,16.15625 a 6.7576093,6.7576093 0 1 0 12.53125,-5.0625 l -17.5,-43.21875 a 6.750675,6.750675 0 0 0 -6.28125,-4.3125 z"
+           style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" /></g><g
+         id="g4750"
+         style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"><path
+           sodipodi:type="arc"
+           style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.46130222;stroke-miterlimit:4;stroke-dasharray:none"
+           id="path4479"
+           sodipodi:cx="102.06332"
+           sodipodi:cy="125.22211"
+           sodipodi:rx="3.25734"
+           sodipodi:ry="3.1216176"
+           d="m 105.32066,125.22211 a 3.25734,3.1216176 0 1 1 -6.514684,0 3.25734,3.1216176 0 1 1 6.514684,0 z"
+           transform="matrix(0.98880313,-0.44393908,0.44393908,0.98880313,-54.312475,46.576269)" /><path
+           transform="matrix(0.98880313,-0.44393908,0.44393908,0.98880313,27.39247,17.938822)"
+           d="m 105.32066,125.22211 a 3.25734,3.1216176 0 1 1 -6.514684,0 3.25734,3.1216176 0 1 1 6.514684,0 z"
+           sodipodi:ry="3.1216176"
+           sodipodi:rx="3.25734"
+           sodipodi:cy="125.22211"
+           sodipodi:cx="102.06332"
+           id="path4481"
+           style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.46130222;stroke-miterlimit:4;stroke-dasharray:none"
+           sodipodi:type="arc" /></g><path
+         style="fill:#4d4d4d;fill-opacity:1;stroke:none"
+         d="m 155.84375,8.53125 c -2.7841,-0.086304 -6.45076,0.5847419 -9.6875,1.6875 l -82.875,28.25 c -2.037566,0.694198 -4.927624,2.827186 -6.46875,5.375 -1.541126,2.547814 -2.092472,5.038809 -0.71875,8.40625 l 34.5,84.53125 c 0.443193,1.08641 1.273856,2.34335 2.5625,3.28125 -0.970342,-0.86582 -1.626075,-1.89589 -2,-2.8125 l -34.5,-84.53125 C 55.28948,49.368352 55.840427,46.91198 57.375,44.375 c 1.530152,-2.529672 4.421979,-4.657063 6.4375,-5.34375 l 82.875,-28.25 c 2.76829,-0.9431583 5.83842,-1.5525003 8.40625,-1.65625 0.85594,-0.034583 1.66293,-0.024361 2.375,0.0625 1.41789,0.1729592 2.35949,0.444633 2.89232,0.8024892 0.1708,0.1147148 0.5204,0.2465578 0.67018,0.3850108 -0.80331,-1.1222334 -1.88419,-1.4842817 -4.0625,-1.75 -0.3584,-0.043718 -0.72727,-0.081421 -1.125,-0.09375 z"
+         id="path5113"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="sccscccccsccssscss" /><path
+         style="fill:#4d4d4d;fill-opacity:1;stroke:none"
+         d="m 158.375,8.84375 c 0.4119,0.085094 0.77418,0.1866234 1.09375,0.3125 -0.3182,-0.1277152 -0.68149,-0.2278629 -1.09375,-0.3125 z m -8.34375,0.3125 c -0.52306,0.1108753 -1.04032,0.2382306 -1.5625,0.375 0.51786,-0.1361952 1.04381,-0.264064 1.5625,-0.375 z m 10.01745,0.6962932 c 0.32528,0.2630278 0.36217,0.4773388 0.5138,0.8349568 l 36.625,86.375 c 0.70023,1.651396 0.93765,2.884086 0.875,3.875 -0.0626,0.99073 -0.43213,1.74619 -0.875,2.53125 -0.43241,0.76651 -1.09694,1.47237 -1.78125,2.03125 -0.68401,0.55863 -1.39617,0.98837 -1.78125,1.125 l -92.5,32.8125 c -3.582155,1.2709 -6.124046,0.97982 -7.9375,0.0625 -0.396515,-0.20058 -0.950398,-0.67555 -1.276291,-1.09315 -0.325894,-0.4176 -0.30025,-0.45646 -0.799278,-1.15258 0.328593,0.8104 0.876055,1.6176 1.489631,2.26917 0.330647,0.25808 0.621581,0.36703 1.023438,0.57031 1.841002,0.93126 4.429643,1.2153 8.03125,-0.0625 l 92.5,-32.8125 c 0.40826,-0.14485 1.1207,-0.56001 1.8125,-1.125 0.6918,-0.56499 1.37094,-1.27978 1.8125,-2.0625 0.44554,-0.78978 0.81102,-1.58146 0.875,-2.59375 0.064,-1.01229 -0.17077,-2.245431 -0.875,-3.90625 l -36.625,-86.375 c -0.20218,-0.476821 -0.20571,-0.799924 -0.43359,-1.121094 -0.008,-0.0048 -0.1992,-0.1554565 -0.207,-0.160156 -0.12453,-0.07439 -0.59028,-0.1518513 -0.73061,-0.2146941 z"
+         id="path5135"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="ccccccccscssccczccsccsscsscccc" /><path
+         style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
+         d="m 78.411182,125.34412 5.640369,-6.62439 -23.160725,-56.389089 -7.679381,1.018426 z"
+         id="path4487"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="ccccc" /><path
+         sodipodi:nodetypes="ccccc"
+         inkscape:connector-curvature="0"
+         id="path4519"
+         d="m 79.019887,125.55253 5.440835,-5.59341 -0.48766,-1.41355 -5.651067,7.26442 z"
+         style="fill:#000000;stroke:none" /><path
+         sodipodi:nodetypes="ccccc"
+         inkscape:connector-curvature="0"
+         id="path4521"
+         d="m 59.978424,61.811457 -7.052525,-0.01903 -0.06697,1.359774 7.75195,-0.769753 z"
+         style="fill:#000000;stroke:none" /></g></g><g
+     inkscape:groupmode="layer"
+     id="layer3"
+     inkscape:label="Text"
+     style="display:inline"
+     sodipodi:insensitive="true"><path
+       d="m 39.99308,164.63193 7.5825,0 0,56.12353 -7.5825,0 0,-26.18603 -29.312963,0 0,26.18603 -7.5820371,0 0,-56.12353 7.5820371,0 0,23.21487 29.312963,0 0,-23.21487"
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3449"
+       inkscape:connector-curvature="0" /><path
+       d="m 82.48533,197.07093 c -0.234375,-3.59525 -1.172375,-6.5665 -2.96975,-8.834 -1.72025,-2.26613 -4.53425,-3.35988 -8.442375,-3.35988 -2.03275,0 -3.90825,0.54588 -5.6285,1.64113 -1.79775,1.17237 -3.2045,2.65775 -4.221125,4.61225 -1.016125,1.95412 -1.484875,3.90775 -1.484875,5.9405 l 22.746625,0 z m 6.566375,10.86475 c -0.234375,1.48625 -0.9385,3.28365 -2.110875,5.54976 -1.172375,2.26758 -2.892125,4.14405 -5.158625,5.62794 -1.328625,0.86084 -2.736375,1.56347 -4.299375,2.03222 -1.564,0.54736 -3.8305,0.78271 -6.80025,0.78271 -2.8145,0 -5.394125,-0.54785 -7.660625,-1.56396 -2.267125,-1.01611 -4.22125,-2.42236 -5.78475,-4.29883 -1.641625,-1.87598 -2.813875,-4.06494 -3.595625,-6.48734 -0.859375,-2.42375 -1.251,-5.15863 -1.251,-8.12988 0,-4.30025 0.704125,-8.2075 2.189,-11.64737 1.407125,-3.439 3.595125,-6.17538 6.48775,-8.13038 2.97075,-1.95225 6.6445,-2.96975 10.943875,-2.96975 2.892,0 5.471625,0.54738 7.73875,1.6425 2.1885,1.171 3.985875,2.73488 5.471625,4.76713 1.40675,2.03275 2.501,4.53425 3.28325,7.42625 0.703125,2.89262 1.09425,6.254 1.09425,10.00637 l -29.860375,0 c 0,4.29888 1.016125,7.58155 3.048875,9.92628 1.953625,2.34521 4.92425,3.51757 8.833,3.51757 1.563,0 2.96975,-0.23388 4.29825,-0.78125 1.2515,-0.54736 2.34575,-1.17236 3.28325,-2.03271 0.860375,-0.85986 1.642125,-1.71875 2.189,-2.73584 0.46925,-0.93755 0.703625,-1.79642 0.78175,-2.50142 l 6.878875,0"
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3451"
+       inkscape:connector-curvature="0" /><path
+       d="m 94.186955,220.75546 6.878415,0 0,-56.12349 -6.878415,0 0,56.12349 z"
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3453"
+       inkscape:connector-curvature="0" /><path
+       d="m 135.60559,197.07093 c -0.23375,-3.59525 -1.17125,-6.5665 -2.97,-8.834 -1.72,-2.26613 -4.53375,-3.35988 -8.44176,-3.35988 -2.03275,0 -3.90875,0.54588 -5.6285,1.64113 -1.79787,1.17237 -3.2045,2.65775 -4.22062,4.61225 -1.01663,1.95412 -1.48538,3.90775 -1.48538,5.9405 l 22.74626,0 z m 6.56625,10.86475 c -0.23375,1.48625 -0.9375,3.28365 -2.11,5.54976 -1.1725,2.26758 -2.8925,4.14405 -5.15875,5.62794 -1.33,0.86084 -2.73625,1.56347 -4.3,2.03222 -1.56375,0.54736 -3.83026,0.78271 -6.80038,0.78271 -2.814,0 -5.39363,-0.54785 -7.66025,-1.56396 -2.2675,-1.01611 -4.22113,-2.42236 -5.78513,-4.29883 -1.64112,-1.87598 -2.8135,-4.06494 -3.59512,-6.48734 -0.85988,-2.42375 -1.2505,-5.15863 -1.2505,-8.12988 0,-4.30025 0.70362,-8.2075 2.18837,-11.64737 1.40675,-3.439 3.59575,-6.17538 6.48838,-8.13038 2.96962,-1.95225 6.644,-2.96975 10.94337,-2.96975 2.89151,0 5.47126,0.54738 7.73876,1.6425 2.18875,1.171 3.98625,2.73488 5.47125,4.76713 1.4075,2.03275 2.50125,4.53425 3.28375,7.42625 0.7025,2.89262 1.09375,6.254 1.09375,10.00637 l -29.86001,0 c 0,4.29888 1.01563,7.58155 3.04838,9.92628 1.954,2.34521 4.92475,3.51757 8.833,3.51757 1.56337,0 2.97013,-0.23388 4.29863,-0.78125 1.25,-0.54736 2.345,-1.17236 3.28375,-2.03271 0.86,-0.85986 1.64125,-1.71875 2.18875,-2.73584 0.46875,-0.93755 0.70375,-1.79642 0.78125,-2.50142 l 6.87875,0"
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3455"
+       inkscape:connector-curvature="0" /><path
+       d="m 180.52934,220.75546 -6.88,0 -0.0788,-25.16991 c 0,-3.7525 -0.625,-6.48737 -1.9525,-8.12987 -1.25125,-1.72025 -3.51875,-2.57863 -6.80125,-2.57863 -1.5625,0 -3.205,0.38963 -4.84625,1.25 -1.64125,0.78225 -3.04875,2.1885 -4.22125,4.22113 -1.1725,2.03225 -1.71875,4.76762 -1.71875,8.13 l 0,22.27728 -6.87875,0 0,-40.88091 6.48625,0 0,5.78375 0.1575,0 c 1.1725,-1.79887 2.81375,-3.36137 4.76875,-4.84625 1.95375,-1.40762 4.53375,-2.11125 7.58125,-2.11125 2.4225,0 4.7675,0.39113 6.87875,1.251 2.11,0.78125 3.90875,2.2675 5.39375,4.37738 1.40625,2.11137 2.11125,5.003 2.11125,8.59762 l 0,27.82866"
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3457"
+       inkscape:connector-curvature="0" /><path
+       d="m 208.41059,179.16955 c 0,-2.42237 -0.3125,-4.29887 -0.9375,-5.70512 -0.625,-1.48625 -1.955,-2.189 -3.90875,-2.189 -1.955,0 -3.205,0.78125 -3.90875,2.26662 -0.70375,1.48488 -1.01625,3.36138 -1.01625,5.6275 l 0,24.07613 c 0,5.55125 1.6425,8.36476 5.0025,8.36476 1.955,0 3.28375,-0.78125 3.90875,-2.42339 0.5475,-1.56387 0.86,-3.5175 0.86,-5.94137 l 0,-24.07613 z m 13.7575,22.90475 c 0,3.439 -0.31375,6.40875 -0.93875,8.83253 -0.625,2.42236 -1.64125,4.45507 -3.12625,6.17382 -1.4075,1.64259 -3.28375,2.89357 -5.70625,3.75245 -2.345,0.85986 -5.23625,1.33008 -8.755,1.33008 -3.43875,0 -6.33125,-0.47022 -8.755,-1.33008 -2.4225,-0.85888 -4.3775,-2.10986 -5.86125,-3.75245 -1.48625,-1.71875 -2.50125,-3.82861 -3.1275,-6.25146 -0.70375,-2.42476 -1.01625,-5.39501 -1.01625,-8.75489 l 0,-23.84225 c 0,-5.62887 1.6425,-9.92775 4.925,-12.97512 3.20375,-3.04888 7.8175,-4.53375 13.835,-4.53375 6.01875,0 10.63125,1.48487 13.83625,4.53375 3.12625,3.04737 4.69,7.34625 4.69,12.97512 l 0,23.84225"
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3459"
+       inkscape:connector-curvature="0" /><path
+       d="m 236.4985,201.1358 0,4.14213 c 0,1.95512 0.39,3.44037 1.25,4.61279 0.7825,1.17236 2.18875,1.71972 4.22125,1.71972 1.485,0 2.57875,-0.54736 3.44,-1.71972 0.78125,-1.17242 1.17125,-2.50142 1.17125,-4.14404 0,-2.10988 -0.54625,-3.67238 -1.72,-4.76713 -1.17125,-1.09375 -3.12625,-2.50137 -5.94,-4.22112 -4.92375,-2.814 -8.4425,-5.39413 -10.39625,-7.66025 -2.6575,-3.12738 -3.9875,-7.03513 -3.9875,-11.726 0,-2.73638 0.3925,-5.15925 1.25125,-7.27 0.78125,-2.11038 1.87625,-3.83013 3.36125,-5.23638 1.485,-1.32912 3.28375,-2.42287 5.39375,-3.12737 2.11125,-0.70275 4.53375,-1.01525 7.27,-1.01525 2.81375,0 5.315,0.46875 7.50375,1.32862 2.1875,0.85988 4.06375,2.11138 5.55,3.7515 1.485,1.64113 2.57875,3.67388 3.2825,6.01863 0.70375,2.34512 1.095,5.00237 1.095,7.89637 l -12.66375,0 c -0.0775,-2.73775 -0.39,-4.77 -0.85875,-6.17625 -0.46875,-1.32912 -1.72,-2.11037 -3.675,-2.26662 -2.89125,0 -4.455,1.32775 -4.7675,3.90925 0,1.79587 0.3125,3.126 1.01625,4.14112 0.70375,1.0175 1.71875,2.03225 3.12625,3.04975 1.25,0.78125 2.8925,1.79738 5.0025,3.04738 2.11125,1.17387 3.67375,2.189 4.7675,2.89262 1.095,0.70413 2.11125,1.48538 3.05,2.34513 1.64,1.5635 2.97,3.44 3.82875,5.629 0.86125,2.1885 1.25125,5.00237 1.25125,8.36325 0,3.67387 -0.7025,6.8789 -2.0325,9.53661 -1.32875,2.57861 -3.36,4.61134 -5.94125,5.94093 -2.65625,1.32763 -5.86125,2.03271 -9.69125,2.03271 -2.97,0 -5.6275,-0.39258 -7.89625,-1.17383 -2.26625,-0.70264 -4.14125,-1.79736 -5.6275,-3.20361 -1.485,-1.40772 -2.57875,-2.9712 -3.28375,-4.76905 -0.7025,-1.79736 -1.09375,-3.67339 -1.09375,-5.62739 l 0,-6.2535 12.7425,0"
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3461"
+       inkscape:connector-curvature="0" /></g></svg>
Index: contrib/artwork/HelenOS.svg
===================================================================
--- contrib/artwork/HelenOS.svg	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ contrib/artwork/HelenOS.svg	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,338 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   id="svg3437"
+   version="1.1"
+   inkscape:version="0.48.4 r9939"
+   width="259.225"
+   height="231.9"
+   xml:space="preserve"
+   sodipodi:docname="HelenOS.svg"><metadata
+     id="metadata3443"><rdf:RDF><cc:Work
+         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+     id="defs3441"><linearGradient
+       id="linearGradient7224"
+       inkscape:collect="always"><stop
+         id="stop7226"
+         offset="0"
+         style="stop-color:#f4f7f9;stop-opacity:1" /><stop
+         id="stop7228"
+         offset="1"
+         style="stop-color:#cad0d4;stop-opacity:1" /></linearGradient><linearGradient
+       id="linearGradient7208"><stop
+         style="stop-color:#ebeef1;stop-opacity:1;"
+         offset="0"
+         id="stop7210" /><stop
+         style="stop-color:#cad0d4;stop-opacity:1"
+         offset="1"
+         id="stop7212" /></linearGradient><clipPath
+       clipPathUnits="userSpaceOnUse"
+       id="clipPath3475"><path
+         d="m 816.738,689.309 c -41.34,0 -80.386,25.441 -96.019,66.679 L 477.898,1395.8 c -4.722,12.45 -6.89,25.24 -6.765,37.79 0.418,40.99 25.34,79.39 65.719,94.69 l 635.128,241.02 c 11.89,4.52 24.1,6.66 36.11,6.66 41.36,0 80.39,-25.4 96.01,-66.69 l 242.82,-639.72 c 4.72,-12.46 6.89,-25.27 6.76,-37.84 -0.41,-41.026 -25.35,-79.433 -65.8,-94.73 L 852.75,695.961 c -11.848,-4.512 -24.031,-6.652 -36.012,-6.652"
+         id="path3477" /></clipPath><linearGradient
+       x1="0"
+       y1="0"
+       x2="1"
+       y2="0"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(39.659,-85.0491,-85.0491,-39.659,81.4102,165.789)"
+       spreadMethod="pad"
+       id="linearGradient3479"><stop
+         style="stop-opacity:1;stop-color:#ffffff"
+         offset="0"
+         id="stop3481" /><stop
+         style="stop-opacity:1;stop-color:#cac9ca"
+         offset="1"
+         id="stop3483" /></linearGradient><filter
+       id="filter4590"
+       inkscape:label="Inner Shadow"
+       inkscape:menu="Shadows and Glows"
+       inkscape:menu-tooltip="Adds a colorizable drop shadow inside"
+       color-interpolation-filters="sRGB"><feGaussianBlur
+         id="feGaussianBlur4592"
+         stdDeviation="4"
+         result="result8" /><feOffset
+         id="feOffset4594"
+         dx="4"
+         dy="4"
+         result="result11" /><feComposite
+         id="feComposite4596"
+         in2="result11"
+         result="result6"
+         in="SourceGraphic"
+         operator="in" /><feFlood
+         id="feFlood4598"
+         result="result10"
+         in="result6"
+         flood-opacity="1"
+         flood-color="rgb(76,76,76)" /><feBlend
+         id="feBlend4600"
+         in2="result10"
+         mode="normal"
+         in="result6"
+         result="result12" /><feComposite
+         id="feComposite4602"
+         in2="SourceGraphic"
+         result="result2"
+         operator="in" /></filter><filter
+       id="filter4738"
+       style="color-interpolation-filters:sRGB;"
+       inkscape:label="Drop Shadow"><feFlood
+         id="feFlood4740"
+         flood-opacity="0.8909657320872274"
+         flood-color="rgb(0,0,0)"
+         result="flood" /><feComposite
+         id="feComposite4742"
+         in2="SourceGraphic"
+         in="flood"
+         operator="in"
+         result="composite1" /><feGaussianBlur
+         id="feGaussianBlur4744"
+         in="composite"
+         stdDeviation="2.5738461538461532"
+         result="blur" /><feOffset
+         id="feOffset4746"
+         dx="0"
+         dy="2"
+         result="offset" /><feComposite
+         id="feComposite4748"
+         in2="offset"
+         in="SourceGraphic"
+         operator="over"
+         result="composite2" /></filter><filter
+       id="filter4768"
+       inkscape:label="Drop Shadow"
+       inkscape:menu="Shadows and Glows"
+       inkscape:menu-tooltip="Adds a colorizable drop shadow inside"
+       color-interpolation-filters="sRGB"
+       style="color-interpolation-filters:sRGB;"><feGaussianBlur
+         id="feGaussianBlur4770"
+         stdDeviation="1"
+         result="result8" /><feOffset
+         id="feOffset4772"
+         dx="1"
+         dy="1"
+         result="result11" /><feComposite
+         id="feComposite4774"
+         in2="result11"
+         result="result6"
+         in="SourceGraphic"
+         operator="in" /><feFlood
+         id="feFlood4776"
+         result="result10"
+         in="result6"
+         flood-opacity="1"
+         flood-color="rgb(60,62,63)" /><feBlend
+         id="feBlend4778"
+         in2="result10"
+         mode="normal"
+         in="result6"
+         result="result12" /><feComposite
+         id="feComposite4780"
+         in2="SourceGraphic"
+         result="fbSourceGraphic"
+         operator="in" /><feColorMatrix
+         result="fbSourceGraphicAlpha"
+         in="fbSourceGraphic"
+         values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"
+         id="feColorMatrix4924" /><feFlood
+         id="feFlood4926"
+         flood-opacity="0.90537634408602152"
+         flood-color="rgb(255,255,255)"
+         result="flood"
+         in="fbSourceGraphic" /><feComposite
+         id="feComposite4928"
+         in2="fbSourceGraphic"
+         in="flood"
+         operator="in"
+         result="composite1" /><feGaussianBlur
+         id="feGaussianBlur4930"
+         in="composite"
+         stdDeviation="0.24978417266187047"
+         result="blur" /><feOffset
+         id="feOffset4932"
+         dx="1"
+         dy="1"
+         result="offset" /><feComposite
+         id="feComposite4934"
+         in2="offset"
+         in="fbSourceGraphic"
+         operator="over"
+         result="composite2" /></filter><linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient7208"
+       id="linearGradient7214"
+       x1="104.32044"
+       y1="18.753582"
+       x2="150.06894"
+       y2="128.61929"
+       gradientUnits="userSpaceOnUse" /><linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient7224"
+       id="linearGradient7222"
+       x1="108.13281"
+       y1="25.685173"
+       x2="146.25656"
+       y2="122.38086"
+       gradientUnits="userSpaceOnUse" /></defs><sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1276"
+     inkscape:window-height="761"
+     id="namedview3439"
+     showgrid="false"
+     inkscape:zoom="2.259464"
+     inkscape:cx="110.05942"
+     inkscape:cy="117.36032"
+     inkscape:window-x="0"
+     inkscape:window-y="18"
+     inkscape:window-maximized="0"
+     inkscape:current-layer="layer3"
+     showguides="true"
+     inkscape:guide-bbox="true" /><g
+     inkscape:groupmode="layer"
+     id="layer2"
+     inkscape:label="Logo"
+     style="display:inline"
+     sodipodi:insensitive="true"><g
+       id="g4604"
+       style="filter:url(#filter4738)"><g
+         id="g7230"><path
+           sodipodi:nodetypes="sssssssss"
+           inkscape:connector-curvature="0"
+           id="path5035"
+           d="M 144.06902,10.045066 61.198812,38.278932 C 53.834625,40.787909 45.731809,50.10879 50.057881,60.713409 L 84.548982,145.2624 c 2.357198,5.77826 9.755299,11.05606 19.840018,7.47815 l 92.48498,-32.81233 c 4.92096,-1.74588 11.69893,-8.51248 7.47816,-18.46647 L 167.72442,15.081378 c -3.72435,-8.7832514 -14.95083,-8.0019572 -23.6554,-5.036312 z"
+           style="fill:#4f5051;fill-opacity:1;stroke:none" /><rect
+           y="48.708691"
+           x="48.849281"
+           height="6.2556591"
+           width="6.8167043"
+           id="rect5037"
+           style="fill:#4f5051;fill-opacity:1;stroke:none" /><rect
+           y="101.55563"
+           x="199.60468"
+           height="5.889843"
+           width="6.0749969"
+           id="rect5039"
+           style="fill:#4f5051;fill-opacity:1;stroke:none" /></g><path
+         sodipodi:nodetypes="sssssssss"
+         inkscape:connector-curvature="0"
+         id="path4485"
+         d="M 144.06902,4.0450664 61.198812,32.278932 C 53.834625,34.787909 45.731809,44.10879 50.057881,54.713409 L 84.548982,139.2624 c 2.357198,5.77826 9.755299,11.05606 19.840018,7.47815 l 92.48498,-32.81233 c 4.92096,-1.74588 11.69893,-8.51248 7.47816,-18.466475 L 167.72442,9.0813775 C 164.00007,0.29812656 152.77359,1.0794208 144.06902,4.0450664 z"
+         style="fill:url(#linearGradient7214);fill-opacity:1;stroke:none" /><path
+         sodipodi:type="inkscape:offset"
+         inkscape:radius="-6.7012396"
+         inkscape:original="M 157.75 2.15625 C 153.38977 1.6243729 148.41478 2.5484272 144.0625 4.03125 L 61.1875 32.28125 C 53.823313 34.790227 45.736428 44.114131 50.0625 54.71875 L 84.5625 139.25 C 86.919698 145.02826 94.290281 150.32791 104.375 146.75 L 196.875 113.9375 C 201.79596 112.19162 208.56452 105.42275 204.34375 95.46875 L 167.71875 9.09375 C 165.85657 4.7021245 162.11023 2.6881271 157.75 2.15625 z "
+         style="fill:url(#linearGradient7222);fill-opacity:1;stroke:none"
+         id="path7206"
+         d="m 156.9375,8.8125 c -2.82602,-0.3447281 -7.03762,0.3083377 -10.71875,1.5625 l -82.875,28.25 c -1.992244,0.678757 -4.857585,2.803885 -6.375,5.3125 -1.517415,2.508615 -2.039469,4.935882 -0.6875,8.25 l 34.5,84.53125 c 1.053105,2.5815 4.193953,6.25539 11.34375,3.71875 l 92.5,-32.8125 c 0.80096,-0.28417 2.6915,-1.58104 3.5625,-3.125 0.871,-1.54396 1.39467,-3.11714 0,-6.40625 l -36.625,-86.375 c -0.8886,-2.0956068 -1.82512,-2.5647104 -4.625,-2.90625 z" /><g
+         style="filter:url(#filter4590)"
+         id="g4542"><path
+           inkscape:connector-curvature="0"
+           id="path4473"
+           d="m 135.03125,34.78125 a 6.750675,6.750675 0 0 0 -6.21875,9.375 l 6.4375,15.9375 -23.78125,9.5625 L 105.03125,53.75 A 6.750675,6.750675 0 0 0 98.75,49.4375 6.750675,6.750675 0 0 0 92.53125,58.8125 L 110,102.03125 a 6.7576093,6.7576093 0 1 0 12.53125,-5.0625 l -6.5625,-16.1875 23.78125,-9.5625 6.53125,16.15625 a 6.7576093,6.7576093 0 1 0 12.53125,-5.0625 l -17.5,-43.21875 a 6.750675,6.750675 0 0 0 -6.28125,-4.3125 z"
+           style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#c3c2c4;fill-opacity:1;stroke:none;stroke-width:13.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" /></g><g
+         id="g4750"
+         style="filter:url(#filter4768)"><path
+           sodipodi:type="arc"
+           style="fill:#c3c2c4;fill-opacity:1;stroke:none"
+           id="path4479"
+           sodipodi:cx="102.06332"
+           sodipodi:cy="125.22211"
+           sodipodi:rx="3.25734"
+           sodipodi:ry="3.1216176"
+           d="m 105.32066,125.22211 a 3.25734,3.1216176 0 1 1 -6.514684,0 3.25734,3.1216176 0 1 1 6.514684,0 z"
+           transform="matrix(0.98880313,-0.44393908,0.44393908,0.98880313,-54.312475,46.576269)" /><path
+           transform="matrix(0.98880313,-0.44393908,0.44393908,0.98880313,27.39247,17.938822)"
+           d="m 105.32066,125.22211 a 3.25734,3.1216176 0 1 1 -6.514684,0 3.25734,3.1216176 0 1 1 6.514684,0 z"
+           sodipodi:ry="3.1216176"
+           sodipodi:rx="3.25734"
+           sodipodi:cy="125.22211"
+           sodipodi:cx="102.06332"
+           id="path4481"
+           style="fill:#c3c2c4;fill-opacity:1;stroke:none"
+           sodipodi:type="arc" /></g><path
+         style="fill:#4d4d4d;fill-opacity:1;stroke:none"
+         d="m 155.84375,8.53125 c -2.7841,-0.086304 -6.45076,0.5847419 -9.6875,1.6875 l -82.875,28.25 c -2.037566,0.694198 -4.927624,2.827186 -6.46875,5.375 -1.541126,2.547814 -2.092472,5.038809 -0.71875,8.40625 l 34.5,84.53125 c 0.443193,1.08641 1.273856,2.34335 2.5625,3.28125 -0.970342,-0.86582 -1.626075,-1.89589 -2,-2.8125 l -34.5,-84.53125 C 55.28948,49.368352 55.840427,46.91198 57.375,44.375 c 1.530152,-2.529672 4.421979,-4.657063 6.4375,-5.34375 l 82.875,-28.25 c 2.76829,-0.9431583 5.83842,-1.5525003 8.40625,-1.65625 0.85594,-0.034583 1.66293,-0.024361 2.375,0.0625 1.41789,0.1729592 2.35949,0.444633 2.89232,0.8024892 0.1708,0.1147148 0.5204,0.2465578 0.67018,0.3850108 -0.80331,-1.1222334 -1.88419,-1.4842817 -4.0625,-1.75 -0.3584,-0.043718 -0.72727,-0.081421 -1.125,-0.09375 z"
+         id="path5113"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="sccscccccsccssscss" /><path
+         style="fill:#4d4d4d;fill-opacity:1;stroke:none"
+         d="m 158.375,8.84375 c 0.4119,0.085094 0.77418,0.1866234 1.09375,0.3125 -0.3182,-0.1277152 -0.68149,-0.2278629 -1.09375,-0.3125 z m -8.34375,0.3125 c -0.52306,0.1108753 -1.04032,0.2382306 -1.5625,0.375 0.51786,-0.1361952 1.04381,-0.264064 1.5625,-0.375 z m 10.01745,0.6962932 c 0.32528,0.2630278 0.36217,0.4773388 0.5138,0.8349568 l 36.625,86.375 c 0.70023,1.651396 0.93765,2.884086 0.875,3.875 -0.0626,0.99073 -0.43213,1.74619 -0.875,2.53125 -0.43241,0.76651 -1.09694,1.47237 -1.78125,2.03125 -0.68401,0.55863 -1.39617,0.98837 -1.78125,1.125 l -92.5,32.8125 c -3.582155,1.2709 -6.124046,0.97982 -7.9375,0.0625 -0.396515,-0.20058 -0.950398,-0.67555 -1.276291,-1.09315 -0.325894,-0.4176 -0.30025,-0.45646 -0.799278,-1.15258 0.328593,0.8104 0.876055,1.6176 1.489631,2.26917 0.330647,0.25808 0.621581,0.36703 1.023438,0.57031 1.841002,0.93126 4.429643,1.2153 8.03125,-0.0625 l 92.5,-32.8125 c 0.40826,-0.14485 1.1207,-0.56001 1.8125,-1.125 0.6918,-0.56499 1.37094,-1.27978 1.8125,-2.0625 0.44554,-0.78978 0.81102,-1.58146 0.875,-2.59375 0.064,-1.01229 -0.17077,-2.245431 -0.875,-3.90625 l -36.625,-86.375 c -0.20218,-0.476821 -0.20571,-0.799924 -0.43359,-1.121094 -0.008,-0.0048 -0.1992,-0.1554565 -0.207,-0.160156 -0.12453,-0.07439 -0.59028,-0.1518513 -0.73061,-0.2146941 z"
+         id="path5135"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="ccccccccscssccczccsccsscsscccc" /><path
+         style="fill:#f9f9f9;fill-opacity:1;stroke:none"
+         d="m 160.66086,9.9356565 c 0.29941,0.4813045 0.18296,0.5641445 0.49539,1.3009705 l 36.625,86.375 c 0.70423,1.660819 0.93898,2.893963 0.875,3.906253 -0.064,1.01229 -0.42946,1.80397 -0.875,2.59375 -0.44156,0.78272 -1.1207,1.49751 -1.8125,2.0625 -0.6918,0.56499 -1.40424,0.98015 -1.8125,1.125 l -92.5,32.8125 c -3.601607,1.2778 -6.214641,1.04049 -8.03125,0.0625 -0.901764,-0.48547 -1.55545,-1.09494 -2.128906,-1.77734 1.601388,2.27579 4.81824,4.36105 10.691406,2.27734 l 92.5,-32.8125 c 0.84547,-0.29996 2.76088,-1.63159 3.65625,-3.21875 0.89537,-1.58716 1.41689,-3.2294 0,-6.562503 L 161.59766,11.638971 c -0.44229,-1.040443 -0.41497,-1.174048 -0.9368,-1.7033145 z"
+         id="path5120"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="csscssccscccsssc" /><path
+         style="fill:#323232;fill-opacity:1;stroke:none"
+         d="m 78.322398,125.81023 5.729153,-7.0905 L 60.890826,62.330641 52.859,63.151994 z"
+         id="path4487"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="ccccc" /><path
+         sodipodi:nodetypes="ccccc"
+         inkscape:connector-curvature="0"
+         id="path4519"
+         d="m 79.019887,125.55253 5.440835,-5.59341 -0.48766,-1.41355 -5.651067,7.26442 z"
+         style="fill:#f9f9f9;stroke:none" /><path
+         style="fill:#f9f9f9;fill-opacity:1;stroke:none"
+         d="m 156.34375,9.09375 c -0.39775,-0.00909 -0.82203,0.013958 -1.25,0.03125 -2.56783,0.1037497 -5.63796,0.7130915 -8.40625,1.65625 l -82.875,28.25 c -2.015521,0.686687 -4.907348,2.814078 -6.4375,5.34375 -1.534573,2.53698 -2.08552,4.993352 -0.71875,8.34375 l 34.5,84.53125 c 0.280444,0.68746 1.163727,1.70758 1.329926,1.86437 0.166199,0.15679 0.344629,0.25227 1.076271,0.55429 -0.464587,-0.22276 -0.384832,-0.17168 -0.636666,-0.39913 -0.251834,-0.22745 -0.493954,-1.1277 -0.769531,-1.73823 L 57.65625,53 c -1.312012,-3.216169 -0.796136,-5.39098 0.6875,-7.84375 1.442449,-2.38468 4.316055,-4.466796 6.15625,-5.09375 l 82.875,-28.25 c 2.71949,-0.926532 5.75094,-1.555279 8.25,-1.65625 0.83773,-0.03385 1.48163,-0.112435 2.15419,-0.09388 1.29552,0.03574 2.14895,0.0066 2.38837,0.249611 0.23943,0.24297 0.49431,0.59618 0.49431,0.59618 0,0 -0.29527,-0.741854 -0.48319,-0.9422587 -0.18792,-0.200405 -0.2281,-0.2086143 -0.54154,-0.3339453 -0.31344,-0.1253311 -0.76625,-0.2734176 -2.16839,-0.444455 -0.35604,-0.04343 -0.72725,-0.08466 -1.125,-0.093752 z m -6.3125,0.0625 c -0.52306,0.1108753 -1.04032,0.2382306 -1.5625,0.375 0.51786,-0.1361952 1.04381,-0.264064 1.5625,-0.375 z"
+         id="path5142"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="ssccscczczccsccsszczzssccc" /><path
+         sodipodi:nodetypes="ccccc"
+         inkscape:connector-curvature="0"
+         id="path4521"
+         d="m 59.978424,61.811457 -7.052525,-0.01903 -0.06697,1.359774 7.75195,-0.769753 z"
+         style="fill:#000000;stroke:none" /></g></g><g
+     inkscape:groupmode="layer"
+     id="layer3"
+     inkscape:label="Text"
+     sodipodi:insensitive="true"
+     style="display:inline"><path
+       d="m 39.99308,164.63193 7.5825,0 0,56.12353 -7.5825,0 0,-26.18603 -29.312963,0 0,26.18603 -7.5820371,0 0,-56.12353 7.5820371,0 0,23.21487 29.312963,0 0,-23.21487"
+       style="fill:#323232;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3449"
+       inkscape:connector-curvature="0" /><path
+       d="m 82.48533,197.07093 c -0.234375,-3.59525 -1.172375,-6.5665 -2.96975,-8.834 -1.72025,-2.26613 -4.53425,-3.35988 -8.442375,-3.35988 -2.03275,0 -3.90825,0.54588 -5.6285,1.64113 -1.79775,1.17237 -3.2045,2.65775 -4.221125,4.61225 -1.016125,1.95412 -1.484875,3.90775 -1.484875,5.9405 l 22.746625,0 z m 6.566375,10.86475 c -0.234375,1.48625 -0.9385,3.28365 -2.110875,5.54976 -1.172375,2.26758 -2.892125,4.14405 -5.158625,5.62794 -1.328625,0.86084 -2.736375,1.56347 -4.299375,2.03222 -1.564,0.54736 -3.8305,0.78271 -6.80025,0.78271 -2.8145,0 -5.394125,-0.54785 -7.660625,-1.56396 -2.267125,-1.01611 -4.22125,-2.42236 -5.78475,-4.29883 -1.641625,-1.87598 -2.813875,-4.06494 -3.595625,-6.48734 -0.859375,-2.42375 -1.251,-5.15863 -1.251,-8.12988 0,-4.30025 0.704125,-8.2075 2.189,-11.64737 1.407125,-3.439 3.595125,-6.17538 6.48775,-8.13038 2.97075,-1.95225 6.6445,-2.96975 10.943875,-2.96975 2.892,0 5.471625,0.54738 7.73875,1.6425 2.1885,1.171 3.985875,2.73488 5.471625,4.76713 1.40675,2.03275 2.501,4.53425 3.28325,7.42625 0.703125,2.89262 1.09425,6.254 1.09425,10.00637 l -29.860375,0 c 0,4.29888 1.016125,7.58155 3.048875,9.92628 1.953625,2.34521 4.92425,3.51757 8.833,3.51757 1.563,0 2.96975,-0.23388 4.29825,-0.78125 1.2515,-0.54736 2.34575,-1.17236 3.28325,-2.03271 0.860375,-0.85986 1.642125,-1.71875 2.189,-2.73584 0.46925,-0.93755 0.703625,-1.79642 0.78175,-2.50142 l 6.878875,0"
+       style="fill:#323232;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3451"
+       inkscape:connector-curvature="0" /><path
+       d="m 94.186955,220.75546 6.878415,0 0,-56.12349 -6.878415,0 0,56.12349 z"
+       style="fill:#323232;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3453"
+       inkscape:connector-curvature="0" /><path
+       d="m 135.60559,197.07093 c -0.23375,-3.59525 -1.17125,-6.5665 -2.97,-8.834 -1.72,-2.26613 -4.53375,-3.35988 -8.44176,-3.35988 -2.03275,0 -3.90875,0.54588 -5.6285,1.64113 -1.79787,1.17237 -3.2045,2.65775 -4.22062,4.61225 -1.01663,1.95412 -1.48538,3.90775 -1.48538,5.9405 l 22.74626,0 z m 6.56625,10.86475 c -0.23375,1.48625 -0.9375,3.28365 -2.11,5.54976 -1.1725,2.26758 -2.8925,4.14405 -5.15875,5.62794 -1.33,0.86084 -2.73625,1.56347 -4.3,2.03222 -1.56375,0.54736 -3.83026,0.78271 -6.80038,0.78271 -2.814,0 -5.39363,-0.54785 -7.66025,-1.56396 -2.2675,-1.01611 -4.22113,-2.42236 -5.78513,-4.29883 -1.64112,-1.87598 -2.8135,-4.06494 -3.59512,-6.48734 -0.85988,-2.42375 -1.2505,-5.15863 -1.2505,-8.12988 0,-4.30025 0.70362,-8.2075 2.18837,-11.64737 1.40675,-3.439 3.59575,-6.17538 6.48838,-8.13038 2.96962,-1.95225 6.644,-2.96975 10.94337,-2.96975 2.89151,0 5.47126,0.54738 7.73876,1.6425 2.18875,1.171 3.98625,2.73488 5.47125,4.76713 1.4075,2.03275 2.50125,4.53425 3.28375,7.42625 0.7025,2.89262 1.09375,6.254 1.09375,10.00637 l -29.86001,0 c 0,4.29888 1.01563,7.58155 3.04838,9.92628 1.954,2.34521 4.92475,3.51757 8.833,3.51757 1.56337,0 2.97013,-0.23388 4.29863,-0.78125 1.25,-0.54736 2.345,-1.17236 3.28375,-2.03271 0.86,-0.85986 1.64125,-1.71875 2.18875,-2.73584 0.46875,-0.93755 0.70375,-1.79642 0.78125,-2.50142 l 6.87875,0"
+       style="fill:#323232;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3455"
+       inkscape:connector-curvature="0" /><path
+       d="m 180.52934,220.75546 -6.88,0 -0.0788,-25.16991 c 0,-3.7525 -0.625,-6.48737 -1.9525,-8.12987 -1.25125,-1.72025 -3.51875,-2.57863 -6.80125,-2.57863 -1.5625,0 -3.205,0.38963 -4.84625,1.25 -1.64125,0.78225 -3.04875,2.1885 -4.22125,4.22113 -1.1725,2.03225 -1.71875,4.76762 -1.71875,8.13 l 0,22.27728 -6.87875,0 0,-40.88091 6.48625,0 0,5.78375 0.1575,0 c 1.1725,-1.79887 2.81375,-3.36137 4.76875,-4.84625 1.95375,-1.40762 4.53375,-2.11125 7.58125,-2.11125 2.4225,0 4.7675,0.39113 6.87875,1.251 2.11,0.78125 3.90875,2.2675 5.39375,4.37738 1.40625,2.11137 2.11125,5.003 2.11125,8.59762 l 0,27.82866"
+       style="fill:#323232;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3457"
+       inkscape:connector-curvature="0" /><path
+       d="m 208.41059,179.16955 c 0,-2.42237 -0.3125,-4.29887 -0.9375,-5.70512 -0.625,-1.48625 -1.955,-2.189 -3.90875,-2.189 -1.955,0 -3.205,0.78125 -3.90875,2.26662 -0.70375,1.48488 -1.01625,3.36138 -1.01625,5.6275 l 0,24.07613 c 0,5.55125 1.6425,8.36476 5.0025,8.36476 1.955,0 3.28375,-0.78125 3.90875,-2.42339 0.5475,-1.56387 0.86,-3.5175 0.86,-5.94137 l 0,-24.07613 z m 13.7575,22.90475 c 0,3.439 -0.31375,6.40875 -0.93875,8.83253 -0.625,2.42236 -1.64125,4.45507 -3.12625,6.17382 -1.4075,1.64259 -3.28375,2.89357 -5.70625,3.75245 -2.345,0.85986 -5.23625,1.33008 -8.755,1.33008 -3.43875,0 -6.33125,-0.47022 -8.755,-1.33008 -2.4225,-0.85888 -4.3775,-2.10986 -5.86125,-3.75245 -1.48625,-1.71875 -2.50125,-3.82861 -3.1275,-6.25146 -0.70375,-2.42476 -1.01625,-5.39501 -1.01625,-8.75489 l 0,-23.84225 c 0,-5.62887 1.6425,-9.92775 4.925,-12.97512 3.20375,-3.04888 7.8175,-4.53375 13.835,-4.53375 6.01875,0 10.63125,1.48487 13.83625,4.53375 3.12625,3.04737 4.69,7.34625 4.69,12.97512 l 0,23.84225"
+       style="fill:#323232;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3459"
+       inkscape:connector-curvature="0" /><path
+       d="m 236.4985,201.1358 0,4.14213 c 0,1.95512 0.39,3.44037 1.25,4.61279 0.7825,1.17236 2.18875,1.71972 4.22125,1.71972 1.485,0 2.57875,-0.54736 3.44,-1.71972 0.78125,-1.17242 1.17125,-2.50142 1.17125,-4.14404 0,-2.10988 -0.54625,-3.67238 -1.72,-4.76713 -1.17125,-1.09375 -3.12625,-2.50137 -5.94,-4.22112 -4.92375,-2.814 -8.4425,-5.39413 -10.39625,-7.66025 -2.6575,-3.12738 -3.9875,-7.03513 -3.9875,-11.726 0,-2.73638 0.3925,-5.15925 1.25125,-7.27 0.78125,-2.11038 1.87625,-3.83013 3.36125,-5.23638 1.485,-1.32912 3.28375,-2.42287 5.39375,-3.12737 2.11125,-0.70275 4.53375,-1.01525 7.27,-1.01525 2.81375,0 5.315,0.46875 7.50375,1.32862 2.1875,0.85988 4.06375,2.11138 5.55,3.7515 1.485,1.64113 2.57875,3.67388 3.2825,6.01863 0.70375,2.34512 1.095,5.00237 1.095,7.89637 l -12.66375,0 c -0.0775,-2.73775 -0.39,-4.77 -0.85875,-6.17625 -0.46875,-1.32912 -1.72,-2.11037 -3.675,-2.26662 -2.89125,0 -4.455,1.32775 -4.7675,3.90925 0,1.79587 0.3125,3.126 1.01625,4.14112 0.70375,1.0175 1.71875,2.03225 3.12625,3.04975 1.25,0.78125 2.8925,1.79738 5.0025,3.04738 2.11125,1.17387 3.67375,2.189 4.7675,2.89262 1.095,0.70413 2.11125,1.48538 3.05,2.34513 1.64,1.5635 2.97,3.44 3.82875,5.629 0.86125,2.1885 1.25125,5.00237 1.25125,8.36325 0,3.67387 -0.7025,6.8789 -2.0325,9.53661 -1.32875,2.57861 -3.36,4.61134 -5.94125,5.94093 -2.65625,1.32763 -5.86125,2.03271 -9.69125,2.03271 -2.97,0 -5.6275,-0.39258 -7.89625,-1.17383 -2.26625,-0.70264 -4.14125,-1.79736 -5.6275,-3.20361 -1.485,-1.40772 -2.57875,-2.9712 -3.28375,-4.76905 -0.7025,-1.79736 -1.09375,-3.67339 -1.09375,-5.62739 l 0,-6.2535 12.7425,0"
+       style="fill:#323232;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
+       id="path3461"
+       inkscape:connector-curvature="0" /></g></svg>
Index: contrib/qfs/qfs.sh
===================================================================
--- contrib/qfs/qfs.sh	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ contrib/qfs/qfs.sh	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,80 @@
+#!/usr/bin/bash
+#
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+VERSION=2.1.0
+BASENAME=qemu-${VERSION}
+TARBALL=${BASENAME}.tar.bz2
+SOURCEDIR=${BASENAME}
+URL=http://wiki.qemu-project.org/download/${TARBALL}
+MD5="6726977292b448cbc7f89998fac6983b"
+
+if [ ! -f ${TARBALL} ];
+then
+	wget ${URL}
+fi
+
+if [ `md5sum ${TARBALL} | cut -f 1 -d " "` != ${MD5} ];
+then
+	echo Wrong MD5 checksum
+	exit
+fi
+
+tar xvfj ${TARBALL}
+
+cd ${SOURCEDIR}
+
+patch -p 1 <<EOF
+diff --git a/target-arm/cpu.h b/target-arm/cpu.h
+index 8098b8d..659b104 100644
+--- a/target-arm/cpu.h
++++ b/target-arm/cpu.h
+@@ -1255,7 +1255,14 @@ static inline bool arm_singlestep_active(CPUARMState *env)
+ static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
+                                         target_ulong *cs_base, int *flags)
+ {
+-    int fpen = extract32(env->cp15.c1_coproc, 20, 2);
++    int fpen;
++
++    if (arm_feature(env, ARM_FEATURE_V6)) {
++        fpen = extract32(env->cp15.c1_coproc, 20, 2);
++    } else {
++        /* CPACR doesn't exist before v6, so VFP is always accessible */
++        fpen = 3;
++    }
+ 
+     if (is_a64(env)) {
+         *pc = env->pc;
+EOF
+
+./configure --target-list=i386-softmmu,x86_64-softmmu,arm-softmmu,ppc-softmmu,sparc-softmmu,sparc64-softmmu,mips-softmmu,mipsel-softmmu --audio-drv-list=pa
+
+make -j 4
+
+sudo make install
+
Index: faults/mips64/Makefile.config
===================================================================
--- defaults/mips64/Makefile.config	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,41 +1,0 @@
-# Platform
-PLATFORM = mips64
-
-# Ramdisk format
-RDFMT = ext4fs
-
-# Compiler
-COMPILER = gcc_cross
-
-# Debug build
-CONFIG_DEBUG = y
-
-# Deadlock detection support for spinlocks
-CONFIG_DEBUG_SPINLOCK = y
-
-# Support for SMP
-CONFIG_SMP = y
-
-# Support for userspace debuggers
-CONFIG_UDEBUG = y
-
-# Kernel console support
-CONFIG_KCONSOLE = y
-
-# Kernel symbol information
-CONFIG_SYMTAB = y
-
-# Detailed kernel logging
-CONFIG_LOG = n
-
-# Kernel function tracing
-CONFIG_TRACE = n
-
-# Compile kernel tests
-CONFIG_TEST = y
-
-# Input device class
-CONFIG_HID_IN = generic
-
-# Output device class
-CONFIG_HID_OUT = generic
Index: faults/mips64/msim/Makefile.config
===================================================================
--- defaults/mips64/msim/Makefile.config	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,2 +1,0 @@
-# Machine type
-MACHINE = msim
Index: faults/mips64/output
===================================================================
--- defaults/mips64/output	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-image.boot
Index: defaults/ppc32/Makefile.config
===================================================================
--- defaults/ppc32/Makefile.config	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ defaults/ppc32/Makefile.config	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -41,2 +41,4 @@
 OHCI_POWER_SWITCH = ganged
 
+# Barebone build with essential binaries only
+CONFIG_BAREBONE = y
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -66,12 +66,12 @@
 SIZEOK_MAP = generic/src/debug/sizeok_map.o
 
-.PHONY: all clean
+.PHONY: all clean autogen_clean
 
 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BIN) $(DISASM)
 	-[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
 
-clean:
+clean: autogen_clean
 	rm -f $(DEPEND) $(DEPEND_PREV) $(RAW) $(BIN) $(MAP) $(JOB) $(MAP_PREV) $(DISASM) $(DUMP) $(REAL_MAP).* arch/*/_link.ld arch/*/include/arch/common.h
-	find generic/src/ arch/*/src/ genarch/src/ test/ -name '*.o' -follow -exec rm \{\} \;
+	find generic/src/ arch/*/src/ genarch/src/ test/ -name '*.o' -follow -exec rm '{}' \;
 
 ## Common compiler flags
@@ -367,4 +367,8 @@
 GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
 
+ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG)))
+ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG)))
+ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG)))
+
 LFLAGS_LTO := $(addprefix -Xlinker ,$(LFLAGS))
 
@@ -397,4 +401,9 @@
 $(LINK): $(LINK).in $(DEPEND)
 	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
+
+%.h: %.ag
+	$(AUTOGEN) probe $< >$<.probe.c
+	$(CC) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
+	$(AUTOGEN) generate $< <$<.probe.s >$@   
 
 %.o: %.S $(DEPEND)
@@ -441,5 +450,5 @@
 	$(GENMAP) $(MAP_PREV) $(DUMP) $@
 
-$(DEPEND): $(COMMON_HEADER_ARCH)
+$(DEPEND): $(COMMON_HEADER_ARCH) $(ARCH_AUTOGENS_H)
 	makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > $@ 2> /dev/null
 	-[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
@@ -447,2 +456,5 @@
 $(COMMON_HEADER_ARCH): $(COMMON_HEADER)
 	ln -sfn ../../../../$< $@
+
+autogen_clean:
+	-rm $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)
Index: kernel/arch/abs32le/Makefile.inc
===================================================================
--- kernel/arch/abs32le/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/abs32le/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -50,5 +50,4 @@
 	arch/$(KARCH)/src/userspace.c \
 	arch/$(KARCH)/src/cpu/cpu.c \
-	arch/$(KARCH)/src/ddi/ddi.c \
 	arch/$(KARCH)/src/smp/smp.c \
 	arch/$(KARCH)/src/smp/ipi.c \
Index: rnel/arch/abs32le/src/ddi/ddi.c
===================================================================
--- kernel/arch/abs32le/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Copyright (c) 2010 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 abs32leddi
- * @{
- */
-/** @file
- *  @brief DDI.
- */
-
-#include <ddi/ddi.h>
-#include <proc/task.h>
-#include <typedefs.h>
-
-/** Enable I/O space range for task.
- *
- */
-int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
-{
-	return 0;
-}
-
-/** @}
- */
Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/amd64/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -86,2 +86,7 @@
 		arch/$(KARCH)/src/smp/smp.c
 endif
+
+ARCH_AUTOGENS_AG = \
+	arch/$(KARCH)/include/arch/istate_struct.ag \
+	arch/$(KARCH)/include/arch/context_struct.ag
+
Index: kernel/arch/amd64/include/arch/context.h
===================================================================
--- kernel/arch/amd64/include/arch/context.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/amd64/include/arch/context.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,5 +36,5 @@
 #define KERN_amd64_CONTEXT_H_
 
-#include <typedefs.h>
+#include <arch/context_struct.h>
 
 /*
@@ -52,22 +52,4 @@
 	} while (0)
 
-/* We include only registers that must be preserved
- * during function call
- */
-typedef struct {
-	uintptr_t sp;
-	uintptr_t pc;
-	
-	uint64_t rbx;
-	uint64_t rbp;
-	
-	uint64_t r12;
-	uint64_t r13;
-	uint64_t r14;
-	uint64_t r15;
-	
-	ipl_t ipl;
-} __attribute__ ((packed)) context_t;
-
 #endif
 
Index: rnel/arch/amd64/include/arch/context_offset.h
===================================================================
--- kernel/arch/amd64/include/arch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,79 +1,0 @@
-/*
- * Copyright (c) 2005 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KERN_amd64_CONTEXT_OFFSET_H_
-#define KERN_amd64_CONTEXT_OFFSET_H_
-
-#define OFFSET_SP   0x00
-#define OFFSET_PC   0x08
-#define OFFSET_RBX  0x10
-#define OFFSET_RBP  0x18
-#define OFFSET_R12  0x20
-#define OFFSET_R13  0x28
-#define OFFSET_R14  0x30
-#define OFFSET_R15  0x38
-
-#ifdef KERNEL
-	#define OFFSET_IPL  0x40
-#else
-	#define OFFSET_TLS  0x40
-#endif
-
-#ifdef __ASM__
-
-# ctx: address of the structure with saved context
-# pc: return address
-.macro CONTEXT_SAVE_ARCH_CORE ctx:req pc:req
-	movq \pc, OFFSET_PC(\ctx)
-	movq %rsp, OFFSET_SP(\ctx)
-	
-	movq %rbx, OFFSET_RBX(\ctx)
-	movq %rbp, OFFSET_RBP(\ctx)
-	movq %r12, OFFSET_R12(\ctx)
-	movq %r13, OFFSET_R13(\ctx)
-	movq %r14, OFFSET_R14(\ctx)
-	movq %r15, OFFSET_R15(\ctx)
-.endm
-
-# ctx: address of the structure with saved context
-.macro CONTEXT_RESTORE_ARCH_CORE ctx:req pc:req
-	movq OFFSET_R15(\ctx), %r15
-	movq OFFSET_R14(\ctx), %r14
-	movq OFFSET_R13(\ctx), %r13
-	movq OFFSET_R12(\ctx), %r12
-	movq OFFSET_RBP(\ctx), %rbp
-	movq OFFSET_RBX(\ctx), %rbx
-	
-	movq OFFSET_SP(\ctx), %rsp   # ctx->sp -> %rsp
-	
-	movq OFFSET_PC(\ctx), \pc
-.endm
-
-#endif
-
-#endif
Index: kernel/arch/amd64/include/arch/context_struct.ag
===================================================================
--- kernel/arch/amd64/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/amd64/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,83 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <typedefs.h>
+                }
+        ],
+
+        members : [
+                #
+                # We include only registers that must be preserved
+                # during function call.
+                #
+
+                {
+                        name : sp,
+                        type : uint64_t
+                },
+                {
+                        name : pc,
+                        type : uint64_t
+                },
+
+                {
+                        name : rbx,
+                        type : uint64_t
+                },
+                {
+                        name : rbp,
+                        type : uint64_t
+                },
+
+                {
+                        name : r12,
+                        type : uint64_t
+                },
+                {
+                        name : r13,
+                        type : uint64_t
+                },
+                {
+                        name : r14,
+                        type : uint64_t
+                },
+                {
+                        name : r15,
+                        type : uint64_t
+                },
+
+                {
+                        name : ipl,
+                        type : ipl_t
+                }
+        ]
+}
Index: kernel/arch/amd64/include/arch/istate.h
===================================================================
--- kernel/arch/amd64/include/arch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/amd64/include/arch/istate.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,31 +38,9 @@
 #include <trace.h>
 
-/** This is passed to interrupt handlers */
-typedef struct istate {
-	uint64_t rax;
-	uint64_t rbx;
-	uint64_t rcx;
-	uint64_t rdx;
-	uint64_t rsi;
-	uint64_t rdi;
-	uint64_t rbp;
-	uint64_t r8;
-	uint64_t r9;
-	uint64_t r10;
-	uint64_t r11;
-	uint64_t r12;
-	uint64_t r13;
-	uint64_t r14;
-	uint64_t r15;
-	uint64_t alignment;   /* align rbp_frame on multiple of 16 */
-	uint64_t rbp_frame;   /* imitation of frame pointer linkage */
-	uint64_t rip_frame;   /* imitation of return address linkage */
-	uint64_t error_word;  /* real or fake error word */
-	uint64_t rip;
-	uint64_t cs;
-	uint64_t rflags;
-	uint64_t rsp;         /* only if istate_t is from uspace */
-	uint64_t ss;          /* only if istate_t is from uspace */
-} istate_t;
+#ifdef KERNEL
+#include <arch/istate_struct.h>
+#else
+#include <libarch/istate_struct.h>
+#endif
 
 #define RPL_USER	3
Index: kernel/arch/amd64/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/amd64/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/amd64/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,146 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : istate,
+
+        includes : [
+                {
+                        guard : KERNEL,
+                        include : <typedefs.h>
+                },
+                {
+                        negative-guard: KERNEL,
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : rax,
+                        type : uint64_t
+                },
+                {
+                        name : rbx,
+                        type : uint64_t
+                },
+                {
+                        name : rcx,
+                        type : uint64_t
+                },
+                {
+                        name : rdx,
+                        type : uint64_t
+                },
+                {
+                        name : rsi,
+                        type : uint64_t
+                },
+                {
+                        name : rdi,
+                        type : uint64_t
+                },
+                {
+                        name : rbp,
+                        type : uint64_t
+                },
+                {
+                        name : r8,
+                        type : uint64_t
+                },
+                {
+                        name : r9,
+                        type : uint64_t
+                },
+                {
+                        name : r10,
+                        type : uint64_t
+                },
+                {
+                        name : r11,
+                        type : uint64_t
+                },
+                {
+                        name : r12,
+                        type : uint64_t
+                },
+                {
+                        name : r13,
+                        type : uint64_t
+                },
+                {
+                        name : r14,
+                        type : uint64_t
+                },
+                {
+                        name : r15,
+                        type : uint64_t
+                },
+                {
+                        # align rbp_frame on multiple of 16
+                        name : alignment,
+                        type : uint64_t
+                },
+                {
+                        # imitation of frame pointer linkage
+                        name : rbp_frame,
+                        type : uint64_t
+                },
+                {
+                        # imitation of frame address linkage
+                        name : rip_frame,
+                        type : uint64_t
+                },
+                {
+                        # real or fake error word
+                        name : error_word,
+                        type : uint64_t
+                },
+                {
+                        name : rip,
+                        type : uint64_t
+                },
+                {
+                        name : cs,
+                        type : uint64_t
+                },
+                {
+                        name : rflags,
+                        type : uint64_t
+                },
+                {
+                        # only if istate_t is from uspace
+                        name : rsp,
+                        type : uint64_t
+                },
+                {
+                        # only if istate_t is from uspace
+                        name : ss,
+                        type : uint64_t
+                }
+        ]
+}
Index: kernel/arch/amd64/src/asm.S
===================================================================
--- kernel/arch/amd64/src/asm.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/amd64/src/asm.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -29,4 +29,5 @@
 #include <arch/pm.h>
 #include <arch/mm/page.h>
+#include <arch/istate_struct.h>
 
 .text
@@ -142,34 +143,9 @@
 	ret
 
-#define ISTATE_OFFSET_RAX		0
-#define ISTATE_OFFSET_RBX		8
-#define ISTATE_OFFSET_RCX		16
-#define ISTATE_OFFSET_RDX		24
-#define ISTATE_OFFSET_RSI		32
-#define ISTATE_OFFSET_RDI		40
-#define ISTATE_OFFSET_RBP		48
-#define ISTATE_OFFSET_R8		56
-#define ISTATE_OFFSET_R9		64
-#define ISTATE_OFFSET_R10		72
-#define ISTATE_OFFSET_R11		80
-#define ISTATE_OFFSET_R12		88	
-#define ISTATE_OFFSET_R13 		96
-#define ISTATE_OFFSET_R14		104
-#define ISTATE_OFFSET_R15		112
-#define ISTATE_OFFSET_ALIGNMENT		120
-#define ISTATE_OFFSET_RBP_FRAME		128
-#define ISTATE_OFFSET_RIP_FRAME		136
-#define ISTATE_OFFSET_ERROR_WORD	144
-#define ISTATE_OFFSET_RIP		152
-#define ISTATE_OFFSET_CS		160
-#define ISTATE_OFFSET_RFLAGS		168
-#define ISTATE_OFFSET_RSP		176
-#define ISTATE_OFFSET_SS		184
-
 /*
  * Size of the istate structure without the hardware-saved part and without the
  * error word.
  */
-#define ISTATE_SOFT_SIZE	144
+#define ISTATE_SOFT_SIZE	ISTATE_SIZE - (6 * 8)
 
 /**
Index: kernel/arch/amd64/src/context.S
===================================================================
--- kernel/arch/amd64/src/context.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/amd64/src/context.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -32,5 +32,5 @@
 .global context_restore_arch
 
-#include <arch/context_offset.h>
+#include <arch/context_struct.h>
 
 ## Save current CPU context
@@ -43,5 +43,13 @@
 	
 	# 1st argument passed in %edi
-	CONTEXT_SAVE_ARCH_CORE %rdi %rdx
+	movq %rdx, CONTEXT_OFFSET_PC(%rdi)
+	movq %rsp, CONTEXT_OFFSET_SP(%rdi)
+	
+	movq %rbx, CONTEXT_OFFSET_RBX(%rdi)
+	movq %rbp, CONTEXT_OFFSET_RBP(%rdi)
+	movq %r12, CONTEXT_OFFSET_R12(%rdi)
+	movq %r13, CONTEXT_OFFSET_R13(%rdi)
+	movq %r14, CONTEXT_OFFSET_R14(%rdi)
+	movq %r15, CONTEXT_OFFSET_R15(%rdi)
 	
 	xorl %eax, %eax       # context_save returns 1
@@ -56,5 +64,14 @@
 #
 context_restore_arch:
-	CONTEXT_RESTORE_ARCH_CORE %rdi %rdx
+	movq CONTEXT_OFFSET_R15(%rdi), %r15
+	movq CONTEXT_OFFSET_R14(%rdi), %r14
+	movq CONTEXT_OFFSET_R13(%rdi), %r13
+	movq CONTEXT_OFFSET_R12(%rdi), %r12
+	movq CONTEXT_OFFSET_RBP(%rdi), %rbp
+	movq CONTEXT_OFFSET_RBX(%rdi), %rbx
+	
+	movq CONTEXT_OFFSET_SP(%rdi), %rsp   # ctx->sp -> %rsp
+	
+	movq CONTEXT_OFFSET_PC(%rdi), %rdx 
 	
 	movq %rdx, (%rsp)
@@ -62,2 +79,3 @@
 	xorl %eax, %eax       # context_restore returns 0
 	ret
+
Index: kernel/arch/amd64/src/ddi/ddi.c
===================================================================
--- kernel/arch/amd64/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/amd64/src/ddi/ddi.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -45,67 +45,4 @@
 #include <arch.h>
 #include <align.h>
-
-/** Enable I/O space range for task.
- *
- * Interrupts are disabled and task is locked.
- *
- * @param task   Task.
- * @param ioaddr Startign I/O space address.
- * @param size   Size of the enabled I/O range.
- *
- * @return 0 on success or an error code from errno.h.
- *
- */
-int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
-{
-	size_t elements = ioaddr + size;
-	if (elements > IO_PORTS)
-		return ENOENT;
-	
-	if (task->arch.iomap.elements < elements) {
-		/*
-		 * The I/O permission bitmap is too small and needs to be grown.
-		 */
-		
-		void *store = malloc(bitmap_size(elements), FRAME_ATOMIC);
-		if (!store)
-			return ENOMEM;
-		
-		bitmap_t oldiomap;
-		bitmap_initialize(&oldiomap, task->arch.iomap.elements,
-		    task->arch.iomap.bits);
-		
-		bitmap_initialize(&task->arch.iomap, elements, store);
-		
-		/*
-		 * Mark the new range inaccessible.
-		 */
-		bitmap_set_range(&task->arch.iomap, oldiomap.elements,
-		    elements - oldiomap.elements);
-		
-		/*
-		 * In case there really existed smaller iomap,
-		 * copy its contents and deallocate it.
-		 */
-		if (oldiomap.bits) {
-			bitmap_copy(&task->arch.iomap, &oldiomap,
-			    oldiomap.elements);
-			
-			free(oldiomap.bits);
-		}
-	}
-	
-	/*
-	 * Enable the range and we are done.
-	 */
-	bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);
-	
-	/*
-	 * Increment I/O Permission bitmap generation counter.
-	 */
-	task->arch.iomapver++;
-	
-	return 0;
-}
 
 /** Install I/O Permission bitmap.
Index: kernel/arch/arm32/Makefile.inc
===================================================================
--- kernel/arch/arm32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/arm32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -54,5 +54,4 @@
 	arch/$(KARCH)/src/dummy.S \
 	arch/$(KARCH)/src/cpu/cpu.c \
-	arch/$(KARCH)/src/ddi/ddi.c \
 	arch/$(KARCH)/src/interrupt.c \
 	arch/$(KARCH)/src/exception.c \
@@ -96,2 +95,7 @@
 	ARCH_SOURCES += genarch/src/drivers/pl050/pl050.c
 endif
+
+ARCH_AUTOGENS_AG = \
+	arch/$(KARCH)/include/arch/istate_struct.ag \
+	arch/$(KARCH)/include/arch/context_struct.ag
+
Index: kernel/arch/arm32/include/arch/context.h
===================================================================
--- kernel/arch/arm32/include/arch/context.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/arm32/include/arch/context.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,4 +39,5 @@
 #include <align.h>
 #include <arch/stack.h>
+#include <arch/context_struct.h>
 
 /* Put one item onto the stack to support get_stack_base() and align it up. */
@@ -52,27 +53,4 @@
 #ifndef __ASM__
 
-#include <typedefs.h>
-
-/** Thread context containing registers that must be preserved across function
- * calls.
- */
-typedef struct {
-	uint32_t cpu_mode;
-	uintptr_t sp;
-	uintptr_t pc;
-	
-	uint32_t r4;
-	uint32_t r5;
-	uint32_t r6;
-	uint32_t r7;
-	uint32_t r8;
-	uint32_t r9;
-	uint32_t r10;
-	uint32_t fp;	/* r11 */
-	
-	ipl_t ipl;
-} context_t;
-
-
 #endif /* __ASM__ */
 
Index: kernel/arch/arm32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/arm32/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/arm32/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,95 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <typedefs.h>
+                },
+        ],
+
+        #
+        # Thread context containing registers that must be preserved across
+        # function calls.
+        #
+        members : [
+                {
+                        name : cpu_mode,
+                        type : uint32_t
+                },
+                {
+                        name : sp,
+                        type : uintptr_t
+                },
+                {
+                        name : pc,
+                        type : uintptr_t
+                },
+
+                {
+                        name : r4,
+                        type : uint32_t
+                },
+                {
+                        name : r5,
+                        type : uint32_t
+                },
+                {
+                        name : r6,
+                        type : uint32_t
+                },
+                {
+                        name : r7,
+                        type : uint32_t
+                },
+                {
+                        name : r8,
+                        type : uint32_t
+                },
+                {
+                        name : r9,
+                        type : uint32_t
+                },
+                {
+                        name : r10,
+                        type : uint32_t
+                },
+                {
+                        # r11
+                        name : fp,
+                        type : uint32_t
+                },
+
+                {
+                        name : ipl,
+                        type : ipl_t
+                }
+        ]
+}
+
Index: kernel/arch/arm32/include/arch/istate.h
===================================================================
--- kernel/arch/arm32/include/arch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/arm32/include/arch/istate.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,35 +39,13 @@
 #ifdef KERNEL
 
+#include <arch/istate_struct.h>
 #include <arch/regutils.h>
 
 #else /* KERNEL */
 
+#include <libarch/istate_struct.h>
 #include <libarch/regutils.h>
 
 #endif /* KERNEL */
-
-/** Struct representing CPU state saved when an exception occurs. */
-typedef struct istate {
-	uint32_t dummy;
-	uint32_t spsr;
-	uint32_t sp;
-	uint32_t lr;
-	
-	uint32_t r0;
-	uint32_t r1;
-	uint32_t r2;
-	uint32_t r3;
-	uint32_t r4;
-	uint32_t r5;
-	uint32_t r6;
-	uint32_t r7;
-	uint32_t r8;
-	uint32_t r9;
-	uint32_t r10;
-	uint32_t fp;
-	uint32_t r12;
-	
-	uint32_t pc;
-} istate_t;
 
 /** Set Program Counter member of given istate structure.
Index: kernel/arch/arm32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/arm32/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/arm32/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,119 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : istate,
+
+        includes : [
+                {
+                        guard : KERNEL,
+                        include : <typedefs.h>
+                },
+                {
+                        negative-guard : KERNEL,
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : dummy,
+                        type : uint32_t
+                },
+                {
+                        name : spsr,
+                        type : uint32_t
+                },
+                {
+                        name : sp,
+                        type : uint32_t
+                },
+                {
+                        name : lr,
+                        type : uint32_t
+                },
+
+                {
+                        name : r0,
+                        type : uint32_t
+                },
+                {
+                        name : r1,
+                        type : uint32_t
+                },
+                {
+                        name : r2,
+                        type : uint32_t
+                },
+                {
+                        name : r3,
+                        type : uint32_t
+                },
+                {
+                        name : r4,
+                        type : uint32_t
+                },
+                {
+                        name : r5,
+                        type : uint32_t
+                },
+                {
+                        name : r6,
+                        type : uint32_t
+                },
+                {
+                        name : r7,
+                        type : uint32_t
+                },
+                {
+                        name : r8,
+                        type : uint32_t
+                },
+                {
+                        name : r9,
+                        type : uint32_t
+                },
+                {
+                        name : r10,
+                        type : uint32_t
+                },
+                {
+                        name : fp,
+                        type : uint32_t
+                },
+                {
+                        name : r12,
+                        type : uint32_t
+                },
+
+                {
+                        name : pc,
+                        type : uint32_t
+                }
+        ]
+}
+
Index: rnel/arch/arm32/src/ddi/ddi.c
===================================================================
--- kernel/arch/arm32/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup arm32ddi
- * @{
- */
-/** @file
- *  @brief DDI.
- */
-
-#include <ddi/ddi.h>
-#include <proc/task.h>
-#include <typedefs.h>
-
-/** Enable I/O space range for task.
- *
- * Interrupts are disabled and task is locked.
- *
- * @param task Task.
- * @param ioaddr Startign I/O space address.
- * @param size Size of the enabled I/O range.
- *
- * @return 0 on success or an error code from errno.h.
- */
-int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
-{
-	return 0;
-}
-
-/** @}
- */
Index: kernel/arch/ia32/Makefile.inc
===================================================================
--- kernel/arch/ia32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -105,2 +105,7 @@
 	arch/$(KARCH)/src/fpu_context.c \
 	arch/$(KARCH)/src/syscall.c
+
+ARCH_AUTOGENS_AG = \
+	arch/$(KARCH)/include/arch/istate_struct.ag \
+	arch/$(KARCH)/include/arch/context_struct.ag
+
Index: kernel/arch/ia32/include/arch/context.h
===================================================================
--- kernel/arch/ia32/include/arch/context.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia32/include/arch/context.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,4 +37,5 @@
 
 #include <typedefs.h>
+#include <arch/context_struct.h>
 
 #define STACK_ITEM_SIZE  4
@@ -55,18 +56,4 @@
 	} while (0)
 
-/*
- * Only save registers that must be preserved across
- * function calls.
- */
-typedef struct {
-	uintptr_t sp;
-	uintptr_t pc;
-	uint32_t ebx;
-	uint32_t esi;
-	uint32_t edi;
-	uint32_t ebp;
-	ipl_t ipl;
-} __attribute__ ((packed)) context_t;
-
 #endif
 
Index: rnel/arch/ia32/include/arch/context_offset.h
===================================================================
--- kernel/arch/ia32/include/arch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/*
- * Copyright (c) 2008 Josef Cejka
- * 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 ia32
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_ia32_CONTEXT_OFFSET_H_
-#define KERN_ia32_CONTEXT_OFFSET_H_
-
-#define OFFSET_SP   0x00
-#define OFFSET_PC   0x04
-#define OFFSET_EBX  0x08
-#define OFFSET_ESI  0x0C
-#define OFFSET_EDI  0x10
-#define OFFSET_EBP  0x14
-
-#ifdef KERNEL
-	#define OFFSET_IPL  0x18
-#else
-	#define OFFSET_TLS  0x18
-#endif
-
-#ifdef __ASM__
-
-# ctx: address of the structure with saved context
-# pc: return address
-
-.macro CONTEXT_SAVE_ARCH_CORE ctx:req pc:req
-	movl %esp,OFFSET_SP(\ctx)	# %esp -> ctx->sp
-	movl \pc,OFFSET_PC(\ctx)	# %eip -> ctx->pc
-	movl %ebx,OFFSET_EBX(\ctx)	# %ebx -> ctx->ebx
-	movl %esi,OFFSET_ESI(\ctx)	# %esi -> ctx->esi
-	movl %edi,OFFSET_EDI(\ctx)	# %edi -> ctx->edi
-	movl %ebp,OFFSET_EBP(\ctx)	# %ebp -> ctx->ebp
-.endm
-
-# ctx: address of the structure with saved context
-
-.macro CONTEXT_RESTORE_ARCH_CORE ctx:req pc:req
-	movl OFFSET_SP(\ctx),%esp	# ctx->sp -> %esp
-	movl OFFSET_PC(\ctx),\pc	# ctx->pc -> \pc
-	movl OFFSET_EBX(\ctx),%ebx	# ctx->ebx -> %ebx
-	movl OFFSET_ESI(\ctx),%esi	# ctx->esi -> %esi
-	movl OFFSET_EDI(\ctx),%edi	# ctx->edi -> %edi
-	movl OFFSET_EBP(\ctx),%ebp	# ctx->ebp -> %ebp
-.endm
-
-#endif /* __ASM__ */
-
-#endif
-
-/** @}
- */
Index: kernel/arch/ia32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/ia32/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/ia32/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,72 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <typedefs.h>
+                }
+        ],
+
+        members : [
+                #
+                # Only save registers that must be preserved across function
+                # calls.
+                #
+
+                {
+                        name : sp,
+                        type : uint32_t
+                },
+                {
+                        name : pc,
+                        type : uint32_t
+                },
+                {
+                        name : ebx,
+                        type : uint32_t
+                },
+                {
+                        name : esi,
+                        type : uint32_t
+                },
+                {
+                        name : edi,
+                        type : uint32_t
+                },
+                {
+                        name : ebp,
+                        type : uint32_t
+                },
+                {
+                        name : ipl,
+                        type : ipl_t
+                }
+        ]
+}
Index: kernel/arch/ia32/include/arch/istate.h
===================================================================
--- kernel/arch/ia32/include/arch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia32/include/arch/istate.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,33 +38,9 @@
 #include <trace.h>
 
-typedef struct istate {
-	/*
-	 * The strange order of the GPRs is given by the requirement to use the
-	 * istate structure for both regular interrupts and exceptions as well
-	 * as for syscall handlers which use this order as an optimization.
-	 */
-	uint32_t edx;
-	uint32_t ecx;
-	uint32_t ebx;
-	uint32_t esi;
-	uint32_t edi;
-	uint32_t ebp;
-	uint32_t eax;
-	
-	uint32_t ebp_frame;  /* imitation of frame pointer linkage */
-	uint32_t eip_frame;  /* imitation of return address linkage */
-	
-	uint32_t gs;
-	uint32_t fs;
-	uint32_t es;
-	uint32_t ds;
-	
-	uint32_t error_word;  /* real or fake error word */
-	uint32_t eip;
-	uint32_t cs;
-	uint32_t eflags;
-	uint32_t esp;         /* only if istate_t is from uspace */
-	uint32_t ss;          /* only if istate_t is from uspace */
-} istate_t;
+#ifdef KERNEL
+#include <arch/istate_struct.h>
+#else
+#include <libarch/istate_struct.h>
+#endif /* KERNEL */
 
 #define RPL_USER	3
Index: kernel/arch/ia32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/ia32/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/ia32/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,135 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : istate,
+
+        includes : [
+                {
+                        guard : KERNEL,
+                        include : <typedefs.h>
+                },
+                {
+                        negative-guard: KERNEL,
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+
+                #
+                # The strange order of the GPRs is given by the requirement to use the
+                # istate structure for both regular interrupts and exceptions as well
+                # as for syscall handlers which use this order as an optimization.
+                #
+
+                {
+                        name : edx,
+                        type : uint32_t
+                },
+                {
+                        name : ecx,
+                        type : uint32_t
+                },
+                {
+                        name : ebx,
+                        type : uint32_t
+                },
+                {
+                        name : esi,
+                        type : uint32_t
+                },
+                {
+                        name : edi,
+                        type : uint32_t
+                },
+                {
+                        name : ebp,
+                        type : uint32_t
+                },
+                {
+                        name : eax,
+                        type : uint32_t
+                },
+
+                {
+                        # imitation of frame pointer linkage
+                        name : ebp_frame,
+                        type : uint32_t
+                },
+                {
+                        # imitation of return address linkage
+                        name : eip_frame,
+                        type : uint32_t
+                },
+
+                {
+                        name : gs,
+                        type : uint32_t
+                },
+                {
+                        name : fs,
+                        type : uint32_t
+                },
+                {
+                        name : es,
+                        type : uint32_t
+                },
+                {
+                        name : ds,
+                        type : uint32_t
+                },
+
+                {
+                        # real or fake error word
+                        name : error_word,
+                        type : uint32_t
+                },
+                {
+                        name : eip,
+                        type : uint32_t
+                },
+                {
+                        name : cs,
+                        type : uint32_t
+                },
+                {
+                        name : eflags,
+                        type : uint32_t
+                },
+                {
+                        # only if istate_t is from uspace
+                        name : esp,
+                        type : uint32_t
+                },
+                {
+                        # only if istate_t is from uspace
+                        name : ss,
+                        type : uint32_t
+                }
+        ]
+}
Index: kernel/arch/ia32/src/asm.S
===================================================================
--- kernel/arch/ia32/src/asm.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia32/src/asm.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -34,4 +34,5 @@
 #include <arch/cpu.h>
 #include <arch/mm/page.h>
+#include <arch/istate_struct.h>
 
 .text
@@ -136,29 +137,9 @@
 	ret
 
-#define ISTATE_OFFSET_EDX         0
-#define ISTATE_OFFSET_ECX         4
-#define ISTATE_OFFSET_EBX         8
-#define ISTATE_OFFSET_ESI         12
-#define ISTATE_OFFSET_EDI         16 
-#define ISTATE_OFFSET_EBP         20
-#define ISTATE_OFFSET_EAX         24
-#define ISTATE_OFFSET_EBP_FRAME   28
-#define ISTATE_OFFSET_EIP_FRAME   32
-#define ISTATE_OFFSET_GS          36
-#define ISTATE_OFFSET_FS          40
-#define ISTATE_OFFSET_ES          44
-#define ISTATE_OFFSET_DS          48
-#define ISTATE_OFFSET_ERROR_WORD  52
-#define ISTATE_OFFSET_EIP         56
-#define ISTATE_OFFSET_CS          60
-#define ISTATE_OFFSET_EFLAGS      64
-#define ISTATE_OFFSET_ESP         68
-#define ISTATE_OFFSET_SS          72
-
 /*
  * Size of the istate structure without the hardware-saved part
  * and without the error word.
  */
-#define ISTATE_SOFT_SIZE  52
+#define ISTATE_SOFT_SIZE	ISTATE_SIZE - (6 * 4) 
 
 /*
Index: kernel/arch/ia32/src/context.S
===================================================================
--- kernel/arch/ia32/src/context.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia32/src/context.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -27,5 +27,5 @@
 #
 
-#include <arch/context_offset.h>
+#include <arch/context_struct.h>
 
 .text
@@ -41,11 +41,16 @@
 #
 context_save_arch:
-	movl 0(%esp),%eax	# save pc value into eax	
-	movl 4(%esp),%edx	# address of the context variable to save context to 
+	movl 0(%esp), %eax	# save pc value into eax	
+	movl 4(%esp), %edx	# address of the context variable to save context to 
 
-		# save registers to given structure
-	CONTEXT_SAVE_ARCH_CORE %edx %eax
+	# save registers to given structure
+	movl %esp, CONTEXT_OFFSET_SP(%edx)	# %esp -> ctx->sp
+	movl %eax, CONTEXT_OFFSET_PC(%edx)	# %eip -> ctx->pc
+	movl %ebx, CONTEXT_OFFSET_EBX(%edx)	# %ebx -> ctx->ebx
+	movl %esi, CONTEXT_OFFSET_ESI(%edx)	# %esi -> ctx->esi
+	movl %edi, CONTEXT_OFFSET_EDI(%edx)	# %edi -> ctx->edi
+	movl %ebp, CONTEXT_OFFSET_EBP(%edx)	# %ebp -> ctx->ebp
 
-	xorl %eax,%eax		# context_save returns 1
+	xorl %eax, %eax		# context_save returns 1
 	incl %eax
 	ret
@@ -58,10 +63,16 @@
 #
 context_restore_arch:
-	movl 4(%esp),%eax	# address of the context variable to restore context from
+	movl 4(%esp), %eax	# address of the context variable to restore context from
 
-		# restore registers from given structure
-	CONTEXT_RESTORE_ARCH_CORE %eax %edx
+	# restore registers from given structure
+	movl CONTEXT_OFFSET_SP(%eax), %esp	# ctx->sp -> %esp
+	movl CONTEXT_OFFSET_PC(%eax), %edx	# ctx->pc -> \pc
+	movl CONTEXT_OFFSET_EBX(%eax), %ebx	# ctx->ebx -> %ebx
+	movl CONTEXT_OFFSET_ESI(%eax), %esi	# ctx->esi -> %esi
+	movl CONTEXT_OFFSET_EDI(%eax), %edi	# ctx->edi -> %edi
+	movl CONTEXT_OFFSET_EBP(%eax), %ebp	# ctx->ebp -> %ebp
 
-	movl %edx,0(%esp)	# put saved pc on stack
-	xorl %eax,%eax		# context_restore returns 0
+	movl %edx, 0(%esp)	# put saved pc on stack
+	xorl %eax, %eax		# context_restore returns 0
 	ret
+
Index: kernel/arch/ia32/src/ddi/ddi.c
===================================================================
--- kernel/arch/ia32/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia32/src/ddi/ddi.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -45,67 +45,4 @@
 #include <arch.h>
 #include <align.h>
-
-/** Enable I/O space range for task.
- *
- * Interrupts are disabled and task is locked.
- *
- * @param task   Task.
- * @param ioaddr Startign I/O space address.
- * @param size   Size of the enabled I/O range.
- *
- * @return 0 on success or an error code from errno.h.
- *
- */
-int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
-{
-	size_t elements = ioaddr + size;
-	if (elements > IO_PORTS)
-		return ENOENT;
-	
-	if (task->arch.iomap.elements < elements) {
-		/*
-		 * The I/O permission bitmap is too small and needs to be grown.
-		 */
-		
-		void *store = malloc(bitmap_size(elements), FRAME_ATOMIC);
-		if (!store)
-			return ENOMEM;
-		
-		bitmap_t oldiomap;
-		bitmap_initialize(&oldiomap, task->arch.iomap.elements,
-		    task->arch.iomap.bits);
-		
-		bitmap_initialize(&task->arch.iomap, elements, store);
-		
-		/*
-		 * Mark the new range inaccessible.
-		 */
-		bitmap_set_range(&task->arch.iomap, oldiomap.elements,
-		    elements - oldiomap.elements);
-		
-		/*
-		 * In case there really existed smaller iomap,
-		 * copy its contents and deallocate it.
-		 */
-		if (oldiomap.bits) {
-			bitmap_copy(&task->arch.iomap, &oldiomap,
-			    oldiomap.elements);
-			
-			free(oldiomap.bits);
-		}
-	}
-	
-	/*
-	 * Enable the range and we are done.
-	 */
-	bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);
-	
-	/*
-	 * Increment I/O Permission bitmap generation counter.
-	 */
-	task->arch.iomapver++;
-	
-	return 0;
-}
 
 /** Install I/O Permission bitmap.
Index: kernel/arch/ia64/Makefile.inc
===================================================================
--- kernel/arch/ia64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia64/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -72,2 +72,6 @@
 	BFD = binary
 endif
+
+ARCH_AUTOGENS_AG = \
+	arch/$(KARCH)/include/arch/istate_struct.ag
+
Index: kernel/arch/ia64/include/arch/istate.h
===================================================================
--- kernel/arch/ia64/include/arch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia64/include/arch/istate.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,73 +40,13 @@
 #ifdef KERNEL
 
+#include <arch/istate_struct.h>
 #include <arch/register.h>
 
 #else /* KERNEL */
 
+#include <libarch/istate_struct.h>
 #include <libarch/register.h>
 
 #endif /* KERNEL */
-
-typedef struct istate {
-	uint128_t f2;
-	uint128_t f3;
-	uint128_t f4;
-	uint128_t f5;
-	uint128_t f6;
-	uint128_t f7;
-	uint128_t f8;
-	uint128_t f9;
-	uint128_t f10;
-	uint128_t f11;
-	uint128_t f12;
-	uint128_t f13;
-	uint128_t f14;
-	uint128_t f15;
-	uint128_t f16;
-	uint128_t f17;
-	uint128_t f18;
-	uint128_t f19;
-	uint128_t f20;
-	uint128_t f21;
-	uint128_t f22;
-	uint128_t f23;
-	uint128_t f24;
-	uint128_t f25;
-	uint128_t f26;
-	uint128_t f27;
-	uint128_t f28;
-	uint128_t f29;
-	uint128_t f30;
-	uint128_t f31;
-	
-	uintptr_t ar_bsp;
-	uintptr_t ar_bspstore;
-	uintptr_t ar_bspstore_new;
-	uint64_t ar_rnat;
-	uint64_t ar_ifs;
-	uint64_t ar_pfs;
-	uint64_t ar_rsc;
-	uintptr_t cr_ifa;
-	cr_isr_t cr_isr;
-	uintptr_t cr_iipa;
-	psr_t cr_ipsr;
-	uintptr_t cr_iip;
-	uint64_t pr;
-	uintptr_t sp;
-	
-	/*
-	 * The following variables are defined only for break_instruction
-	 * handler.
-	 */
-	uint64_t in0;
-	uint64_t in1;
-	uint64_t in2;
-	uint64_t in3;
-	uint64_t in4;
-	uint64_t in5;
-	uint64_t in6;
-
-	uint64_t alignment;
-} istate_t;
 
 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
Index: kernel/arch/ia64/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/ia64/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/ia64/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,263 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : istate,
+
+        includes : [
+                {
+                        guard : KERNEL,
+                        include : <typedefs.h>
+                },
+                {
+                        guard : KERNEL,
+                        include : <arch/register.h>
+                },
+                {
+                        negative-guard : KERNEL,
+                        include : <sys/types.h>
+                },
+                {
+                        negative-guard : KERNEL,
+                        include : <libarch/register.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : f2,
+                        type : uint128_t
+                },
+                {
+                        name : f3,
+                        type : uint128_t
+                },
+                {
+                        name : f4,
+                        type : uint128_t
+                },
+                {
+                        name : f5,
+                        type : uint128_t
+                },
+                {
+                        name : f6,
+                        type : uint128_t
+                },
+                {
+                        name : f7,
+                        type : uint128_t
+                },
+                {
+                        name : f8,
+                        type : uint128_t
+                },
+                {
+                        name : f9,
+                        type : uint128_t
+                },
+                {
+                        name : f10,
+                        type : uint128_t
+                },
+                {
+                        name : f11,
+                        type : uint128_t
+                },
+                {
+                        name : f12,
+                        type : uint128_t
+                },
+                {
+                        name : f13,
+                        type : uint128_t
+                },
+                {
+                        name : f14,
+                        type : uint128_t
+                },
+                {
+                        name : f15,
+                        type : uint128_t
+                },
+                {
+                        name : f16,
+                        type : uint128_t
+                },
+                {
+                        name : f17,
+                        type : uint128_t
+                },
+                {
+                        name : f18,
+                        type : uint128_t
+                },
+                {
+                        name : f19,
+                        type : uint128_t
+                },
+                {
+                        name : f20,
+                        type : uint128_t
+                },
+                {
+                        name : f21,
+                        type : uint128_t
+                },
+                {
+                        name : f22,
+                        type : uint128_t
+                },
+                {
+                        name : f23,
+                        type : uint128_t
+                },
+                {
+                        name : f24,
+                        type : uint128_t
+                },
+                {
+                        name : f25,
+                        type : uint128_t
+                },
+                {
+                        name : f26,
+                        type : uint128_t
+                },
+                {
+                        name : f27,
+                        type : uint128_t
+                },
+                {
+                        name : f28,
+                        type : uint128_t
+                },
+                {
+                        name : f29,
+                        type : uint128_t
+                },
+                {
+                        name : f30,
+                        type : uint128_t
+                },
+                {
+                        name : f31,
+                        type : uint128_t
+                },
+
+                {
+                        name : ar_bsp,
+                        type : uintptr_t
+                },
+                {
+                        name : ar_bspstore,
+                        type : uintptr_t
+                },
+                {
+                        name : ar_bspstore_new,
+                        type : uintptr_t
+                },
+                {
+                        name : ar_rnat,
+                        type : uint64_t
+                },
+                {
+                        name : ar_ifs,
+                        type : uint64_t
+                },
+                {
+                        name : ar_pfs,
+                        type : uint64_t
+                },
+                {
+                        name : ar_rsc,
+                        type : uint64_t
+                },
+                {
+                        name : cr_ifa,
+                        type : uintptr_t
+                },
+                {
+                        name : cr_isr,
+                        type : cr_isr_t
+                },
+                {
+                        name : cr_iipa,
+                        type : uintptr_t
+                },
+                {
+                        name : cr_ipsr,
+                        type : psr_t
+                },
+                {
+                        name : cr_iip,
+                        type : uintptr_t
+                },
+                {
+                        name : pr,
+                        type : uint64_t
+                },
+                {
+                        name : sp,
+                        type : uintptr_t
+                },
+
+                #
+                # The following variables are defined only for break_instruction
+                # handler.
+                #
+                {
+                        name : in0,
+                        type : uint64_t
+                },
+                {
+                        name : in1,
+                        type : uint64_t
+                },
+                {
+                        name : in2,
+                        type : uint64_t
+                },
+                {
+                        name : in3,
+                        type : uint64_t
+                },
+                {
+                        name : in4,
+                        type : uint64_t
+                },
+                {
+                        name : in5,
+                        type : uint64_t
+                },
+                {
+                        name : in6,
+                        type : uint64_t
+                }
+        ]
+}
+
Index: kernel/arch/ia64/src/ddi/ddi.c
===================================================================
--- kernel/arch/ia64/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia64/src/ddi/ddi.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -47,9 +47,9 @@
  * Interrupts are disabled and task is locked.
  *
- * @param task		Task.
- * @param ioaddr	Starting I/O space address.
- * @param size		Size of the enabled I/O range.
+ * @param task	 Task.
+ * @param ioaddr Starting I/O space address.
+ * @param size	 Size of the enabled I/O range.
  *
- * @return 0 on success or an error code from errno.h.
+ * @return EOK on success or an error code from errno.h.
  */
 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
@@ -72,5 +72,27 @@
 	bitmap_set_range(task->arch.iomap, iopage, size / 4);
 	
-	return 0;
+	return EOK;
+}
+
+/** Disable I/O space range for task.
+ *
+ * Interrupts are disabled and task is locked.
+ *
+ * @param task	 Task.
+ * @param ioaddr Starting I/O space address.
+ * @param size	 Size of the disabled I/O range.
+ *
+ * @return EOK on success or an error code from errno.h.
+ */
+int ddi_iospace_disable_arch(task_t *task, uintptr_t ioaddr, size_t size)
+{
+	if (!task->arch.iomap)
+		return EINVAL;
+
+	uintptr_t iopage = ioaddr / PORTS_PER_PAGE;
+	size = ALIGN_UP(size + ioaddr - 4 * iopage, PORTS_PER_PAGE);
+	bitmap_clear_range(task->arch.iomap, iopage, size / 4);
+	
+	return EOK;
 }
 
Index: kernel/arch/ia64/src/ivt.S
===================================================================
--- kernel/arch/ia64/src/ivt.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ia64/src/ivt.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -31,15 +31,10 @@
 #include <arch/register.h>
 #include <arch/mm/page.h>
+#include <arch/istate_struct.h>
 #include <align.h>
 
-#define FRS_TO_SAVE 30
-#define STACK_ITEMS		(21 + FRS_TO_SAVE * 2)
-#define STACK_FRAME_SIZE	ALIGN_UP((STACK_ITEMS * STACK_ITEM_SIZE) + STACK_SCRATCH_AREA_SIZE, STACK_ALIGNMENT)
-
-#if (STACK_ITEMS % 2 == 0)
-#	define STACK_FRAME_BIAS	8
-#else
-#	define STACK_FRAME_BIAS 16
-#endif
+#define STACK_FRAME_SIZE	ALIGN_UP(ISTATE_SIZE + STACK_SCRATCH_AREA_SIZE, STACK_ALIGNMENT)
+
+#define FLOAT_ITEM_SIZE		(STACK_ITEM_SIZE * 2)
 
 /** Partitioning of bank 0 registers. */
@@ -120,9 +115,9 @@
 	mov r27 = ~PSR_DFH_MASK ;;
 	and r26 = r25, r26
-	and r24 = r24, r27;;
-	or r24 = r24, r26;;
-	mov psr.l = r24;;
+	and r24 = r24, r27 ;;
+	or r24 = r24, r26 ;;
+	mov psr.l = r24 ;;
 	srlz.i
-	srlz.d;;
+	srlz.d ;;
 
 	mov r24 = cr.iip
@@ -161,6 +156,6 @@
 (p4)	mov r12 = R_KSTACK ;;
 	
-	add r31 = -STACK_FRAME_BIAS, r12 ;;
-	add r12 = -STACK_FRAME_SIZE, r12
+	add r12 = -STACK_FRAME_SIZE, r12 ;;
+	add r31 = STACK_SCRATCH_AREA_SIZE + ISTATE_OFFSET_IN6, r12
 
     /* 4. save registers in bank 0 into memory stack */
@@ -179,22 +174,22 @@
 	 */
 
-(p6)	st8 [r31] = r38, -8 ;;		/* save in6 */
-(p6)	st8 [r31] = r37, -8 ;;		/* save in5 */
-(p6)	st8 [r31] = r36, -8 ;;		/* save in4 */	
-(p6)	st8 [r31] = r35, -8 ;;		/* save in3 */
-(p6) 	st8 [r31] = r34, -8 ;;		/* save in2 */
-(p6)	st8 [r31] = r33, -8 ;;		/* save in1 */
-(p6)	st8 [r31] = r32, -8 ;;		/* save in0 */
-(p5)	add r31 = -56, r31 ;;
+(p6)	st8 [r31] = r38, -STACK_ITEM_SIZE ;;	/* save in6 */
+(p6)	st8 [r31] = r37, -STACK_ITEM_SIZE ;;	/* save in5 */
+(p6)	st8 [r31] = r36, -STACK_ITEM_SIZE ;;	/* save in4 */	
+(p6)	st8 [r31] = r35, -STACK_ITEM_SIZE ;;	/* save in3 */
+(p6) 	st8 [r31] = r34, -STACK_ITEM_SIZE ;;	/* save in2 */
+(p6)	st8 [r31] = r33, -STACK_ITEM_SIZE ;;	/* save in1 */
+(p6)	st8 [r31] = r32, -STACK_ITEM_SIZE ;;	/* save in0 */
+(p5)	add r31 = -(7 * STACK_ITEM_SIZE), r31 ;;
     
-	st8 [r31] = r30, -8 ;;		/* save old stack pointer */ 
-	
-	st8 [r31] = r29, -8 ;;		/* save predicate registers */
-
-	st8 [r31] = r24, -8 ;;		/* save cr.iip */
-	st8 [r31] = r25, -8 ;;		/* save cr.ipsr */
-	st8 [r31] = r26, -8 ;;		/* save cr.iipa */
-	st8 [r31] = r27, -8 ;;		/* save cr.isr */
-	st8 [r31] = r28, -8 ;;		/* save cr.ifa */
+	st8 [r31] = r30, -STACK_ITEM_SIZE ;;	/* save old stack pointer */ 
+	
+	st8 [r31] = r29, -STACK_ITEM_SIZE ;;	/* save predicate registers */
+
+	st8 [r31] = r24, -STACK_ITEM_SIZE ;;	/* save cr.iip */
+	st8 [r31] = r25, -STACK_ITEM_SIZE ;;	/* save cr.ipsr */
+	st8 [r31] = r26, -STACK_ITEM_SIZE ;;	/* save cr.iipa */
+	st8 [r31] = r27, -STACK_ITEM_SIZE ;;	/* save cr.isr */
+	st8 [r31] = r28, -STACK_ITEM_SIZE ;;	/* save cr.ifa */
 
     /* 5. RSE switch from interrupted context */
@@ -204,7 +199,7 @@
 	mov r26 = cr.ifs
 	
-	st8 [r31] = r24, -8 ;;		/* save ar.rsc */
-	st8 [r31] = r25, -8 ;;		/* save ar.pfs */
-	st8 [r31] = r26, -8		/* save ar.ifs */
+	st8 [r31] = r24, -STACK_ITEM_SIZE ;;	/* save ar.rsc */
+	st8 [r31] = r25, -STACK_ITEM_SIZE ;;	/* save ar.pfs */
+	st8 [r31] = r26, -STACK_ITEM_SIZE	/* save ar.ifs */
 	
 	and r24 = ~(RSC_PL_MASK), r24 ;;
@@ -231,8 +226,8 @@
 	mov r29 = ar.bsp
 	
-	st8 [r31] = r27, -8 ;;		/* save ar.rnat */
-	st8 [r31] = r30, -8 ;;		/* save new value written to ar.bspstore */
-	st8 [r31] = r28, -8 ;;		/* save ar.bspstore */
-	st8 [r31] = r29, -8 		/* save ar.bsp */
+	st8 [r31] = r27, -STACK_ITEM_SIZE ;;	/* save ar.rnat */
+	st8 [r31] = r30, -STACK_ITEM_SIZE ;;	/* save new value written to ar.bspstore */
+	st8 [r31] = r28, -STACK_ITEM_SIZE ;;	/* save ar.bspstore */
+	st8 [r31] = r29, -STACK_ITEM_SIZE 	/* save ar.bsp */
 	
 	mov ar.rsc = r24		/* restore RSE's setting + kernel privileges */
@@ -246,9 +241,9 @@
 	cover				/* allocate zero size frame (step 1 (from Intel Docs)) */
 
-	add r31 = (STACK_SCRATCH_AREA_SIZE + (FRS_TO_SAVE * 2 * 8)), r12 ;;
-
-	ld8 r30 = [r31], +8 ;;		/* load ar.bsp */
-	ld8 r29 = [r31], +8 ;;   	/* load ar.bspstore */
-	ld8 r28 = [r31], +8 ;;   	/* load ar.bspstore_new */
+	add r31 = STACK_SCRATCH_AREA_SIZE + ISTATE_OFFSET_AR_BSP, r12 ;;
+
+	ld8 r30 = [r31], +STACK_ITEM_SIZE ;;	/* load ar.bsp */
+	ld8 r29 = [r31], +STACK_ITEM_SIZE ;;	/* load ar.bspstore */
+	ld8 r28 = [r31], +STACK_ITEM_SIZE ;;	/* load ar.bspstore_new */
 	sub r27 = r30 , r28 ;;		/* calculate loadrs (step 2) */
 	shl r27 = r27, 16
@@ -261,8 +256,8 @@
 	loadrs 				/* (step 3) */
 
-	ld8 r27 = [r31], +8 ;;		/* load ar.rnat */
-	ld8 r26 = [r31], +8 ;;		/* load cr.ifs */
-	ld8 r25 = [r31], +8 ;;		/* load ar.pfs */
-	ld8 r24 = [r31], +8 ;;		/* load ar.rsc */
+	ld8 r27 = [r31], +STACK_ITEM_SIZE ;;	/* load ar.rnat */
+	ld8 r26 = [r31], +STACK_ITEM_SIZE ;;	/* load cr.ifs */
+	ld8 r25 = [r31], +STACK_ITEM_SIZE ;;	/* load ar.pfs */
+	ld8 r24 = [r31], +STACK_ITEM_SIZE ;;	/* load ar.rsc */
 
 	mov ar.bspstore = r29 ;;	/* (step 4) */
@@ -275,9 +270,9 @@
 
     /* 17. restore interruption state from memory stack */
-	ld8 r28 = [r31], +8 ;;		/* load cr.ifa */		
-	ld8 r27 = [r31], +8 ;;		/* load cr.isr */
-	ld8 r26 = [r31], +8 ;;		/* load cr.iipa */
-	ld8 r25 = [r31], +8 ;;		/* load cr.ipsr */
-	ld8 r24 = [r31], +8 ;;		/* load cr.iip */
+	ld8 r28 = [r31], +STACK_ITEM_SIZE ;;	/* load cr.ifa */		
+	ld8 r27 = [r31], +STACK_ITEM_SIZE ;;	/* load cr.isr */
+	ld8 r26 = [r31], +STACK_ITEM_SIZE ;;	/* load cr.iipa */
+	ld8 r25 = [r31], +STACK_ITEM_SIZE ;;	/* load cr.ipsr */
+	ld8 r24 = [r31], +STACK_ITEM_SIZE ;;	/* load cr.iip */
 
 	mov cr.iip = r24;;
@@ -292,13 +287,13 @@
 	and r25 = r25, r27
 	and r24 = r24, r26 ;;
-	or r25 = r25, r24;;
+	or r25 = r25, r24 ;;
 	mov cr.ipsr = r25
 
     /* 18. restore predicate registers from memory stack */
-	ld8 r29 = [r31], +8 ;;		/* load predicate registers */
+	ld8 r29 = [r31], +STACK_ITEM_SIZE ;;	/* load predicate registers */
 	mov pr = r29
 	
     /* 19. return from interruption */
-    	ld8 r12 = [r31]			/* load stack pointer */ 
+    	ld8 r12 = [r31]				/* load stack pointer */ 
 	rfi ;;
 
@@ -373,46 +368,46 @@
 	mov loc46 = r31
 
-	add r24 = 96 + STACK_SCRATCH_AREA_SIZE, r12
-	add r25 = 112 + STACK_SCRATCH_AREA_SIZE, r12
-	add r26 = 0 + STACK_SCRATCH_AREA_SIZE, r12
-	add r27 = 16 + STACK_SCRATCH_AREA_SIZE, r12
-	add r28 = 32 + STACK_SCRATCH_AREA_SIZE, r12
-	add r29 = 48 + STACK_SCRATCH_AREA_SIZE, r12
-	add r30 = 64 + STACK_SCRATCH_AREA_SIZE, r12
-	add r31 = 80 + STACK_SCRATCH_AREA_SIZE, r12 ;;
-	
-	stf.spill [r26] = f2, 0x80
-	stf.spill [r27] = f3, 0x80
-	stf.spill [r28] = f4, 0x80
-	stf.spill [r29] = f5, 0x80
-	stf.spill [r30] = f6, 0x80
-	stf.spill [r31] = f7, 0x80 ;;
-
-	stf.spill [r24] = f8, 0x80
-	stf.spill [r25] = f9, 0x80
-	stf.spill [r26] = f10, 0x80
-	stf.spill [r27] = f11, 0x80
-	stf.spill [r28] = f12, 0x80
-	stf.spill [r29] = f13, 0x80
-	stf.spill [r30] = f14, 0x80
-	stf.spill [r31] = f15, 0x80 ;;
-
-	stf.spill [r24] = f16, 0x80
-	stf.spill [r25] = f17, 0x80
-	stf.spill [r26] = f18, 0x80
-	stf.spill [r27] = f19, 0x80
-	stf.spill [r28] = f20, 0x80
-	stf.spill [r29] = f21, 0x80
-	stf.spill [r30] = f22, 0x80
-	stf.spill [r31] = f23, 0x80 ;;
-
-	stf.spill [r24] = f24, 0x80
-	stf.spill [r25] = f25, 0x80
-	stf.spill [r26] = f26, 0x80
-	stf.spill [r27] = f27, 0x80
-	stf.spill [r28] = f28, 0x80
-	stf.spill [r29] = f29, 0x80
-	stf.spill [r30] = f30, 0x80
-	stf.spill [r31] = f31, 0x80 ;;
+	add r24 = ISTATE_OFFSET_F8 + STACK_SCRATCH_AREA_SIZE, r12
+	add r25 = ISTATE_OFFSET_F9 + STACK_SCRATCH_AREA_SIZE, r12
+	add r26 = ISTATE_OFFSET_F2 + STACK_SCRATCH_AREA_SIZE, r12
+	add r27 = ISTATE_OFFSET_F3 + STACK_SCRATCH_AREA_SIZE, r12
+	add r28 = ISTATE_OFFSET_F4 + STACK_SCRATCH_AREA_SIZE, r12
+	add r29 = ISTATE_OFFSET_F5 + STACK_SCRATCH_AREA_SIZE, r12
+	add r30 = ISTATE_OFFSET_F6 + STACK_SCRATCH_AREA_SIZE, r12
+	add r31 = ISTATE_OFFSET_F7 + STACK_SCRATCH_AREA_SIZE, r12 ;;
+	
+	stf.spill [r26] = f2, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r27] = f3, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r28] = f4, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r29] = f5, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r30] = f6, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r31] = f7, 8 * FLOAT_ITEM_SIZE ;;
+
+	stf.spill [r24] = f8, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r25] = f9, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r26] = f10, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r27] = f11, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r28] = f12, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r29] = f13, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r30] = f14, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r31] = f15, 8 * FLOAT_ITEM_SIZE ;;
+
+	stf.spill [r24] = f16, 8 * FLOAT_ITEM_SIZE 
+	stf.spill [r25] = f17, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r26] = f18, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r27] = f19, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r28] = f20, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r29] = f21, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r30] = f22, 8 * FLOAT_ITEM_SIZE
+	stf.spill [r31] = f23, 8 * FLOAT_ITEM_SIZE ;;
+
+	stf.spill [r24] = f24
+	stf.spill [r25] = f25
+	stf.spill [r26] = f26
+	stf.spill [r27] = f27
+	stf.spill [r28] = f28
+	stf.spill [r29] = f29
+	stf.spill [r30] = f30
+	stf.spill [r31] = f31 ;;
 
 	mov loc47 = ar.fpsr	/* preserve floating point status register */
@@ -442,46 +437,46 @@
 
     /* 13. restore general and floating-point registers */
-	add r24 = 96 + STACK_SCRATCH_AREA_SIZE, r12
-	add r25 = 112 + STACK_SCRATCH_AREA_SIZE, r12
-	add r26 = 0 + STACK_SCRATCH_AREA_SIZE, r12
-	add r27 = 16 + STACK_SCRATCH_AREA_SIZE, r12
-	add r28 = 32 + STACK_SCRATCH_AREA_SIZE, r12
-	add r29 = 48 + STACK_SCRATCH_AREA_SIZE, r12
-	add r30 = 64 + STACK_SCRATCH_AREA_SIZE, r12
-	add r31 = 80 + STACK_SCRATCH_AREA_SIZE, r12 ;;
-
-	ldf.fill f2 = [r26], 0x80
-	ldf.fill f3 = [r27], 0x80
-	ldf.fill f4 = [r28], 0x80
-	ldf.fill f5 = [r29], 0x80
-	ldf.fill f6 = [r30], 0x80
-	ldf.fill f7 = [r31], 0x80 ;;
-
-	ldf.fill f8 = [r24], 0x80
-	ldf.fill f9 = [r25], 0x80
-	ldf.fill f10 = [r26], 0x80
-	ldf.fill f11 = [r27], 0x80
-	ldf.fill f12 = [r28], 0x80
-	ldf.fill f13 = [r29], 0x80
-	ldf.fill f14 = [r30], 0x80
-	ldf.fill f15 = [r31], 0x80 ;;
-
-	ldf.fill f16 = [r24], 0x80
-	ldf.fill f17 = [r25], 0x80
-	ldf.fill f18 = [r26], 0x80
-	ldf.fill f19 = [r27], 0x80
-	ldf.fill f20 = [r28], 0x80
-	ldf.fill f21 = [r29], 0x80
-	ldf.fill f22 = [r30], 0x80
-	ldf.fill f23 = [r31], 0x80 ;;
-
-	ldf.fill f24 = [r24], 0x80
-	ldf.fill f25 = [r25], 0x80
-	ldf.fill f26 = [r26], 0x80
-	ldf.fill f27 = [r27], 0x80
-	ldf.fill f28 = [r28], 0x80
-	ldf.fill f29 = [r29], 0x80
-	ldf.fill f30 = [r30], 0x80
-	ldf.fill f31 = [r31], 0x80 ;;
+	add r24 = ISTATE_OFFSET_F8 + STACK_SCRATCH_AREA_SIZE, r12
+	add r25 = ISTATE_OFFSET_F9 + STACK_SCRATCH_AREA_SIZE, r12
+	add r26 = ISTATE_OFFSET_F2 + STACK_SCRATCH_AREA_SIZE, r12
+	add r27 = ISTATE_OFFSET_F3 + STACK_SCRATCH_AREA_SIZE, r12
+	add r28 = ISTATE_OFFSET_F4 + STACK_SCRATCH_AREA_SIZE, r12
+	add r29 = ISTATE_OFFSET_F5 + STACK_SCRATCH_AREA_SIZE, r12
+	add r30 = ISTATE_OFFSET_F6 + STACK_SCRATCH_AREA_SIZE, r12
+	add r31 = ISTATE_OFFSET_F7 + STACK_SCRATCH_AREA_SIZE, r12 ;;
+
+	ldf.fill f2 = [r26], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f3 = [r27], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f4 = [r28], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f5 = [r29], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f6 = [r30], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f7 = [r31], 8 * FLOAT_ITEM_SIZE ;;
+
+	ldf.fill f8 = [r24], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f9 = [r25], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f10 = [r26],8 * FLOAT_ITEM_SIZE
+	ldf.fill f11 = [r27], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f12 = [r28], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f13 = [r29], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f14 = [r30], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f15 = [r31], 8 * FLOAT_ITEM_SIZE ;;
+
+	ldf.fill f16 = [r24], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f17 = [r25], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f18 = [r26], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f19 = [r27], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f20 = [r28], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f21 = [r29], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f22 = [r30], 8 * FLOAT_ITEM_SIZE
+	ldf.fill f23 = [r31], 8 * FLOAT_ITEM_SIZE ;;
+
+	ldf.fill f24 = [r24]
+	ldf.fill f25 = [r25]
+	ldf.fill f26 = [r26]
+	ldf.fill f27 = [r27]
+	ldf.fill f28 = [r28]
+	ldf.fill f29 = [r29]
+	ldf.fill f30 = [r30]
+	ldf.fill f31 = [r31] ;;
 	
 	mov r1 = loc17
Index: kernel/arch/mips32/Makefile.inc
===================================================================
--- kernel/arch/mips32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/mips32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -70,5 +70,4 @@
 	arch/$(KARCH)/src/mm/as.c \
 	arch/$(KARCH)/src/fpu_context.c \
-	arch/$(KARCH)/src/ddi/ddi.c \
 	arch/$(KARCH)/src/smp/smp.c \
 	arch/$(KARCH)/src/machine_func.c
@@ -86,2 +85,6 @@
 endif
 
+ARCH_AUTOGENS_AG = \
+	arch/$(KARCH)/include/arch/istate_struct.ag \
+	arch/$(KARCH)/include/arch/context_struct.ag
+
Index: kernel/arch/mips32/include/arch/context.h
===================================================================
--- kernel/arch/mips32/include/arch/context.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/mips32/include/arch/context.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,4 +38,6 @@
 #include <align.h>
 #include <arch/stack.h>
+#include <arch/context_struct.h>
+#include <typedefs.h>
 
 /*
@@ -44,34 +46,6 @@
 #define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
 
-#ifndef __ASM__
-
-#include <typedefs.h>
-
 #define context_set(ctx, pc, stack, size) \
     context_set_generic(ctx, pc, stack, size)
-
-/*
- * Only save registers that must be preserved across
- * function calls.
- */
-typedef struct {
-	uintptr_t sp;
-	uintptr_t pc;
-	
-	uint32_t s0;
-	uint32_t s1;
-	uint32_t s2;
-	uint32_t s3;
-	uint32_t s4;
-	uint32_t s5;
-	uint32_t s6;
-	uint32_t s7;
-	uint32_t s8;
-	uint32_t gp;
-
-	ipl_t ipl;
-} context_t;
-
-#endif /* __ASM__ */
 
 #endif
Index: rnel/arch/mips32/include/arch/context_offset.h
===================================================================
--- kernel/arch/mips32/include/arch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,188 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KERN_mips32_CONTEXT_OFFSET_H_
-#define KERN_mips32_CONTEXT_OFFSET_H_
-
-#define OFFSET_SP      0x0
-#define OFFSET_PC      0x4
-#define OFFSET_S0      0x8
-#define OFFSET_S1      0xc
-#define OFFSET_S2      0x10
-#define OFFSET_S3      0x14
-#define OFFSET_S4      0x18
-#define OFFSET_S5      0x1c
-#define OFFSET_S6      0x20
-#define OFFSET_S7      0x24
-#define OFFSET_S8      0x28
-#define OFFSET_GP      0x2c
-
-#ifdef KERNEL
-# define OFFSET_IPL     0x30
-#else
-# define OFFSET_TLS     0x30
-
-# define OFFSET_F20     0x34
-# define OFFSET_F21     0x38
-# define OFFSET_F22     0x3c
-# define OFFSET_F23     0x40
-# define OFFSET_F24     0x44
-# define OFFSET_F25     0x48
-# define OFFSET_F26     0x4c
-# define OFFSET_F27     0x50
-# define OFFSET_F28     0x54
-# define OFFSET_F29     0x58
-# define OFFSET_F30     0x5c
-#endif /* KERNEL */
-
-#ifdef __ASM__
-
-#ifdef KERNEL
-
-#include <arch/asm/regname.h>
-
-#else /* KERNEL */
-
-#include <libarch/regname.h>
-
-#endif /* KERNEL */
-
-/* ctx: address of the structure with saved context */
-.macro CONTEXT_SAVE_ARCH_CORE ctx:req
-	sw $s0, OFFSET_S0(\ctx)
-	sw $s1, OFFSET_S1(\ctx)
-	sw $s2, OFFSET_S2(\ctx)
-	sw $s3, OFFSET_S3(\ctx)
-	sw $s4, OFFSET_S4(\ctx)
-	sw $s5, OFFSET_S5(\ctx)
-	sw $s6, OFFSET_S6(\ctx)
-	sw $s7, OFFSET_S7(\ctx)
-	sw $s8, OFFSET_S8(\ctx)
-	sw $gp, OFFSET_GP(\ctx)
-	
-#ifndef KERNEL
-	sw $k1, OFFSET_TLS(\ctx)
-	
-#ifdef CONFIG_FPU
-	mfc1 $t0, $20
-	sw $t0, OFFSET_F20(\ctx)
-	
-	mfc1 $t0, $21
-	sw $t0, OFFSET_F21(\ctx)
-	
-	mfc1 $t0, $22
-	sw $t0, OFFSET_F22(\ctx)
-	
-	mfc1 $t0, $23
-	sw $t0, OFFSET_F23(\ctx)
-	
-	mfc1 $t0, $24
-	sw $t0, OFFSET_F24(\ctx)
-	
-	mfc1 $t0, $25
-	sw $t0, OFFSET_F25(\ctx)
-	
-	mfc1 $t0, $26
-	sw $t0, OFFSET_F26(\ctx)
-	
-	mfc1 $t0, $27
-	sw $t0, OFFSET_F27(\ctx)
-	
-	mfc1 $t0, $28
-	sw $t0, OFFSET_F28(\ctx)
-	
-	mfc1 $t0, $29
-	sw $t0, OFFSET_F29(\ctx)
-	
-	mfc1 $t0, $30
-	sw $t0, OFFSET_F30(\ctx)
-#endif /* CONFIG_FPU */
-#endif /* KERNEL */
-	
-	sw $ra, OFFSET_PC(\ctx)
-	sw $sp, OFFSET_SP(\ctx)
-.endm
-
-/* ctx: address of the structure with saved context */
-.macro CONTEXT_RESTORE_ARCH_CORE ctx:req
-	lw $s0, OFFSET_S0(\ctx)
-	lw $s1, OFFSET_S1(\ctx)
-	lw $s2, OFFSET_S2(\ctx)
-	lw $s3, OFFSET_S3(\ctx)
-	lw $s4, OFFSET_S4(\ctx)
-	lw $s5, OFFSET_S5(\ctx)
-	lw $s6, OFFSET_S6(\ctx)
-	lw $s7, OFFSET_S7(\ctx)
-	lw $s8, OFFSET_S8(\ctx)
-	lw $gp, OFFSET_GP(\ctx)
-#ifndef KERNEL
-	lw $k1, OFFSET_TLS(\ctx)
-	
-#ifdef CONFIG_FPU
-	lw $t0, OFFSET_F20(\ctx)
-	mtc1 $t0, $20
-	
-	lw $t0, OFFSET_F21(\ctx)
-	mtc1 $t0, $21
-	
-	lw $t0, OFFSET_F22(\ctx)
-	mtc1 $t0, $22
-	
-	lw $t0, OFFSET_F23(\ctx)
-	mtc1 $t0, $23
-	
-	lw $t0, OFFSET_F24(\ctx)
-	mtc1 $t0, $24
-	
-	lw $t0, OFFSET_F25(\ctx)
-	mtc1 $t0, $25
-	
-	lw $t0, OFFSET_F26(\ctx)
-	mtc1 $t0, $26
-	
-	lw $t0, OFFSET_F27(\ctx)
-	mtc1 $t0, $27
-	
-	lw $t0, OFFSET_F28(\ctx)
-	mtc1 $t0, $28
-	
-	lw $t0, OFFSET_F29(\ctx)
-	mtc1 $t0, $29
-	
-	lw $t0, OFFSET_F30(\ctx)
-	mtc1 $t0, $30
-#endif /* CONFIG_FPU */
-#endif /* KERNEL */
-	
-	lw $ra, OFFSET_PC(\ctx)
-	lw $sp, OFFSET_SP(\ctx)
-.endm
-
-#endif /* __ASM__ */
-
-#endif
Index: kernel/arch/mips32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/mips32/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/mips32/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,97 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <typedefs.h>
+                }
+        ],
+
+        members : [
+                #
+                # Only save registers that must be preserved across function
+                # calls.
+                #
+                {
+                        name : sp,
+                        type : uint32_t
+                },
+                {
+                        name : pc,
+                        type : uint32_t
+                },
+
+                {
+                        name : s0,
+                        type : uint32_t
+                },
+                {
+                        name : s1,
+                        type : uint32_t
+                },
+                {
+                        name : s2,
+                        type : uint32_t
+                },
+                {
+                        name : s3,
+                        type : uint32_t
+                },
+                {
+                        name : s4,
+                        type : uint32_t
+                },
+                {
+                        name : s5,
+                        type : uint32_t
+                },
+                {
+                        name : s6,
+                        type : uint32_t
+                },
+                {
+                        name : s7,
+                        type : uint32_t
+                },
+                {
+                        name : s8,
+                        type : uint32_t
+                },
+                {
+                        name : gp,
+                        type : uint32_t
+                },
+
+                {
+                        name : ipl,
+                        type : ipl_t
+                }
+        ]
+}
Index: kernel/arch/mips32/include/arch/istate.h
===================================================================
--- kernel/arch/mips32/include/arch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/mips32/include/arch/istate.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -41,56 +41,12 @@
 
 #include <arch/cp0.h>
+#include <arch/istate_struct.h>
 
 #else /* KERNEL */
 
 #include <libarch/cp0.h>
+#include <libarch/istate_struct.h>
 
 #endif /* KERNEL */
-
-typedef struct istate {
-	/*
-	 * The first seven registers are arranged so that the istate structure
-	 * can be used both for exception handlers and for the syscall handler.
-	 */
-	uint32_t a0;	/* arg1 */
-	uint32_t a1;	/* arg2 */
-	uint32_t a2;	/* arg3 */
-	uint32_t a3;	/* arg4 */
-	uint32_t t0;	/* arg5 */
-	uint32_t t1;	/* arg6 */
-	uint32_t v0;	/* arg7 */
-	uint32_t v1;
-	uint32_t at;
-	uint32_t t2;
-	uint32_t t3;
-	uint32_t t4;
-	uint32_t t5;
-	uint32_t t6;
-	uint32_t t7;
-	uint32_t s0;
-	uint32_t s1;
-	uint32_t s2;
-	uint32_t s3;
-	uint32_t s4;
-	uint32_t s5;
-	uint32_t s6;
-	uint32_t s7;
-	uint32_t t8;
-	uint32_t t9;
-	uint32_t kt0;
-	uint32_t kt1;	/* We use it as thread-local pointer */
-	uint32_t gp;
-	uint32_t sp;
-	uint32_t s8;
-	uint32_t ra;
-	
-	uint32_t lo;
-	uint32_t hi;
-	
-	uint32_t status;	/* cp0_status */
-	uint32_t epc;		/* cp0_epc */
-
-	uint32_t alignment;	/* to make sizeof(istate_t) a multiple of 8 */
-} istate_t;
 
 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
Index: kernel/arch/mips32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/mips32/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/mips32/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,207 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : istate,
+
+        includes : [
+                {
+                        guard : KERNEL,
+                        include : <typedefs.h>
+                },
+                {
+                        negative-guard : KERNEL,
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                #
+                # The first seven registers are arranged so that the istate structure
+                # can be used both for exception handlers and for the syscall handler.
+                #
+                {
+                        # arg1
+                        name : a0,
+                        type : uint32_t
+                },
+                {
+                        # arg2
+                        name : a1,
+                        type : uint32_t
+                },
+                {
+                        # arg3
+                        name : a2,
+                        type : uint32_t
+                },
+                {
+                        # arg4
+                        name : a3,
+                        type : uint32_t
+                },
+                {
+                        # arg5
+                        name : t0,
+                        type : uint32_t
+                },
+                {
+                        # arg6
+                        name : t1,
+                        type : uint32_t
+                },
+                {
+                        # arg7
+                        name : v0,
+                        type : uint32_t
+                },
+                {
+                        name : v1,
+                        type : uint32_t
+                },
+                {
+                        name : at,
+                        type : uint32_t
+                },
+                {
+                        name : t2,
+                        type : uint32_t
+                },
+                {
+                        name : t3,
+                        type : uint32_t
+                },
+                {
+                        name : t4,
+                        type : uint32_t
+                },
+                {
+                        name : t5,
+                        type : uint32_t
+                },
+                {
+                        name : t6,
+                        type : uint32_t
+                },
+                {
+                        name : t7,
+                        type : uint32_t
+                },
+                {
+                        name : s0,
+                        type : uint32_t
+                },
+                {
+                        name : s1,
+                        type : uint32_t
+                },
+                {
+                        name : s2,
+                        type : uint32_t
+                },
+                {
+                        name : s3,
+                        type : uint32_t
+                },
+                {
+                        name : s4,
+                        type : uint32_t
+                },
+                {
+                        name : s5,
+                        type : uint32_t
+                },
+                {
+                        name : s6,
+                        type : uint32_t
+                },
+                {
+                        name : s7,
+                        type : uint32_t
+                },
+                {
+                        name : t8,
+                        type : uint32_t
+                },
+                {
+                        name : t9,
+                        type : uint32_t
+                },
+                {
+                        name : kt0,
+                        type : uint32_t
+                },
+                {
+                        # We use it as thread-local pointer
+                        name : kt1,
+                        type : uint32_t
+                },
+                {
+                        name : gp,
+                        type : uint32_t
+                },
+                {
+                        name : sp,
+                        type : uint32_t
+                },
+                {
+                        name : s8,
+                        type : uint32_t
+                },
+                {
+                        name : ra,
+                        type : uint32_t
+                },
+
+                {
+                        name : lo,
+                        type : uint32_t
+                },
+                {
+                        name : hi,
+                        type : uint32_t
+                },
+
+                {
+                        # cp0_status
+                        name : status,
+                        type : uint32_t
+                },
+                {
+                        # cp0_epc
+                        name : epc,
+                        type : uint32_t
+                },
+
+                {
+                        # to make sizeof(istate_t) a multiple of 8 */
+                        name : alignment,
+                        type : uint32_t
+                }
+
+        ]
+}
Index: kernel/arch/mips32/src/context.S
===================================================================
--- kernel/arch/mips32/src/context.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/mips32/src/context.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -27,5 +27,5 @@
 #
 
-#include <arch/context_offset.h>
+#include <arch/context_struct.h>
 
 .text
@@ -39,5 +39,17 @@
 
 context_save_arch:
-	CONTEXT_SAVE_ARCH_CORE $a0
+	sw $s0, CONTEXT_OFFSET_S0($a0)
+	sw $s1, CONTEXT_OFFSET_S1($a0)
+	sw $s2, CONTEXT_OFFSET_S2($a0)
+	sw $s3, CONTEXT_OFFSET_S3($a0)
+	sw $s4, CONTEXT_OFFSET_S4($a0)
+	sw $s5, CONTEXT_OFFSET_S5($a0)
+	sw $s6, CONTEXT_OFFSET_S6($a0)
+	sw $s7, CONTEXT_OFFSET_S7($a0)
+	sw $s8, CONTEXT_OFFSET_S8($a0)
+	sw $gp, CONTEXT_OFFSET_GP($a0)
+	
+	sw $ra, CONTEXT_OFFSET_PC($a0)
+	sw $sp, CONTEXT_OFFSET_SP($a0)
 	
 	# context_save returns 1
@@ -46,5 +58,17 @@
 
 context_restore_arch:
-	CONTEXT_RESTORE_ARCH_CORE $a0
+	lw $s0, CONTEXT_OFFSET_S0($a0)
+	lw $s1, CONTEXT_OFFSET_S1($a0)
+	lw $s2, CONTEXT_OFFSET_S2($a0)
+	lw $s3, CONTEXT_OFFSET_S3($a0)
+	lw $s4, CONTEXT_OFFSET_S4($a0)
+	lw $s5, CONTEXT_OFFSET_S5($a0)
+	lw $s6, CONTEXT_OFFSET_S6($a0)
+	lw $s7, CONTEXT_OFFSET_S7($a0)
+	lw $s8, CONTEXT_OFFSET_S8($a0)
+	lw $gp, CONTEXT_OFFSET_GP($a0)
+	
+	lw $ra, CONTEXT_OFFSET_PC($a0)
+	lw $sp, CONTEXT_OFFSET_SP($a0)
 	
 	# context_restore returns 0
Index: rnel/arch/mips32/src/ddi/ddi.c
===================================================================
--- kernel/arch/mips32/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips32ddi
- * @{
- */
-/** @file
- */
-
-#include <ddi/ddi.h>
-#include <proc/task.h>
-#include <typedefs.h>
-#include <security/cap.h>
-#include <arch.h>
-#include <arch/cp0.h>
-
-/** Enable I/O space range for task.
- *
- * Interrupts are disabled and task is locked.
- *
- * @param task Task.
- * @param ioaddr Startign I/O space address.
- * @param size Size of the enabled I/O range.
- *
- * @return 0 on success or an error code from errno.h.
- */
-int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
-{
-	return 0;
-}
-
-/** @}
- */
Index: kernel/arch/mips32/src/start.S
===================================================================
--- kernel/arch/mips32/src/start.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/mips32/src/start.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -30,6 +30,6 @@
 #include <arch/mm/page.h>
 #include <arch/asm/boot.h>
-#include <arch/context_offset.h>
 #include <arch/stack.h>
+#include <arch/istate_struct.h>
 
 .text
@@ -51,43 +51,4 @@
 #define REG_SAVE_MASK 0x1f
 
-#define ISTATE_OFFSET_A0	0
-#define ISTATE_OFFSET_A1	4
-#define ISTATE_OFFSET_A2	8
-#define ISTATE_OFFSET_A3	12
-#define ISTATE_OFFSET_T0	16
-#define ISTATE_OFFSET_T1	20
-#define ISTATE_OFFSET_V0	24
-#define ISTATE_OFFSET_V1	28
-#define ISTATE_OFFSET_AT	32
-#define ISTATE_OFFSET_T2	36
-#define ISTATE_OFFSET_T3	40
-#define ISTATE_OFFSET_T4	44
-#define ISTATE_OFFSET_T5	48
-#define ISTATE_OFFSET_T6	52
-#define ISTATE_OFFSET_T7	56
-#define ISTATE_OFFSET_S0	60
-#define ISTATE_OFFSET_S1	64
-#define ISTATE_OFFSET_S2	68
-#define ISTATE_OFFSET_S3	72
-#define ISTATE_OFFSET_S4	76
-#define ISTATE_OFFSET_S5	80
-#define ISTATE_OFFSET_S6	84
-#define ISTATE_OFFSET_S7	88
-#define ISTATE_OFFSET_T8	92
-#define ISTATE_OFFSET_T9	96
-#define ISTATE_OFFSET_KT0	100
-#define ISTATE_OFFSET_KT1	104
-#define ISTATE_OFFSET_GP	108
-#define ISTATE_OFFSET_SP	112
-#define ISTATE_OFFSET_S8	116
-#define ISTATE_OFFSET_RA	120
-#define ISTATE_OFFSET_LO	124
-#define ISTATE_OFFSET_HI	128
-#define ISTATE_OFFSET_STATUS	132
-#define ISTATE_OFFSET_EPC	136
-#define ISTATE_OFFSET_ALIGNMENT	140
-
-#define ISTATE_SOFT_SIZE	144
-
 /*
  * The fake ABI prologue is never executed and may not be part of the
@@ -97,5 +58,5 @@
  */
 .macro FAKE_ABI_PROLOGUE
-	sub $sp, ISTATE_SOFT_SIZE
+	sub $sp, ISTATE_SIZE
 	sw $ra, ISTATE_OFFSET_EPC($sp)
 .endm
@@ -265,5 +226,5 @@
 	KERNEL_STACK_TO_K0
 	
-	sub $k0, ISTATE_SOFT_SIZE
+	sub $k0, ISTATE_SIZE
 	sw $sp, ISTATE_OFFSET_SP($k0)
 	move $sp, $k0
@@ -355,5 +316,5 @@
 tlb_refill_handler:
 	KERNEL_STACK_TO_K0
-	sub $k0, ISTATE_SOFT_SIZE
+	sub $k0, ISTATE_SIZE
 	REGISTERS_STORE_AND_EXC_RESET $k0
 	sw $sp, ISTATE_OFFSET_SP($k0)
@@ -371,5 +332,5 @@
 cache_error_handler:
 	KERNEL_STACK_TO_K0
-	sub $k0, ISTATE_SOFT_SIZE
+	sub $k0, ISTATE_SIZE
 	REGISTERS_STORE_AND_EXC_RESET $k0
 	sw $sp, ISTATE_OFFSET_SP($k0)
Index: rnel/arch/mips64/Makefile.inc
===================================================================
--- kernel/arch/mips64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-BFD_ARCH = mips:4000
-BFD = binary
-GCC_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=64
-AFLAGS = -64
-
-BITS = 64
-
-## Accepted MACHINEs
-#
-
-ifeq ($(MACHINE),msim)
-	BFD_NAME = elf64-tradlittlemips
-	ENDIANESS = LE
-endif
-
-ARCH_SOURCES = \
-	arch/$(KARCH)/src/start.S \
-	arch/$(KARCH)/src/context.S \
-	arch/$(KARCH)/src/mips64.c \
-	arch/$(KARCH)/src/asm.S \
-	arch/$(KARCH)/src/exception.c \
-	arch/$(KARCH)/src/interrupt.c \
-	arch/$(KARCH)/src/cache.c \
-	arch/$(KARCH)/src/debugger.c \
-	arch/$(KARCH)/src/cpu/cpu.c \
-	arch/$(KARCH)/src/debug/stacktrace.c \
-	arch/$(KARCH)/src/debug/stacktrace_asm.S \
-	arch/$(KARCH)/src/mm/km.c \
-	arch/$(KARCH)/src/mm/frame.c \
-	arch/$(KARCH)/src/mm/page.c \
-	arch/$(KARCH)/src/mm/tlb.c \
-	arch/$(KARCH)/src/mm/as.c \
-	arch/$(KARCH)/src/fpu_context.c \
-	arch/$(KARCH)/src/ddi/ddi.c \
-	arch/$(KARCH)/src/smp/dorder.c \
-	arch/$(KARCH)/src/smp/smp.c
Index: rnel/arch/mips64/_link.ld.in
===================================================================
--- kernel/arch/mips64/_link.ld.in	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,57 +1,0 @@
-/*
- * MIPS64 linker script
- *
- *  kernel text
- *  kernel data
- *
- */
-
-#undef mips
-#define mips mips
-
-#define KERNEL_LOAD_ADDRESS 0xffffffff80100000
-
-OUTPUT_ARCH(mips)
-OUTPUT_FORMAT(elf64-tradlittlemips)
-ENTRY(kernel_image_start)
-
-SECTIONS {
-	. = KERNEL_LOAD_ADDRESS;
-	.text : {
-		ktext_start = .;
-		*(.text);
-		ktext_end = .;
-	}
-	.data : {
-		kdata_start = .;
-		*(.data);                       /* initialized data */
-		hardcoded_ktext_size = .;
-		LONG(ktext_end - ktext_start);
-		hardcoded_kdata_size = .;
-		LONG(kdata_end - kdata_start);
-		hardcoded_load_address = .;
-		LONG(KERNEL_LOAD_ADDRESS);
-		*(.rodata*);
-		*(.sdata);
-		*(.reginfo);
-		*(.sbss);
-		*(.scommon);
-		*(.bss);                        /* uninitialized static variables */
-		*(COMMON);                      /* global variables */
-		. = ALIGN(8);
-		symbol_table = .;
-		*(symtab.*);
-	}
-	_gp = . + 0x8000;
-	.lit8 : { *(.lit8) }
-	.lit4 : { *(.lit4) }
-	
-	kdata_end = .;
-	
-	/DISCARD/ : {
-		*(.mdebug*);
-		*(.pdr);
-		*(.comment);
-		*(.note);
-	}
-}
Index: rnel/arch/mips64/include/arch/arch.h
===================================================================
--- kernel/arch/mips64/include/arch/arch.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,63 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_ARCH_H_
-#define KERN_mips64_ARCH_H_
-
-#include <typedefs.h>
-
-#define TASKMAP_MAX_RECORDS        32
-#define CPUMAP_MAX_RECORDS         32
-#define BOOTINFO_TASK_NAME_BUFLEN  32
-
-extern size_t cpu_count;
-
-typedef struct {
-	void *addr;
-	size_t size;
-	char name[BOOTINFO_TASK_NAME_BUFLEN];
-} utask_t;
-
-typedef struct {
-	uint32_t cpumap;
-	size_t cnt;
-	utask_t tasks[TASKMAP_MAX_RECORDS];
-} bootinfo_t;
-
-extern void arch_pre_main(void *entry, bootinfo_t *bootinfo);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/asm.h
===================================================================
--- kernel/arch/mips64/include/arch/asm.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,117 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_ASM_H_
-#define KERN_mips64_ASM_H_
-
-#include <typedefs.h>
-#include <config.h>
-#include <trace.h>
-
-NO_TRACE static inline void cpu_sleep(void)
-{
-	/*
-	 * Unfortunatelly most of the simulators do not support
-	 *
-	 * asm volatile (
-	 *     "wait"
-	 * );
-	 *
-	 */
-}
-
-/** Return base address of current stack
- *
- * Return the base address of the current stack.
- * The stack is assumed to be STACK_SIZE bytes long.
- * The stack must start on page boundary.
- *
- */
-NO_TRACE static inline uintptr_t get_stack_base(void)
-{
-	uintptr_t base;
-	
-	asm volatile (
-		"and %[base], $29, %[mask]\n"
-		: [base] "=r" (base)
-		: [mask] "r" (~(STACK_SIZE - 1))
-	);
-	
-	return base;
-}
-
-NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
-{
-	*port = v;
-}
-
-NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
-{
-	*port = v;
-}
-
-NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
-{
-	*port = v;
-}
-
-NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
-{
-	return *port;
-}
-
-NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
-{
-	return *port;
-}
-
-NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
-{
-	return *port;
-}
-
-extern void cpu_halt(void) __attribute__((noreturn));
-extern void asm_delay_loop(uint32_t);
-extern void userspace_asm(uintptr_t, uintptr_t, uintptr_t);
-
-extern ipl_t interrupts_disable(void);
-extern ipl_t interrupts_enable(void);
-extern void interrupts_restore(ipl_t);
-extern ipl_t interrupts_read(void);
-extern bool interrupts_disabled(void);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/asm/boot.h
===================================================================
--- kernel/arch/mips64/include/arch/asm/boot.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * Copyright (c) 2005 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_BOOT_H_
-#define KERN_mips64_BOOT_H_
-
-/* Temporary stack size for boot process */
-#define TEMP_STACK_SIZE  0x100
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/asm/regname.h
===================================================================
--- kernel/arch/mips64/include/arch/asm/regname.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/*
- * Copyright (c) 2005 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_REGNAME_H_
-#define KERN_mips64_REGNAME_H_
-
-#define zero    0
-#define at      1
-#define v0      2
-#define v1      3
-#define a0      4
-#define a1      5
-#define a2      6
-#define a3      7
-#define t0      8
-#define t1      9
-#define t2      10
-#define t3      11
-#define t4      12
-#define t5      13
-#define t6      14
-#define t7      15
-#define s0      16
-#define s1      17
-#define s2      18
-#define s3      19
-#define s4      20
-#define s5      21
-#define s6      22
-#define s7      23
-#define t8      24
-#define t9      25
-#define k0      26
-#define k1      27
-#define gp      28
-#define sp      29
-#define s8      30
-#define ra      31
-
-#define rindex    0
-#define rrandom   1
-#define entrylo0  2
-#define entrylo1  3
-#define context   4
-#define pagemask  5
-#define wired     6
-#define badvaddr  8
-#define count     9
-#define entryhi   10
-#define compare   11
-#define status    12
-#define cause     13
-#define epc       14
-#define rconfig   16
-#define lladdr    17
-#define watchlo   18
-#define watchhi   19
-#define xcontext  20
-#define rdebug    23
-#define depc      24
-#define eepc      30
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/atomic.h
===================================================================
--- kernel/arch/mips64/include/arch/atomic.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,114 +1,0 @@
-/*
- * Copyright (c) 2005 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_ATOMIC_H_
-#define KERN_mips64_ATOMIC_H_
-
-#include <trace.h>
-
-#define atomic_inc(x)  ((void) atomic_add(x, 1))
-#define atomic_dec(x)  ((void) atomic_add(x, -1))
-
-#define atomic_postinc(x)  (atomic_add(x, 1) - 1)
-#define atomic_postdec(x)  (atomic_add(x, -1) + 1)
-
-#define atomic_preinc(x)  atomic_add(x, 1)
-#define atomic_predec(x)  atomic_add(x, -1)
-
-/* Atomic addition of immediate value.
- *
- * @param val Memory location to which will be the immediate value added.
- * @param i Signed immediate that will be added to *val.
- *
- * @return Value after addition.
- *
- */
-NO_TRACE static inline atomic_count_t atomic_add(atomic_t *val,
-    atomic_count_t i)
-{
-	atomic_count_t tmp;
-	atomic_count_t v;
-	
-	asm volatile (
-		"1:\n"
-		"	lld %0, %1\n"
-		"	daddu %0, %0, %3\n"  /* same as daddi, but never traps on overflow */
-		"	move %2, %0\n"
-		"	scd %0, %1\n"
-		"	beq %0, %4, 1b\n"   /* if the atomic operation failed, try again */
-		"	nop\n"
-		: "=&r" (tmp),
-		  "+m" (val->count),
-		  "=&r" (v)
-		: "r" (i),
-		  "i" (0)
-	);
-	
-	return v;
-}
-
-NO_TRACE static inline atomic_count_t test_and_set(atomic_t *val)
-{
-	atomic_count_t tmp;
-	atomic_count_t v;
-	
-	asm volatile (
-		"1:\n"
-		"	lld %2, %1\n"
-		"	bnez %2, 2f\n"
-		"	dli %0, %3\n"
-		"	scd %0, %1\n"
-		"	beqz %0, 1b\n"
-		"	nop\n"
-		"2:\n"
-		: "=&r" (tmp),
-		  "+m" (val->count),
-		  "=&r" (v)
-		: "i" (1)
-	);
-	
-	return v;
-}
-
-NO_TRACE static inline void atomic_lock_arch(atomic_t *val)
-{
-	do {
-		while (val->count);
-	} while (test_and_set(val));
-}
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/barrier.h
===================================================================
--- kernel/arch/mips64/include/arch/barrier.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_BARRIER_H_
-#define KERN_mips64_BARRIER_H_
-
-/*
- * TODO: implement true MIPS memory barriers for macros below.
- */
-#define CS_ENTER_BARRIER()  asm volatile ("" ::: "memory")
-#define CS_LEAVE_BARRIER()  asm volatile ("" ::: "memory")
-
-#define memory_barrier() asm volatile ("" ::: "memory")
-#define read_barrier()   asm volatile ("" ::: "memory")
-#define write_barrier()  asm volatile ("" ::: "memory")
-
-#define smc_coherence(a)
-#define smc_coherence_block(a, l)
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/cache.h
===================================================================
--- kernel/arch/mips64/include/arch/cache.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_CACHE_H_
-#define KERN_mips64_CACHE_H_
-
-#include <arch/exception.h>
-
-extern void cache_error(istate_t *);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/context.h
===================================================================
--- kernel/arch/mips64/include/arch/context.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_CONTEXT_H_
-#define KERN_mips64_CONTEXT_H_
-
-#include <align.h>
-#include <arch/stack.h>
-
-/*
- * Put one item onto the stack to support get_stack_base() and align it up.
- */
-#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
-
-#ifndef __ASM__
-
-#include <typedefs.h>
-
-#define context_set(ctx, pc, stack, size) \
-    context_set_generic(ctx, pc, stack, size)
-
-/*
- * Only save registers that must be preserved across
- * function calls.
- */
-typedef struct {
-	uintptr_t sp;
-	uintptr_t pc;
-	
-	uint64_t s0;
-	uint64_t s1;
-	uint64_t s2;
-	uint64_t s3;
-	uint64_t s4;
-	uint64_t s5;
-	uint64_t s6;
-	uint64_t s7;
-	uint64_t s8;
-	uint64_t gp;
-	
-	ipl_t ipl;
-} context_t;
-
-#endif /* __ASM__ */
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/context_offset.h
===================================================================
--- kernel/arch/mips64/include/arch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,189 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KERN_mips64_CONTEXT_OFFSET_H_
-#define KERN_mips64_CONTEXT_OFFSET_H_
-
-#define OFFSET_SP       0x00
-#define OFFSET_PC       0x08
-#define OFFSET_S0       0x10
-#define OFFSET_S1       0x18
-#define OFFSET_S2       0x20
-#define OFFSET_S3       0x28
-#define OFFSET_S4       0x30
-#define OFFSET_S5       0x38
-#define OFFSET_S6       0x40
-#define OFFSET_S7       0x48
-#define OFFSET_S8       0x50
-#define OFFSET_GP       0x58
-
-#ifdef KERNEL
-	#define OFFSET_IPL  0x60
-#else
-	#define OFFSET_TLS  0x60
-	
-	#define OFFSET_F20  0x68
-	#define OFFSET_F21  0x70
-	#define OFFSET_F22  0x78
-	#define OFFSET_F23  0x80
-	#define OFFSET_F24  0x88
-	#define OFFSET_F25  0x90
-	#define OFFSET_F26  0x98
-	#define OFFSET_F27  0xa0
-	#define OFFSET_F28  0xa8
-	#define OFFSET_F29  0xb0
-	#define OFFSET_F30  0xb8
-#endif /* KERNEL */
-
-#ifdef __ASM__
-
-#ifdef KERNEL
-
-#include <arch/asm/regname.h>
-
-#else /* KERNEL */
-
-#include <libarch/regname.h>
-
-#endif /* KERNEL */
-
-/* ctx: address of the structure with saved context */
-.macro CONTEXT_SAVE_ARCH_CORE ctx:req
-	sd $s0, OFFSET_S0(\ctx)
-	sd $s1, OFFSET_S1(\ctx)
-	sd $s2, OFFSET_S2(\ctx)
-	sd $s3, OFFSET_S3(\ctx)
-	sd $s4, OFFSET_S4(\ctx)
-	sd $s5, OFFSET_S5(\ctx)
-	sd $s6, OFFSET_S6(\ctx)
-	sd $s7, OFFSET_S7(\ctx)
-	sd $s8, OFFSET_S8(\ctx)
-	sd $gp, OFFSET_GP(\ctx)
-	
-#ifndef KERNEL
-	sd $k1, OFFSET_TLS(\ctx)
-	
-#ifdef CONFIG_FPU
-	dmfc1 $t0, $20
-	sd $t0, OFFSET_F20(\ctx)
-	
-	dmfc1 $t0,$21
-	sd $t0, OFFSET_F21(\ctx)
-	
-	dmfc1 $t0,$22
-	sd $t0, OFFSET_F22(\ctx)
-	
-	dmfc1 $t0,$23
-	sd $t0, OFFSET_F23(\ctx)
-	
-	dmfc1 $t0,$24
-	sd $t0, OFFSET_F24(\ctx)
-	
-	dmfc1 $t0,$25
-	sd $t0, OFFSET_F25(\ctx)
-	
-	dmfc1 $t0,$26
-	sd $t0, OFFSET_F26(\ctx)
-	
-	dmfc1 $t0,$27
-	sd $t0, OFFSET_F27(\ctx)
-	
-	dmfc1 $t0,$28
-	sd $t0, OFFSET_F28(\ctx)
-	
-	dmfc1 $t0,$29
-	sd $t0, OFFSET_F29(\ctx)
-	
-	dmfc1 $t0,$30
-	sd $t0, OFFSET_F30(\ctx)
-#endif /* CONFIG_FPU */
-#endif /* KERNEL */
-	
-	sd $ra, OFFSET_PC(\ctx)
-	sd $sp, OFFSET_SP(\ctx)
-.endm
-
-/* ctx: address of the structure with saved context */
-.macro CONTEXT_RESTORE_ARCH_CORE ctx:req
-	ld $s0, OFFSET_S0(\ctx)
-	ld $s1, OFFSET_S1(\ctx)
-	ld $s2, OFFSET_S2(\ctx)
-	ld $s3, OFFSET_S3(\ctx)
-	ld $s4, OFFSET_S4(\ctx)
-	ld $s5, OFFSET_S5(\ctx)
-	ld $s6, OFFSET_S6(\ctx)
-	ld $s7, OFFSET_S7(\ctx)
-	ld $s8, OFFSET_S8(\ctx)
-	ld $gp, OFFSET_GP(\ctx)
-	
-#ifndef KERNEL
-	ld $k1, OFFSET_TLS(\ctx)
-	
-#ifdef CONFIG_FPU
-	ld $t0, OFFSET_F20(\ctx)
-	dmtc1 $t0,$20
-	
-	ld $t0, OFFSET_F21(\ctx)
-	dmtc1 $t0,$21
-	
-	ld $t0, OFFSET_F22(\ctx)
-	dmtc1 $t0,$22
-	
-	ld $t0, OFFSET_F23(\ctx)
-	dmtc1 $t0,$23
-	
-	ld $t0, OFFSET_F24(\ctx)
-	dmtc1 $t0,$24
-	
-	ld $t0, OFFSET_F25(\ctx)
-	dmtc1 $t0,$25
-	
-	ld $t0, OFFSET_F26(\ctx)
-	dmtc1 $t0,$26
-	
-	ld $t0, OFFSET_F27(\ctx)
-	dmtc1 $t0,$27
-	
-	ld $t0, OFFSET_F28(\ctx)
-	dmtc1 $t0,$28
-	
-	ld $t0, OFFSET_F29(\ctx)
-	dmtc1 $t0,$29
-	
-	ld $t0, OFFSET_F30(\ctx)
-	dmtc1 $t0,$30
-#endif /* CONFIG_FPU */
-#endif /* KERNEL */
-	
-	ld $ra, OFFSET_PC(\ctx)
-	ld $sp, OFFSET_SP(\ctx)
-.endm
-
-#endif /* __ASM__ */
-
-#endif
Index: rnel/arch/mips64/include/arch/cp0.h
===================================================================
--- kernel/arch/mips64/include/arch/cp0.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,133 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_CP0_H_
-#define KERN_mips64_CP0_H_
-
-#define cp0_status_ie_enabled_bit     (1 << 0)
-#define cp0_status_exl_exception_bit  (1 << 1)
-#define cp0_status_erl_error_bit      (1 << 2)
-#define cp0_status_um_bit             (1 << 4)
-#define cp0_status_bev_bootstrap_bit  (1 << 22)
-#define cp0_status_fpu_bit            (1 << 29)
-
-#define cp0_status_im_shift  8
-#define cp0_status_im_mask   0xff00
-
-#define cp0_cause_excno(cause)   ((cause >> 2) & 0x1f)
-#define cp0_cause_coperr(cause)  ((cause >> 28) & 0x3)
-
-#define fpu_cop_id  1
-
-/*
- * Magic value for use in msim.
- */
-#define cp0_compare_value  100000
-
-#define cp0_mask_all_int() \
-	cp0_status_write(cp0_status_read() & ~(cp0_status_im_mask))
-
-#define cp0_unmask_all_int() \
-	cp0_status_write(cp0_status_read() | cp0_status_im_mask)
-
-#define cp0_mask_int(it) \
-	cp0_status_write(cp0_status_read() & ~(1 << (cp0_status_im_shift + (it))))
-
-#define cp0_unmask_int(it) \
-	cp0_status_write(cp0_status_read() | (1 << (cp0_status_im_shift + (it))))
-
-#define GEN_READ_CP0(nm,reg) static inline uint64_t cp0_ ##nm##_read(void) \
-	{ \
-		uint64_t retval; \
-		asm volatile ( \
-			"dmfc0 %0, $" #reg \
-			: "=r" (retval) \
-		); \
-		return retval; \
-	}
-
-#define GEN_WRITE_CP0(nm,reg) static inline void cp0_ ##nm##_write(uint32_t val) \
-	{ \
-		asm volatile ( \
-			"dmtc0 %0, $" #reg \
-			:: "r" (val) \
-		); \
-	}
-
-GEN_READ_CP0(index, 0);
-GEN_WRITE_CP0(index, 0);
-
-GEN_READ_CP0(random, 1);
-
-GEN_READ_CP0(entry_lo0, 2);
-GEN_WRITE_CP0(entry_lo0, 2);
-
-GEN_READ_CP0(entry_lo1, 3);
-GEN_WRITE_CP0(entry_lo1, 3);
-
-GEN_READ_CP0(context, 4);
-GEN_WRITE_CP0(context, 4);
-
-GEN_READ_CP0(pagemask, 5);
-GEN_WRITE_CP0(pagemask, 5);
-
-GEN_READ_CP0(wired, 6);
-GEN_WRITE_CP0(wired, 6);
-
-GEN_READ_CP0(badvaddr, 8);
-
-GEN_READ_CP0(count, 9);
-GEN_WRITE_CP0(count, 9);
-
-GEN_READ_CP0(entry_hi, 10);
-GEN_WRITE_CP0(entry_hi, 10);
-
-GEN_READ_CP0(compare, 11);
-GEN_WRITE_CP0(compare, 11);
-
-GEN_READ_CP0(status, 12);
-GEN_WRITE_CP0(status, 12);
-
-GEN_READ_CP0(cause, 13);
-GEN_WRITE_CP0(cause, 13);
-
-GEN_READ_CP0(epc, 14);
-GEN_WRITE_CP0(epc, 14);
-
-GEN_READ_CP0(prid, 15);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/cpu.h
===================================================================
--- kernel/arch/mips64/include/arch/cpu.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_CPU_H_
-#define KERN_mips64_CPU_H_
-
-#include <typedefs.h>
-#include <arch/asm.h>
-
-typedef struct {
-	uint32_t imp_num;
-	uint32_t rev_num;
-} cpu_arch_t;
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/cycle.h
===================================================================
--- kernel/arch/mips64/include/arch/cycle.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Copyright (c) 2006 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_CYCLE_H_
-#define KERN_mips64_CYCLE_H_
-
-#include <arch/cp0.h>
-#include <arch/interrupt.h>
-#include <trace.h>
-
-NO_TRACE static inline uint64_t get_cycle(void)
-{
-	return ((uint64_t) count_hi << 32) + ((uint64_t) cp0_count_read());
-}
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/debug.h
===================================================================
--- kernel/arch/mips64/include/arch/debug.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,71 +1,0 @@
-/*
- * Copyright (c) 2005 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_DEBUG_H_
-#define KERN_mips64_DEBUG_H_
-
-/** Enter the simulator trace mode */
-#define ___traceon() \
-	asm volatile ( \
-		"\t.word\t0x39\n" \
-	);
-
-/** Leave the simulator trace mode */
-#define ___traceoff() \
-	asm volatile ( \
-		"\t.word\t0x3d\n" \
-	);
-
-/** Ask the simulator to dump registers */
-#define ___regview() \
-	asm volatile ( \
-		"\t.word\t0x37\n" \
-	);
-
-/** Halt the simulator */
-#define ___halt() \
-	asm volatile ( \
-		"\t.word\t0x28\n" \
-	);
-
-/** Enter the simulator interactive mode */
-#define ___intmode() \
-	asm volatile ( \
-		"\t.word\t0x29\n" \
-	);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/debugger.h
===================================================================
--- kernel/arch/mips64/include/arch/debugger.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * Copyright (c) 2005 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_DEBUGGER_H_
-#define KERN_mips64_DEBUGGER_H_
-
-#include <arch/exception.h>
-#include <typedefs.h>
-
-#define BKPOINTS_MAX  10
-
-/** Breakpoint was shot */
-#define BKPOINT_INPROG  (1 << 0)
-
-/** One-time breakpoint, mandatory for j/b instructions */
-#define BKPOINT_ONESHOT  (1 << 1)
-
-/**
- * Breakpoint is set on the next instruction, so that it
- * could be reinstalled on the previous one
- */
-#define BKPOINT_REINST  (1 << 2)
-
-/** Call a predefined function */
-#define BKPOINT_FUNCCALL  (1 << 3)
-
-
-typedef struct  {
-	uintptr_t address;         /**< Breakpoint address */
-	sysarg_t instruction;      /**< Original instruction */
-	sysarg_t nextinstruction;  /**< Original instruction following break */
-	unsigned int flags;        /**< Flags regarding breakpoint */
-	size_t counter;
-	void (*bkfunc)(void *, istate_t *);
-} bpinfo_t;
-
-extern bpinfo_t breakpoints[BKPOINTS_MAX];
-
-extern bool is_jump(sysarg_t);
-
-extern void debugger_init(void);
-extern void debugger_bpoint(istate_t *);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/drivers/msim.h
===================================================================
--- kernel/arch/mips64/include/arch/drivers/msim.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2005 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_MSIM_H_
-#define KERN_mips64_MSIM_H_
-
-/** Address of devices. */
-#define MSIM_VIDEORAM     0xffffffff90000000
-#define MSIM_KBD_ADDRESS  0xffffffff90000000
-#define MSIM_KBD_IRQ      2
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/elf.h
===================================================================
--- kernel/arch/mips64/include/arch/elf.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,51 +1,0 @@
-/*
- * Copyright (c) 2006 Sergey Bondari
- * 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_ELF_H_
-#define KERN_mips64_ELF_H_
-
-#define ELF_MACHINE  EM_MIPS
-
-#ifdef __BE__
-	#define ELF_DATA_ENCODING  ELFDATA2MSB
-#else
-	#define ELF_DATA_ENCODING  ELFDATA2LSB
-#endif
-
-#define ELF_CLASS  ELFCLASS64
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/exception.h
===================================================================
--- kernel/arch/mips64/include/arch/exception.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_EXCEPTION_H_
-#define KERN_mips64_EXCEPTION_H_
-
-#include <typedefs.h>
-#include <arch/istate.h>
-
-#define EXC_Int    0
-#define EXC_Mod    1
-#define EXC_TLBL   2
-#define EXC_TLBS   3
-#define EXC_AdEL   4
-#define EXC_AdES   5
-#define EXC_IBE    6
-#define EXC_DBE    7
-#define EXC_Sys    8
-#define EXC_Bp     9
-#define EXC_RI     10
-#define EXC_CpU    11
-#define EXC_Ov     12
-#define EXC_Tr     13
-#define EXC_VCEI   14
-#define EXC_FPE    15
-#define EXC_WATCH  23
-#define EXC_VCED   31
-
-extern void exception(istate_t *istate);
-extern void tlb_refill_entry(void);
-extern void exception_entry(void);
-extern void cache_error_entry(void);
-extern void exception_init(void);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/faddr.h
===================================================================
--- kernel/arch/mips64/include/arch/faddr.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_FADDR_H_
-#define KERN_mips64_FADDR_H_
-
-#include <typedefs.h>
-
-#define FADDR(fptr)  ((uintptr_t) (fptr))
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/fpu_context.h
===================================================================
--- kernel/arch/mips64/include/arch/fpu_context.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Copyright (c) 2005 Jakub Vana
- * 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_FPU_CONTEXT_H_
-#define KERN_mips64_FPU_CONTEXT_H_
-
-#include <typedefs.h>
-
-#define FPU_CONTEXT_ALIGN  sizeof(sysarg_t)
-
-typedef struct {
-	sysarg_t dregs[32];
-	sysarg_t cregs[32];
-} fpu_context_t;
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/interrupt.h
===================================================================
--- kernel/arch/mips64/include/arch/interrupt.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_INTERRUPT_H_
-#define KERN_mips64_INTERRUPT_H_
-
-#include <typedefs.h>
-#include <arch/exception.h>
-
-#define IVT_ITEMS  32
-#define IVT_FIRST  0
-
-#define VECTOR_TLB_SHOOTDOWN_IPI  EXC_Int
-
-extern function virtual_timer_fnc;
-extern uint32_t count_hi;
-
-extern void interrupt_init(void);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/istate.h
===================================================================
--- kernel/arch/mips64/include/arch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,119 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_ISTATE_H_
-#define KERN_mips64_ISTATE_H_
-
-#include <trace.h>
-
-#ifdef KERNEL
-
-#include <arch/cp0.h>
-
-#else /* KERNEL */
-
-#include <libarch/cp0.h>
-
-#endif /* KERNEL */
-
-typedef struct istate {
-	/*
-	 * The first seven registers are arranged so that the istate structure
-	 * can be used both for exception handlers and for the syscall handler.
-	 */
-	uint64_t a0;      /* arg1 */
-	uint64_t a1;      /* arg2 */
-	uint64_t a2;      /* arg3 */
-	uint64_t a3;      /* arg4 */
-	uint64_t t0;      /* arg5 */
-	uint64_t t1;      /* arg6 */
-	uint64_t v0;      /* arg7 */
-	uint64_t v1;
-	uint64_t at;
-	uint64_t t2;
-	uint64_t t3;
-	uint64_t t4;
-	uint64_t t5;
-	uint64_t t6;
-	uint64_t t7;
-	uint64_t s0;
-	uint64_t s1;
-	uint64_t s2;
-	uint64_t s3;
-	uint64_t s4;
-	uint64_t s5;
-	uint64_t s6;
-	uint64_t s7;
-	uint64_t t8;
-	uint64_t t9;
-	uint64_t kt0;
-	uint64_t kt1;     /* We use it as thread-local pointer */
-	uint64_t gp;
-	uint64_t sp;
-	uint64_t s8;
-	uint64_t ra;
-	
-	uint64_t lo;
-	uint64_t hi;
-	
-	uint64_t status;  /* cp0_status */
-	uint64_t epc;     /* cp0_epc */
-} istate_t;
-
-NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
-    uintptr_t retaddr)
-{
-	istate->epc = retaddr;
-}
-
-/** Return true if exception happened while in userspace */
-NO_TRACE static inline int istate_from_uspace(istate_t *istate)
-{
-	return istate->status & cp0_status_um_bit;
-}
-
-NO_TRACE static inline uintptr_t istate_get_pc(istate_t *istate)
-{
-	return istate->epc;
-}
-
-NO_TRACE static inline uintptr_t istate_get_fp(istate_t *istate)
-{
-	return istate->sp;
-}
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/mm/as.h
===================================================================
--- kernel/arch/mips64/include/arch/mm/as.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*
- * Copyright (c) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_AS_H_
-#define KERN_mips64_AS_H_
-
-#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
-
-#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0xffffffff80000000)
-#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT64_C(0xffffffff9fffffff)
-#define USER_ADDRESS_SPACE_START_ARCH    UINT64_C(0x0000000000000000)
-#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x000000ffffffffff)
-
-typedef struct {
-} as_arch_t;
-
-#include <genarch/mm/as_ht.h>
-
-#define as_constructor_arch(as, flags)  (as != as)
-#define as_destructor_arch(as)          (as != as)
-#define as_create_arch(as, flags)       (as != as)
-#define as_deinstall_arch(as)
-#define as_invalidate_translation_cache(as, page, cnt)
-
-extern void as_arch_init(void);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/mm/asid.h
===================================================================
--- kernel/arch/mips64/include/arch/mm/asid.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_ASID_H_
-#define KERN_mips64_ASID_H_
-
-#include <typedefs.h>
-
-#define ASID_MAX_ARCH  255    /* 2^8 - 1 */
-
-typedef uint8_t asid_t;
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/mm/frame.h
===================================================================
--- kernel/arch/mips64/include/arch/mm/frame.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_FRAME_H_
-#define KERN_mips64_FRAME_H_
-
-#define FRAME_WIDTH  14  /* 16K */
-#define FRAME_SIZE   (1 << FRAME_WIDTH)
-
-#define FRAME_LOWPRIO  0
-
-#ifndef __ASM__
-
-extern void frame_low_arch_init(void);
-extern void frame_high_arch_init(void);
-extern void physmem_print(void);
-
-#endif /* __ASM__ */
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/mm/km.h
===================================================================
--- kernel/arch/mips64/include/arch/mm/km.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2011 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_KM_H_
-#define KERN_mips64_KM_H_
-
-#include <typedefs.h>
-
-extern void km_identity_arch_init(void);
-extern void km_non_identity_arch_init(void);
-extern bool km_is_non_identity_arch(uintptr_t);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/mm/page.h
===================================================================
--- kernel/arch/mips64/include/arch/mm/page.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_PAGE_H_
-#define KERN_mips64_PAGE_H_
-
-#include <arch/mm/frame.h>
-#include <trace.h>
-
-#define PAGE_WIDTH  FRAME_WIDTH
-#define PAGE_SIZE   FRAME_SIZE
-
-#ifndef __ASM__
-	#define KA2PA(addr)  (((uintptr_t) (addr)) - 0xffffffff80000000)
-	#define PA2KA(addr)  (((uintptr_t) (addr)) + 0xffffffff80000000)
-#else
-	#define KA2PA(addr)  ((addr) - 0xffffffff80000000)
-	#define PA2KA(addr)  ((addr) + 0xffffffff80000000)
-#endif
-
-#ifndef __ASM__
-
-extern void page_arch_init(void);
-
-#endif /* __ASM__ */
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/mm/tlb.h
===================================================================
--- kernel/arch/mips64/include/arch/mm/tlb.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,181 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_TLB_H_
-#define KERN_mips64_TLB_H_
-
-#include <typedefs.h>
-#include <arch/mm/asid.h>
-#include <arch/exception.h>
-#include <trace.h>
-
-#define TLB_ENTRY_COUNT  48
-
-#define TLB_WIRED               1
-#define TLB_KSTACK_WIRED_INDEX  0
-
-#define TLB_PAGE_MASK_4K    (0x000 << 13)
-#define TLB_PAGE_MASK_16K   (0x003 << 13)
-#define TLB_PAGE_MASK_64K   (0x00f << 13)
-#define TLB_PAGE_MASK_256K  (0x03f << 13)
-#define TLB_PAGE_MASK_1M    (0x0ff << 13)
-#define TLB_PAGE_MASK_4M    (0x3ff << 13)
-#define TLB_PAGE_MASK_16M   (0xfff << 13)
-
-#define PAGE_UNCACHED             2
-#define PAGE_CACHEABLE_EXC_WRITE  5
-
-typedef union {
-	struct {
-#ifdef __BE__
-		unsigned int : 2;       /* zero */
-		unsigned int pfn : 24;  /* frame number */
-		unsigned int c : 3;     /* cache coherency attribute */
-		unsigned int d : 1;     /* dirty/write-protect bit */
-		unsigned int v : 1;     /* valid bit */
-		unsigned int g : 1;     /* global bit */
-#else
-		unsigned int g : 1;     /* global bit */
-		unsigned int v : 1;     /* valid bit */
-		unsigned int d : 1;     /* dirty/write-protect bit */
-		unsigned int c : 3;     /* cache coherency attribute */
-		unsigned int pfn : 24;  /* frame number */
-		unsigned int : 2;       /* zero */
-#endif
-	} __attribute__ ((packed));
-	uint32_t value;
-} entry_lo_t;
-
-typedef union {
-	struct {
-#ifdef __BE__
-		unsigned int vpn2 : 19;
-		unsigned int : 5;
-		unsigned int asid : 8;
-#else
-		unsigned int asid : 8;
-		unsigned int : 5;
-		unsigned int vpn2 : 19;
-#endif
-	} __attribute__ ((packed));
-	uint32_t value;
-} entry_hi_t;
-
-typedef union {
-	struct {
-#ifdef __BE__
-		unsigned int : 7;
-		unsigned int mask : 12;
-		unsigned int : 13;
-#else
-		unsigned int : 13;
-		unsigned int mask : 12;
-		unsigned int : 7;
-#endif
-	} __attribute__ ((packed));
-	uint32_t value;
-} page_mask_t;
-
-typedef union {
-	struct {
-#ifdef __BE__
-		unsigned int p : 1;
-		unsigned int : 27;
-		unsigned int index : 4;
-#else
-		unsigned int index : 4;
-		unsigned int : 27;
-		unsigned int p : 1;
-#endif
-	} __attribute__ ((packed));
-	uint32_t value;
-} tlb_index_t;
-
-/** Probe TLB for Matching Entry
- *
- * Probe TLB for Matching Entry.
- */
-NO_TRACE static inline void tlbp(void)
-{
-	asm volatile (
-		"tlbp\n\t"
-	);
-}
-
-/** Read Indexed TLB Entry
- *
- * Read Indexed TLB Entry.
- */
-NO_TRACE static inline void tlbr(void)
-{
-	asm volatile (
-		"tlbr\n\t"
-	);
-}
-
-/** Write Indexed TLB Entry
- *
- * Write Indexed TLB Entry.
- */
-NO_TRACE static inline void tlbwi(void)
-{
-	asm volatile (
-		"tlbwi\n\t"
-	);
-}
-
-/** Write Random TLB Entry
- *
- * Write Random TLB Entry.
- */
-NO_TRACE static inline void tlbwr(void)
-{
-	asm volatile (
-		"tlbwr\n\t"
-	);
-}
-
-#define tlb_invalidate(asid)  tlb_invalidate_asid(asid)
-
-extern void tlb_invalid(istate_t *);
-extern void tlb_refill(istate_t *);
-extern void tlb_modified(istate_t *);
-extern void tlb_prepare_entry_lo(entry_lo_t *, bool, bool, bool, bool,
-    uintptr_t);
-extern void tlb_prepare_entry_hi(entry_hi_t *, asid_t, uintptr_t);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/proc/task.h
===================================================================
--- kernel/arch/mips64/include/arch/proc/task.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64proc
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_TASK_H_
-#define KERN_mips64_TASK_H_
-
-typedef struct {
-} task_arch_t;
-
-#define task_create_arch(task)
-#define task_destroy_arch(task)
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/proc/thread.h
===================================================================
--- kernel/arch/mips64/include/arch/proc/thread.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64proc
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_THREAD_H_
-#define KERN_mips64_THREAD_H_
-
-typedef struct {
-} thread_arch_t;
-
-#define thr_constructor_arch(thread)
-#define thr_destructor_arch(thread)
-#define thread_create_arch(thread)
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/smp/dorder.h
===================================================================
--- kernel/arch/mips64/include/arch/smp/dorder.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2007 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_DORDER_H_
-#define KERN_mips64_DORDER_H_
-
-#include <typedefs.h>
-
-extern uint32_t dorder_cpuid(void);
-extern void dorder_ipi_ack(uint32_t);
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/stack.h
===================================================================
--- kernel/arch/mips64/include/arch/stack.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * 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 mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_STACK_H_
-#define KERN_mips64_STACK_H_
-
-#include <config.h>
-
-#define MEM_STACK_SIZE	STACK_SIZE
-
-#define STACK_ITEM_SIZE  8
-#define STACK_ALIGNMENT  8
-#define ABI_STACK_FRAME  64
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/include/arch/types.h
===================================================================
--- kernel/arch/mips64/include/arch/types.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips64_TYPES_H_
-#define KERN_mips64_TYPES_H_
-
-typedef uint64_t size_t;
-typedef int64_t ssize_t;
-
-typedef uint64_t uintptr_t;
-typedef uint64_t pfn_t;
-
-typedef uint64_t ipl_t;
-
-typedef uint64_t sysarg_t;
-typedef int64_t native_t;
-typedef uint64_t atomic_count_t;
-
-typedef struct {
-} fncptr_t;
-
-#define INTN_C(c)   INT64_C(c)
-#define UINTN_C(c)  UINT64_C(c)
-
-#define PRIdn  PRId64  /**< Format for native_t. */
-#define PRIun  PRIu64  /**< Format for sysarg_t. */
-#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
-#define PRIua  PRIu64  /**< Format for atomic_count_t. */
-
-#endif
-
-/** @}
- */
Index: rnel/arch/mips64/src/asm.S
===================================================================
--- kernel/arch/mips64/src/asm.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,301 +1,0 @@
-/*
- * Copyright (c) 2003 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <arch/asm/regname.h>
-
-.text
-
-.macro cp0_read reg
-	dmfc0 $2, \reg
-	j $31
-	nop
-.endm
-
-.macro cp0_write reg
-	dmtc0 $4, \reg
-	j $31
-	nop
-.endm
-
-.set noat
-.set noreorder
-.set nomacro
-
-.global asm_delay_loop
-asm_delay_loop:
-	j $31
-	nop
-
-.global cpu_halt
-cpu_halt:
-	j cpu_halt
-	nop
-
-.global memcpy_from_uspace
-.global memcpy_to_uspace
-.global memcpy_from_uspace_failover_address
-.global memcpy_to_uspace_failover_address
-memcpy_from_uspace:
-memcpy_to_uspace:
-	move $t2, $a0  /* save dst */
-	
-	addiu $v0, $a1, 3
-	li $v1, -4  /* 0xfffffffffffffffc */
-	and $v0, $v0, $v1
-	beq $a1, $v0, 3f
-	move $t0, $a0
-	
-	0:
-		beq $a2, $zero, 2f
-		move $a3, $zero
-	
-	1:
-		addu $v0, $a1, $a3
-		lbu $a0, 0($v0)
-		addu $v1, $t0, $a3
-		addiu $a3, $a3, 1
-		bne $a3, $a2, 1b
-		sb $a0, 0($v1)
-	
-	2:
-		jr $ra
-		move $v0, $t2
-	
-	3:
-		addiu $v0, $a0, 3
-		and $v0, $v0, $v1
-		bne $a0, $v0, 0b
-		srl $t1, $a2, 2
-		
-		beq $t1, $zero, 5f
-		move $a3, $zero
-		
-		move $a3, $zero
-		move $a0, $zero
-	
-	4:
-		addu $v0, $a1, $a0
-		lw $v1, 0($v0)
-		addiu $a3, $a3, 1
-		addu $v0, $t0, $a0
-		sw $v1, 0($v0)
-		bne $a3, $t1, 4b
-		addiu $a0, $a0, 4
-	
-	5:
-		andi $a2, $a2, 0x3
-		beq $a2, $zero, 2b
-		nop
-		
-		sll $v0, $a3, 2
-		addu $t1, $v0, $t0
-		move $a3, $zero
-		addu $t0, $v0, $a1
-	
-	6:
-		addu $v0, $t0, $a3
-		lbu $a0, 0($v0)
-		addu $v1, $t1, $a3
-		addiu $a3, $a3, 1
-		bne $a3, $a2, 6b
-		sb $a0, 0($v1)
-		
-		jr $ra
-		move $v0, $t2
-
-memcpy_from_uspace_failover_address:
-memcpy_to_uspace_failover_address:
-	jr $ra
-	move $v0, $zero
-
-.macro fpu_gp_save reg ctx
-	mfc1 $t0, $\reg
-	sw $t0, \reg * 4(\ctx)
-.endm
-
-.macro fpu_gp_restore reg ctx
-	lw $t0, \reg * 4(\ctx)
-	mtc1 $t0, $\reg
-.endm
-
-.macro fpu_ct_save reg ctx
-	cfc1 $t0, $1
-	sw $t0, (\reg + 32) * 4(\ctx)
-.endm
-
-.macro fpu_ct_restore reg ctx
-	lw $t0, (\reg + 32) * 4(\ctx)
-	ctc1 $t0, $\reg
-.endm
-
-.global fpu_context_save
-fpu_context_save:
-#ifdef CONFIG_FPU
-	fpu_gp_save 0, $a0
-	fpu_gp_save 1, $a0
-	fpu_gp_save 2, $a0
-	fpu_gp_save 3, $a0
-	fpu_gp_save 4, $a0
-	fpu_gp_save 5, $a0
-	fpu_gp_save 6, $a0
-	fpu_gp_save 7, $a0
-	fpu_gp_save 8, $a0
-	fpu_gp_save 9, $a0
-	fpu_gp_save 10, $a0
-	fpu_gp_save 11, $a0
-	fpu_gp_save 12, $a0
-	fpu_gp_save 13, $a0
-	fpu_gp_save 14, $a0
-	fpu_gp_save 15, $a0
-	fpu_gp_save 16, $a0
-	fpu_gp_save 17, $a0
-	fpu_gp_save 18, $a0
-	fpu_gp_save 19, $a0
-	fpu_gp_save 20, $a0
-	fpu_gp_save 21, $a0
-	fpu_gp_save 22, $a0
-	fpu_gp_save 23, $a0
-	fpu_gp_save 24, $a0
-	fpu_gp_save 25, $a0
-	fpu_gp_save 26, $a0
-	fpu_gp_save 27, $a0
-	fpu_gp_save 28, $a0
-	fpu_gp_save 29, $a0
-	fpu_gp_save 30, $a0
-	fpu_gp_save 31, $a0
-	
-	fpu_ct_save 1, $a0
-	fpu_ct_save 2, $a0
-	fpu_ct_save 3, $a0
-	fpu_ct_save 4, $a0
-	fpu_ct_save 5, $a0
-	fpu_ct_save 6, $a0
-	fpu_ct_save 7, $a0
-	fpu_ct_save 8, $a0
-	fpu_ct_save 9, $a0
-	fpu_ct_save 10, $a0
-	fpu_ct_save 11, $a0
-	fpu_ct_save 12, $a0
-	fpu_ct_save 13, $a0
-	fpu_ct_save 14, $a0
-	fpu_ct_save 15, $a0
-	fpu_ct_save 16, $a0
-	fpu_ct_save 17, $a0
-	fpu_ct_save 18, $a0
-	fpu_ct_save 19, $a0
-	fpu_ct_save 20, $a0
-	fpu_ct_save 21, $a0
-	fpu_ct_save 22, $a0
-	fpu_ct_save 23, $a0
-	fpu_ct_save 24, $a0
-	fpu_ct_save 25, $a0
-	fpu_ct_save 26, $a0
-	fpu_ct_save 27, $a0
-	fpu_ct_save 28, $a0
-	fpu_ct_save 29, $a0
-	fpu_ct_save 30, $a0
-	fpu_ct_save 31, $a0
-#endif
-	j $ra
-	nop
-
-.global fpu_context_restore
-fpu_context_restore:
-#ifdef CONFIG_FPU
-	fpu_gp_restore 0, $a0
-	fpu_gp_restore 1, $a0
-	fpu_gp_restore 2, $a0
-	fpu_gp_restore 3, $a0
-	fpu_gp_restore 4, $a0
-	fpu_gp_restore 5, $a0
-	fpu_gp_restore 6, $a0
-	fpu_gp_restore 7, $a0
-	fpu_gp_restore 8, $a0
-	fpu_gp_restore 9, $a0
-	fpu_gp_restore 10, $a0
-	fpu_gp_restore 11, $a0
-	fpu_gp_restore 12, $a0
-	fpu_gp_restore 13, $a0
-	fpu_gp_restore 14, $a0
-	fpu_gp_restore 15, $a0
-	fpu_gp_restore 16, $a0
-	fpu_gp_restore 17, $a0
-	fpu_gp_restore 18, $a0
-	fpu_gp_restore 19, $a0
-	fpu_gp_restore 20, $a0
-	fpu_gp_restore 21, $a0
-	fpu_gp_restore 22, $a0
-	fpu_gp_restore 23, $a0
-	fpu_gp_restore 24, $a0
-	fpu_gp_restore 25, $a0
-	fpu_gp_restore 26, $a0
-	fpu_gp_restore 27, $a0
-	fpu_gp_restore 28, $a0
-	fpu_gp_restore 29, $a0
-	fpu_gp_restore 30, $a0
-	fpu_gp_restore 31, $a0
-	
-	fpu_ct_restore 1, $a0
-	fpu_ct_restore 2, $a0
-	fpu_ct_restore 3, $a0
-	fpu_ct_restore 4, $a0
-	fpu_ct_restore 5, $a0
-	fpu_ct_restore 6, $a0
-	fpu_ct_restore 7, $a0
-	fpu_ct_restore 8, $a0
-	fpu_ct_restore 9, $a0
-	fpu_ct_restore 10, $a0
-	fpu_ct_restore 11, $a0
-	fpu_ct_restore 12, $a0
-	fpu_ct_restore 13, $a0
-	fpu_ct_restore 14, $a0
-	fpu_ct_restore 15, $a0
-	fpu_ct_restore 16, $a0
-	fpu_ct_restore 17, $a0
-	fpu_ct_restore 18, $a0
-	fpu_ct_restore 19, $a0
-	fpu_ct_restore 20, $a0
-	fpu_ct_restore 21, $a0
-	fpu_ct_restore 22, $a0
-	fpu_ct_restore 23, $a0
-	fpu_ct_restore 24, $a0
-	fpu_ct_restore 25, $a0
-	fpu_ct_restore 26, $a0
-	fpu_ct_restore 27, $a0
-	fpu_ct_restore 28, $a0
-	fpu_ct_restore 29, $a0
-	fpu_ct_restore 30, $a0
-	fpu_ct_restore 31, $a0
-#endif
-	j $ra
-	nop
-
-.global early_putchar
-early_putchar:
-	j $ra
-	nop
Index: rnel/arch/mips64/src/cache.c
===================================================================
--- kernel/arch/mips64/src/cache.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/src/cache.c
Index: rnel/arch/mips64/src/context.S
===================================================================
--- kernel/arch/mips64/src/context.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/src/context.S
Index: rnel/arch/mips64/src/cpu
===================================================================
--- kernel/arch/mips64/src/cpu	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/src/cpu
Index: rnel/arch/mips64/src/ddi
===================================================================
--- kernel/arch/mips64/src/ddi	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/src/ddi
Index: rnel/arch/mips64/src/debug
===================================================================
--- kernel/arch/mips64/src/debug	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/src/debug
Index: rnel/arch/mips64/src/debugger.c
===================================================================
--- kernel/arch/mips64/src/debugger.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/src/debugger.c
Index: rnel/arch/mips64/src/exception.c
===================================================================
--- kernel/arch/mips64/src/exception.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,231 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#include <arch/exception.h>
-#include <arch/interrupt.h>
-#include <arch/mm/tlb.h>
-#include <panic.h>
-#include <arch/cp0.h>
-#include <typedefs.h>
-#include <arch.h>
-#include <debug.h>
-#include <proc/thread.h>
-#include <print.h>
-#include <interrupt.h>
-#include <func.h>
-#include <ddi/irq.h>
-#include <arch/debugger.h>
-#include <symtab.h>
-
-static const char *exctable[] = {
-	"Interrupt",
-	"TLB Modified",
-	"TLB Invalid",
-	"TLB Invalid Store",
-	"Address Error - load/instr. fetch",
-	"Address Error - store",
-	"Bus Error - fetch instruction",
-	"Bus Error - data reference",
-	"Syscall",
-	"BreakPoint",
-	"Reserved Instruction",
-	"Coprocessor Unusable",
-	"Arithmetic Overflow",
-	"Trap",
-	"Virtual Coherency - instruction",
-	"Floating Point",
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	"WatchHi/WatchLo",  /* 23 */
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	"Virtual Coherency - data",
-};
-
-void istate_decode(istate_t *istate)
-{
-	printf("epc=%#018" PRIx64 "\tsta=%#018" PRIx64 "\t"
-	    "lo =%#018" PRIx64 "\thi =%#018" PRIx64 "\n",
-	    istate->epc, istate->status, istate->lo, istate->hi);
-	
-	printf("a0 =%#018" PRIx64 "\ta1 =%#018" PRIx64 "\t"
-	    "a2 =%#018" PRIx64 "\ta3 =%#018" PRIx64 "\n",
-	    istate->a0, istate->a1, istate->a2, istate->a3);
-	
-	printf("t0 =%#018" PRIx64 "\tt1 =%#018" PRIx64 "\t"
-	    "t2 =%#018" PRIx64 "\tt3 =%#018" PRIx64 "\n",
-	    istate->t0, istate->t1, istate->t2, istate->t3);
-	
-	printf("t4 =%#018" PRIx64 "\tt5 =%#018" PRIx64 "\t"
-	    "t6 =%#018" PRIx64 "\tt7 =%#018" PRIx64 "\n",
-	    istate->t4, istate->t5, istate->t6, istate->t7);
-	
-	printf("t8 =%#018" PRIx64 "\tt9 =%#018" PRIx64 "\t"
-	    "v0 =%#018" PRIx64 "\tv1 =%#018" PRIx64 "\n",
-	    istate->t8, istate->t9, istate->v0, istate->v1);
-	
-	printf("s0 =%#018" PRIx64 "\ts1 =%#018" PRIx64 "\t"
-	    "s2 =%#018" PRIx64 "\ts3 =%#018" PRIx64 "\n",
-	    istate->s0, istate->s1, istate->s2, istate->s3);
-	
-	printf("s4 =%#018" PRIx64 "\ts5 =%#018" PRIx64 "\t"
-	    "s6 =%#018" PRIx64 "\ts7 =%#018" PRIx64 "\n",
-	    istate->s4, istate->s5, istate->s6, istate->s7);
-	
-	printf("s8 =%#018" PRIx64 "\tat =%#018" PRIx64 "\t"
-	    "kt0=%#018" PRIx64 "\tkt1=%#018" PRIx64 "\n",
-	    istate->s8, istate->at, istate->kt0, istate->kt1);
-	
-	printf("sp =%#018" PRIx64 "\tra =%#018" PRIx64 "\t"
-	    "gp =%#018" PRIx64 "\n",
-	    istate->sp, istate->ra, istate->gp);
-}
-
-static void unhandled_exception(unsigned int n, istate_t *istate)
-{
-	fault_if_from_uspace(istate, "Unhandled exception %s.", exctable[n]);
-	panic_badtrap(istate, n, "Unhandled exception %s.", exctable[n]);
-}
-
-static void reserved_instr_exception(unsigned int n, istate_t *istate)
-{
-	if (*((uint32_t *) istate->epc) == 0x7c03e83b) {
-		ASSERT(THREAD);
-		istate->epc += 4;
-		istate->v1 = istate->kt1;
-	} else
-		unhandled_exception(n, istate);
-}
-
-static void breakpoint_exception(unsigned int n, istate_t *istate)
-{
-#ifdef CONFIG_DEBUG
-	debugger_bpoint(istate);
-#else
-	/* it is necessary to not re-execute BREAK instruction after 
-	   returning from Exception handler
-	   (see page 138 in R4000 Manual for more information) */
-	istate->epc += 4;
-#endif
-}
-
-static void tlbmod_exception(unsigned int n, istate_t *istate)
-{
-	tlb_modified(istate);
-}
-
-static void tlbinv_exception(unsigned int n, istate_t *istate)
-{
-	tlb_invalid(istate);
-}
-
-#ifdef CONFIG_FPU_LAZY
-static void cpuns_exception(unsigned int n, istate_t *istate)
-{
-	if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id)
-		scheduler_fpu_lazy_request();
-	else {
-		fault_if_from_uspace(istate,
-		    "Unhandled Coprocessor Unusable Exception.");
-		panic_badtrap(istate, n,
-		    "Unhandled Coprocessor Unusable Exception.");
-	}
-}
-#endif
-
-static void interrupt_exception(unsigned int n, istate_t *istate)
-{
-	/* Decode interrupt number and process the interrupt */
-	uint32_t cause = (cp0_cause_read() >> 8) & 0xff;
-	
-	unsigned int i;
-	for (i = 0; i < 8; i++) {
-		if (cause & (1 << i)) {
-			irq_t *irq = irq_dispatch_and_lock(i);
-			if (irq) {
-				/*
-				 * The IRQ handler was found.
-				 */
-				irq->handler(irq);
-				irq_spinlock_unlock(&irq->lock, false);
-			} else {
-				/*
-				 * Spurious interrupt.
-				 */
-#ifdef CONFIG_DEBUG
-				printf("cpu%u: spurious interrupt (inum=%u)\n",
-				    CPU->id, i);
-#endif
-			}
-		}
-	}
-}
-
-/** Handle syscall userspace call */
-static void syscall_exception(unsigned int n, istate_t *istate)
-{
-	fault_if_from_uspace(istate, "Syscall is handled through shortcut.");
-}
-
-void exception_init(void)
-{
-	unsigned int i;
-	
-	/* Clear exception table */
-	for (i = 0; i < IVT_ITEMS; i++)
-		exc_register(i, "undef", false,
-		    (iroutine_t) unhandled_exception);
-	
-	exc_register(EXC_Bp, "bkpoint", true,
-	    (iroutine_t) breakpoint_exception);
-	exc_register(EXC_RI, "resinstr", true,
-	    (iroutine_t) reserved_instr_exception);
-	exc_register(EXC_Mod, "tlb_mod", true,
-	    (iroutine_t) tlbmod_exception);
-	exc_register(EXC_TLBL, "tlbinvl", true,
-	    (iroutine_t) tlbinv_exception);
-	exc_register(EXC_TLBS, "tlbinvl", true,
-	    (iroutine_t) tlbinv_exception);
-	exc_register(EXC_Int, "interrupt", true,
-	    (iroutine_t) interrupt_exception);
-	
-#ifdef CONFIG_FPU_LAZY
-	exc_register(EXC_CpU, "cpunus", true,
-	    (iroutine_t) cpuns_exception);
-#endif
-	
-	exc_register(EXC_Sys, "syscall", true,
-	    (iroutine_t) syscall_exception);
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/fpu_context.c
===================================================================
--- kernel/arch/mips64/src/fpu_context.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../mips32/src/fpu_context.c
Index: rnel/arch/mips64/src/interrupt.c
===================================================================
--- kernel/arch/mips64/src/interrupt.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,189 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#include <interrupt.h>
-#include <arch/interrupt.h>
-#include <typedefs.h>
-#include <arch.h>
-#include <arch/cp0.h>
-#include <arch/smp/dorder.h>
-#include <time/clock.h>
-#include <ipc/sysipc.h>
-#include <ddi/device.h>
-
-#define IRQ_COUNT   8
-#define TIMER_IRQ   7
-#define DORDER_IRQ  5
-
-function virtual_timer_fnc = NULL;
-static irq_t timer_irq;
-static irq_t dorder_irq;
-
-// TODO: This is SMP unsafe!!!
-
-uint32_t count_hi = 0;
-static unsigned long nextcount;
-static unsigned long lastcount;
-
-/** Disable interrupts.
- *
- * @return Old interrupt priority level.
- */
-ipl_t interrupts_disable(void)
-{
-	ipl_t ipl = (ipl_t) cp0_status_read();
-	cp0_status_write(ipl & ~cp0_status_ie_enabled_bit);
-	return ipl;
-}
-
-/** Enable interrupts.
- *
- * @return Old interrupt priority level.
- */
-ipl_t interrupts_enable(void)
-{
-	ipl_t ipl = (ipl_t) cp0_status_read();
-	cp0_status_write(ipl | cp0_status_ie_enabled_bit);
-	return ipl;
-}
-
-/** Restore interrupt priority level.
- *
- * @param ipl Saved interrupt priority level.
- */
-void interrupts_restore(ipl_t ipl)
-{
-	cp0_status_write(cp0_status_read() | (ipl & cp0_status_ie_enabled_bit));
-}
-
-/** Read interrupt priority level.
- *
- * @return Current interrupt priority level.
- */
-ipl_t interrupts_read(void)
-{
-	return cp0_status_read();
-}
-
-/** Check interrupts state.
- *
- * @return True if interrupts are disabled.
- *
- */
-bool interrupts_disabled(void)
-{
-	return !(cp0_status_read() & cp0_status_ie_enabled_bit);
-}
-
-/** Start hardware clock
- *
- */
-static void timer_start(void)
-{
-	lastcount = cp0_count_read();
-	nextcount = cp0_compare_value + cp0_count_read();
-	cp0_compare_write(nextcount);
-}
-
-static irq_ownership_t timer_claim(irq_t *irq)
-{
-	return IRQ_ACCEPT;
-}
-
-static void timer_irq_handler(irq_t *irq)
-{
-	if (cp0_count_read() < lastcount)
-		/* Count overflow detected */
-		count_hi++;
-	
-	lastcount = cp0_count_read();
-	
-	unsigned long drift = cp0_count_read() - nextcount;
-	while (drift > cp0_compare_value) {
-		drift -= cp0_compare_value;
-		CPU->missed_clock_ticks++;
-	}
-	
-	nextcount = cp0_count_read() + cp0_compare_value - drift;
-	cp0_compare_write(nextcount);
-	
-	/*
-	 * We are holding a lock which prevents preemption.
-	 * Release the lock, call clock() and reacquire the lock again.
-	 */
-	irq_spinlock_unlock(&irq->lock, false);
-	clock();
-	irq_spinlock_lock(&irq->lock, false);
-	
-	if (virtual_timer_fnc != NULL)
-		virtual_timer_fnc();
-}
-
-static irq_ownership_t dorder_claim(irq_t *irq)
-{
-	return IRQ_ACCEPT;
-}
-
-static void dorder_irq_handler(irq_t *irq)
-{
-	dorder_ipi_ack(1 << dorder_cpuid());
-}
-
-/* Initialize basic tables for exception dispatching */
-void interrupt_init(void)
-{
-	irq_init(IRQ_COUNT, IRQ_COUNT);
-	
-	irq_initialize(&timer_irq);
-	timer_irq.devno = device_assign_devno();
-	timer_irq.inr = TIMER_IRQ;
-	timer_irq.claim = timer_claim;
-	timer_irq.handler = timer_irq_handler;
-	irq_register(&timer_irq);
-	
-	timer_start();
-	cp0_unmask_int(TIMER_IRQ);
-	
-	irq_initialize(&dorder_irq);
-	dorder_irq.devno = device_assign_devno();
-	dorder_irq.inr = DORDER_IRQ;
-	dorder_irq.claim = dorder_claim;
-	dorder_irq.handler = dorder_irq_handler;
-	irq_register(&dorder_irq);
-	
-	cp0_unmask_int(DORDER_IRQ);
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/mips64.c
===================================================================
--- kernel/arch/mips64/src/mips64.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,253 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64
- * @{
- */
-/** @file
- */
-
-#include <arch.h>
-#include <typedefs.h>
-#include <errno.h>
-#include <interrupt.h>
-#include <macros.h>
-#include <str.h>
-#include <memstr.h>
-#include <userspace.h>
-#include <console/console.h>
-#include <syscall/syscall.h>
-#include <sysinfo/sysinfo.h>
-#include <arch/debug.h>
-#include <arch/debugger.h>
-#ifdef MACHINE_msim
-#include <arch/drivers/msim.h>
-#endif
-#include <genarch/fb/fb.h>
-#include <genarch/drivers/dsrln/dsrlnin.h>
-#include <genarch/drivers/dsrln/dsrlnout.h>
-#include <genarch/srln/srln.h>
-
-/* Size of the code jumping to the exception handler code
- * - J+NOP
- */
-#define EXCEPTION_JUMP_SIZE  8
-
-#define TLB_EXC    ((char *) 0xffffffff80000000)
-#define NORM_EXC   ((char *) 0xffffffff80000180)
-#define CACHE_EXC  ((char *) 0xffffffff80000100)
-
-
-/* Why the linker moves the variable 64K away in assembler
- * when not in .text section?
- */
-
-/* Stack pointer saved when entering user mode */
-uintptr_t supervisor_sp __attribute__ ((section (".text")));
-
-size_t cpu_count = 0;
-
-/** Performs mips64-specific initialization before main_bsp() is called. */
-void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo)
-{
-	init.cnt = min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS);
-	
-	size_t i;
-	for (i = 0; i < init.cnt; i++) {
-		init.tasks[i].paddr = KA2PA(bootinfo->tasks[i].addr);
-		init.tasks[i].size = bootinfo->tasks[i].size;
-		str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
-		    bootinfo->tasks[i].name);
-	}
-	
-	for (i = 0; i < CPUMAP_MAX_RECORDS; i++) {
-		if ((bootinfo->cpumap & (1 << i)) != 0)
-			cpu_count++;
-	}
-}
-
-void arch_pre_mm_init(void)
-{
-	/* It is not assumed by default */
-	interrupts_disable();
-	
-	/* Initialize dispatch table */
-	exception_init();
-
-	/* Copy the exception vectors to the right places */
-	memcpy(TLB_EXC, (char *) tlb_refill_entry, EXCEPTION_JUMP_SIZE);
-	smc_coherence_block(TLB_EXC, EXCEPTION_JUMP_SIZE);
-	memcpy(NORM_EXC, (char *) exception_entry, EXCEPTION_JUMP_SIZE);
-	smc_coherence_block(NORM_EXC, EXCEPTION_JUMP_SIZE);
-	memcpy(CACHE_EXC, (char *) cache_error_entry, EXCEPTION_JUMP_SIZE);
-	smc_coherence_block(CACHE_EXC, EXCEPTION_JUMP_SIZE);
-	
-	/*
-	 * Switch to BEV normal level so that exception vectors point to the
-	 * kernel. Clear the error level.
-	 */
-	cp0_status_write(cp0_status_read() &
-	    ~(cp0_status_bev_bootstrap_bit | cp0_status_erl_error_bit));
-	
-	/*
-	 * Mask all interrupts
-	 */
-	cp0_mask_all_int();
-	
-	debugger_init();
-}
-
-void arch_post_mm_init(void)
-{
-	interrupt_init();
-	
-#ifdef CONFIG_MSIM_PRN
-	outdev_t *dsrlndev = dsrlnout_init((ioport8_t *) MSIM_KBD_ADDRESS);
-	if (dsrlndev)
-		stdout_wire(dsrlndev);
-#endif
-}
-
-void arch_post_cpu_init(void)
-{
-}
-
-void arch_pre_smp_init(void)
-{
-}
-
-void arch_post_smp_init(void)
-{
-	static const char *platform;
-	
-	/* Set platform name. */
-#ifdef MACHINE_msim
-	platform = "msim";
-#endif
-	sysinfo_set_item_data("platform", NULL, (void *) platform,
-	    str_size(platform));
-	
-#ifdef CONFIG_MSIM_KBD
-	/*
-	 * Initialize the msim keyboard port. Then initialize the serial line
-	 * module and connect it to the msim keyboard. Enable keyboard
-	 * interrupts.
-	 */
-	dsrlnin_instance_t *dsrlnin_instance
-	    = dsrlnin_init((dsrlnin_t *) MSIM_KBD_ADDRESS, MSIM_KBD_IRQ);
-	if (dsrlnin_instance) {
-		srln_instance_t *srln_instance = srln_init();
-		if (srln_instance) {
-			indev_t *sink = stdin_wire();
-			indev_t *srln = srln_wire(srln_instance, sink);
-			dsrlnin_wire(dsrlnin_instance, srln);
-			cp0_unmask_int(MSIM_KBD_IRQ);
-		}
-	}
-	
-	/*
-	 * This is the necessary evil until the userspace driver is entirely
-	 * self-sufficient.
-	 */
-	sysinfo_set_item_val("kbd", NULL, true);
-	sysinfo_set_item_val("kbd.inr", NULL, MSIM_KBD_IRQ);
-	sysinfo_set_item_val("kbd.address.virtual", NULL, MSIM_KBD_ADDRESS);
-#endif
-}
-
-void calibrate_delay_loop(void)
-{
-}
-
-void userspace(uspace_arg_t *kernel_uarg)
-{
-	/* EXL = 1, UM = 1, IE = 1 */
-	cp0_status_write(cp0_status_read() | (cp0_status_exl_exception_bit |
-	    cp0_status_um_bit | cp0_status_ie_enabled_bit));
-	cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry);
-	userspace_asm(((uintptr_t) kernel_uarg->uspace_stack +
-	    kernel_uarg->uspace_stack_size),
-	    (uintptr_t) kernel_uarg->uspace_uarg,
-	    (uintptr_t) kernel_uarg->uspace_entry);
-	
-	while (1);
-}
-
-/** Perform mips64 specific tasks needed before the new task is run. */
-void before_task_runs_arch(void)
-{
-}
-
-/** Perform mips64 specific tasks needed before the new thread is scheduled. */
-void before_thread_runs_arch(void)
-{
-	supervisor_sp =
-	    (uintptr_t) &THREAD->kstack[STACK_SIZE];
-}
-
-void after_thread_ran_arch(void)
-{
-}
-
-/** Set thread-local-storage pointer
- *
- * We have it currently in K1, it is
- * possible to have it separately in the future.
- */
-sysarg_t sys_tls_set(uintptr_t addr)
-{
-	return EOK;
-}
-
-void arch_reboot(void)
-{
-	___halt();
-	while (1);
-}
-
-/** Construct function pointer
- *
- * @param fptr   function pointer structure
- * @param addr   function address
- * @param caller calling function address
- *
- * @return address of the function pointer
- *
- */
-void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller)
-{
-	return addr;
-}
-
-void irq_initialize_arch(irq_t *irq)
-{
-	(void) irq;
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/mm/as.c
===================================================================
--- kernel/arch/mips64/src/mm/as.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,70 +1,0 @@
-/*
- * Copyright (c) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#include <arch/mm/as.h>
-#include <genarch/mm/as_ht.h>
-#include <genarch/mm/page_ht.h>
-#include <genarch/mm/asid_fifo.h>
-#include <arch/mm/tlb.h>
-#include <mm/tlb.h>
-#include <mm/as.h>
-#include <arch/cp0.h>
-
-/** Architecture dependent address space init. */
-void as_arch_init(void)
-{
-	as_operations = &as_ht_operations;
-	asid_fifo_init();
-}
-
-/** Install address space.
- *
- * Install ASID.
- *
- * @param as Address space structure.
- *
- */
-void as_install_arch(as_t *as)
-{
-	/*
-	 * Install ASID.
-	 */
-	entry_hi_t hi;
-	hi.value = cp0_entry_hi_read();
-	hi.asid = as->asid;
-	cp0_entry_hi_write(hi.value);
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/mm/frame.c
===================================================================
--- kernel/arch/mips64/src/mm/frame.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,261 +1,0 @@
-/*
- * Copyright (c) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#include <macros.h>
-#include <arch/mm/frame.h>
-#include <arch/mm/tlb.h>
-#include <interrupt.h>
-#include <mm/frame.h>
-#include <mm/asid.h>
-#include <config.h>
-#ifdef MACHINE_msim
-#include <arch/drivers/msim.h>
-#endif
-#include <print.h>
-
-#define ZERO_PAGE_MASK    TLB_PAGE_MASK_256K
-#define ZERO_FRAMES       2048
-#define ZERO_PAGE_WIDTH   18  /* 256K */
-#define ZERO_PAGE_SIZE    (1 << ZERO_PAGE_WIDTH)
-#define ZERO_PAGE_ASID    ASID_INVALID
-#define ZERO_PAGE_TLBI    0
-#define ZERO_PAGE_ADDR    0
-#define ZERO_PAGE_OFFSET  (ZERO_PAGE_SIZE / sizeof(uint32_t) - 1)
-#define ZERO_PAGE_VALUE   (((volatile uint32_t *) ZERO_PAGE_ADDR)[ZERO_PAGE_OFFSET])
-
-#define ZERO_PAGE_VALUE_KSEG1(frame) \
-	(((volatile uint32_t *) (0xa0000000 + (frame << ZERO_PAGE_WIDTH)))[ZERO_PAGE_OFFSET])
-
-#define MAX_REGIONS  32
-
-typedef struct {
-	pfn_t start;
-	pfn_t count;
-} phys_region_t;
-
-static size_t phys_regions_count = 0;
-static phys_region_t phys_regions[MAX_REGIONS];
-
-/** Check whether frame is available
- *
- * Returns true if given frame is generally available for use.
- * Returns false if given frame is used for physical memory
- * mapped devices and cannot be used.
- *
- */
-static bool frame_available(pfn_t frame)
-{
-#ifdef MACHINE_msim
-	/* MSIM device (dprinter) */
-	if (frame == (KA2PA(MSIM_VIDEORAM) >> ZERO_PAGE_WIDTH))
-		return false;
-	
-	/* MSIM device (dkeyboard) */
-	if (frame == (KA2PA(MSIM_KBD_ADDRESS) >> ZERO_PAGE_WIDTH))
-		return false;
-#endif
-	
-	return true;
-}
-
-/** Check whether frame is safe to write
- *
- * Returns true if given frame is safe for read/write test.
- * Returns false if given frame should not be touched.
- *
- */
-static bool frame_safe(pfn_t frame)
-{
-	/* Kernel structures */
-	if ((frame << ZERO_PAGE_WIDTH) < KA2PA(config.base))
-		return false;
-	
-	/* Kernel */
-	if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
-	    KA2PA(config.base), config.kernel_size))
-		return false;
-	
-	/* Kernel stack */
-	if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
-	    KA2PA(config.stack_base), config.stack_size))
-		return false;
-	
-	/* Init tasks */
-	bool safe = true;
-	size_t i;
-	for (i = 0; i < init.cnt; i++)
-		if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
-		    init.tasks[i].paddr, init.tasks[i].size)) {
-			safe = false;
-			break;
-		}
-	
-	return safe;
-}
-
-static void frame_add_region(pfn_t start_frame, pfn_t end_frame, bool low)
-{
-	if (end_frame <= start_frame)
-		return;
-
-	uintptr_t base = start_frame << ZERO_PAGE_WIDTH;
-	size_t size = (end_frame - start_frame) << ZERO_PAGE_WIDTH;
-
-	if (!frame_adjust_zone_bounds(low, &base, &size))
-		return; 
-
-	pfn_t first = ADDR2PFN(base);
-	size_t count = SIZE2FRAMES(size);
-	pfn_t conf_frame;
-
-	if (low) {
-		/* Interrupt vector frame is blacklisted */
-		if (first == 0)
-			conf_frame = 1;
-		else
-			conf_frame = first;
-		zone_create(first, count, conf_frame,
-		    ZONE_AVAILABLE | ZONE_LOWMEM);
-	} else {
-		conf_frame = zone_external_conf_alloc(count);
-		if (conf_frame != 0)
-			zone_create(first, count, conf_frame,
-			    ZONE_AVAILABLE | ZONE_HIGHMEM);
-	}
-	
-	if (phys_regions_count < MAX_REGIONS) {
-		phys_regions[phys_regions_count].start = first;
-		phys_regions[phys_regions_count].count = count;
-		phys_regions_count++;
-	}
-}
-
-/** Create memory zones
- *
- * Walk through available 256 KB chunks of physical
- * memory and create zones.
- *
- * Note: It is assumed that the TLB is not yet being
- * used in any way, thus there is no interference.
- *
- */
-void frame_low_arch_init(void)
-{
-	ipl_t ipl = interrupts_disable();
-	
-	/* Clear and initialize TLB */
-	cp0_pagemask_write(ZERO_PAGE_MASK);
-	cp0_entry_lo0_write(0);
-	cp0_entry_lo1_write(0);
-	cp0_entry_hi_write(0);
-	
-	for (size_t i = 0; i < TLB_ENTRY_COUNT; i++) {
-		cp0_index_write(i);
-		tlbwi();
-	}
-	
-	pfn_t start_frame = 0;
-	pfn_t frame;
-	bool avail = true;
-	
-	/* Walk through all 1 MB frames */
-	for (frame = 0; frame < ZERO_FRAMES; frame++) {
-		if (!frame_available(frame))
-			avail = false;
-		else {
-			if (frame_safe(frame)) {
-				entry_lo_t lo0;
-				entry_lo_t lo1;
-				entry_hi_t hi;
-				tlb_prepare_entry_lo(&lo0, false, true, true, false, frame << (ZERO_PAGE_WIDTH - 12));
-				tlb_prepare_entry_lo(&lo1, false, false, false, false, 0);
-				tlb_prepare_entry_hi(&hi, ZERO_PAGE_ASID, ZERO_PAGE_ADDR);
-				
-				cp0_pagemask_write(ZERO_PAGE_MASK);
-				cp0_entry_lo0_write(lo0.value);
-				cp0_entry_lo1_write(lo1.value);
-				cp0_entry_hi_write(hi.value);
-				cp0_index_write(ZERO_PAGE_TLBI);
-				tlbwi();
-				
-				ZERO_PAGE_VALUE = 0;
-				if (ZERO_PAGE_VALUE != 0)
-					avail = false;
-				else {
-					ZERO_PAGE_VALUE = 0xdeadbeef;
-					if (ZERO_PAGE_VALUE != 0xdeadbeef)
-						avail = false;
-				}
-			}
-		}
-		
-		if (!avail) {
-			frame_add_region(start_frame, frame, true);
-			start_frame = frame + 1;
-			avail = true;
-		}
-	}
-	
-	frame_add_region(start_frame, frame, true);
-	
-	/* Blacklist interrupt vector frame */
-	frame_mark_unavailable(0, 1);
-	
-	/* Cleanup */
-	cp0_pagemask_write(ZERO_PAGE_MASK);
-	cp0_entry_lo0_write(0);
-	cp0_entry_lo1_write(0);
-	cp0_entry_hi_write(0);
-	cp0_index_write(ZERO_PAGE_TLBI);
-	tlbwi();
-	
-	interrupts_restore(ipl);
-}
-
-void frame_high_arch_init(void)
-{
-}
-
-void physmem_print(void)
-{
-	printf("[base            ] [size            ]\n");
-	
-	for (size_t i = 0; i < phys_regions_count; i++) {
-		printf("%#018lx %18lu\n", PFN2ADDR(phys_regions[i].start),
-		    PFN2ADDR(phys_regions[i].count));
-	}
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/mm/km.c
===================================================================
--- kernel/arch/mips64/src/mm/km.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Copyright (c) 2011 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-
-#include <arch/mm/km.h>
-#include <typedefs.h>
-
-void km_identity_arch_init(void)
-{
-}
-
-void km_non_identity_arch_init(void)
-{
-}
-
-bool km_is_non_identity_arch(uintptr_t addr)
-{
-	return false;
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/mm/page.c
===================================================================
--- kernel/arch/mips64/src/mm/page.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#include <arch/mm/page.h>
-#include <genarch/mm/page_ht.h>
-#include <mm/page.h>
-#include <mm/frame.h>
-
-void page_arch_init(void)
-{
-	page_mapping_operations = &ht_mapping_operations;
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/mm/tlb.c
===================================================================
--- kernel/arch/mips64/src/mm/tlb.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,455 +1,0 @@
-/*
- * Copyright (c) 2003-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup mips64mm
- * @{
- */
-/** @file
- */
-
-#include <arch/mm/tlb.h>
-#include <mm/asid.h>
-#include <mm/tlb.h>
-#include <mm/page.h>
-#include <mm/as.h>
-#include <arch/cp0.h>
-#include <panic.h>
-#include <arch.h>
-#include <synch/mutex.h>
-#include <print.h>
-#include <debug.h>
-#include <align.h>
-#include <interrupt.h>
-#include <symtab.h>
-
-/** Initialize TLB.
- *
- * Invalidate all entries and mark wired entries.
- *
- */
-void tlb_arch_init(void)
-{
-	cp0_pagemask_write(TLB_PAGE_MASK_16K);
-	cp0_entry_hi_write(0);
-	cp0_entry_lo0_write(0);
-	cp0_entry_lo1_write(0);
-	
-	/* Clear and initialize TLB. */
-	
-	for (unsigned int i = 0; i < TLB_ENTRY_COUNT; i++) {
-		cp0_index_write(i);
-		tlbwi();
-	}
-	
-	/*
-	 * The kernel is going to make use of some wired
-	 * entries (e.g. mapping kernel stacks in kseg3).
-	 */
-	cp0_wired_write(TLB_WIRED);
-}
-
-/** Try to find PTE for faulting address.
- *
- * @param badvaddr Faulting virtual address.
- * @param access   Access mode that caused the fault.
- * @param istate   Pointer to interrupted state.
- *
- * @return PTE on success, NULL otherwise.
- *
- */
-static pte_t *find_mapping_and_check(uintptr_t badvaddr, int access,
-    istate_t *istate)
-{
-	entry_hi_t hi;
-	hi.value = cp0_entry_hi_read();
-	
-	ASSERT(hi.asid == AS->asid);
-	
-	/*
-	 * Check if the mapping exists in page tables.
-	 */
-	pte_t *pte = page_mapping_find(AS, badvaddr, true);
-	if ((pte) && (pte->p) && ((pte->w) || (access != PF_ACCESS_WRITE))) {
-		/*
-		 * Mapping found in page tables.
-		 * Immediately succeed.
-		 */
-		return pte;
-	}
-
-	/*
-	 * Mapping not found in page tables.
-	 * Resort to higher-level page fault handler.
-	 */
-	if (as_page_fault(badvaddr, access, istate) == AS_PF_OK) {
-		/*
-		 * The higher-level page fault handler succeeded,
-		 * The mapping ought to be in place.
-		 */
-		pte = page_mapping_find(AS, badvaddr, true);
-		ASSERT(pte);
-		ASSERT(pte->p);
-		ASSERT((pte->w) || (access != PF_ACCESS_WRITE));
-		return pte;
-	}
-
-	return NULL;
-}
-
-void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d,
-    bool c, uintptr_t addr)
-{
-	lo->value = 0;
-	lo->g = g;
-	lo->v = v;
-	lo->d = d;
-	lo->c = c ? PAGE_CACHEABLE_EXC_WRITE : PAGE_UNCACHED;
-	lo->pfn = ADDR2PFN(addr);
-}
-
-void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr)
-{
-	hi->value = ALIGN_DOWN(addr, PAGE_SIZE * 2);
-	hi->asid = asid;
-}
-
-/** Process TLB Refill Exception.
- *
- * @param istate Interrupted register context.
- *
- */
-void tlb_refill(istate_t *istate)
-{
-	uintptr_t badvaddr = cp0_badvaddr_read();
-	
-	mutex_lock(&AS->lock);
-	asid_t asid = AS->asid;
-	mutex_unlock(&AS->lock);
-	
-	pte_t *pte = find_mapping_and_check(badvaddr, PF_ACCESS_READ, istate);
-	if (pte) {
-		/*
-		 * Record access to PTE.
-		 */
-		pte->a = 1;
-	
-		entry_lo_t lo;
-		entry_hi_t hi;
-	
-		tlb_prepare_entry_hi(&hi, asid, badvaddr);
-		tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->c,
-		    pte->frame);
-	
-		/*
-		 * New entry is to be inserted into TLB
-		 */
-		cp0_entry_hi_write(hi.value);
-	
-		if ((badvaddr / PAGE_SIZE) % 2 == 0) {
-			cp0_entry_lo0_write(lo.value);
-			cp0_entry_lo1_write(0);
-		} else {
-			cp0_entry_lo0_write(0);
-			cp0_entry_lo1_write(lo.value);
-		}
-	
-		cp0_pagemask_write(TLB_PAGE_MASK_16K);
-		tlbwr();
-	}
-}
-
-/** Process TLB Invalid Exception.
- *
- * @param istate Interrupted register context.
- *
- */
-void tlb_invalid(istate_t *istate)
-{
-	uintptr_t badvaddr = cp0_badvaddr_read();
-	
-	/*
-	 * Locate the faulting entry in TLB.
-	 */
-	entry_hi_t hi;
-	hi.value = cp0_entry_hi_read();
-	
-	tlb_prepare_entry_hi(&hi, hi.asid, badvaddr);
-	cp0_entry_hi_write(hi.value);
-	tlbp();
-	
-	tlb_index_t index;
-	index.value = cp0_index_read();
-	
-	ASSERT(!index.p);
-	
-	pte_t *pte = find_mapping_and_check(badvaddr, PF_ACCESS_READ, istate);
-	if (pte) {
-		/*
-		 * Read the faulting TLB entry.
-		 */
-		tlbr();
-	
-		/*
-		 * Record access to PTE.
-		 */
-		pte->a = 1;
-
-		entry_lo_t lo;
-		tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->c,
-		    pte->frame);
-	
-		/*
-		 * The entry is to be updated in TLB.
-		 */
-		if ((badvaddr / PAGE_SIZE) % 2 == 0)
-			cp0_entry_lo0_write(lo.value);
-		else
-			cp0_entry_lo1_write(lo.value);
-	
-		cp0_pagemask_write(TLB_PAGE_MASK_16K);
-		tlbwi();
-	}
-	
-}
-
-/** Process TLB Modified Exception.
- *
- * @param istate Interrupted register context.
- *
- */
-void tlb_modified(istate_t *istate)
-{
-	uintptr_t badvaddr = cp0_badvaddr_read();
-	
-	/*
-	 * Locate the faulting entry in TLB.
-	 */
-	entry_hi_t hi;
-	hi.value = cp0_entry_hi_read();
-	
-	tlb_prepare_entry_hi(&hi, hi.asid, badvaddr);
-	cp0_entry_hi_write(hi.value);
-	tlbp();
-	
-	tlb_index_t index;
-	index.value = cp0_index_read();
-	
-	ASSERT(!index.p);
-	
-	pte_t *pte = find_mapping_and_check(badvaddr, PF_ACCESS_WRITE, istate);
-	if (pte) {
-		/*
-		 * Read the faulting TLB entry.
-		 */
-		tlbr();
-	
-		/*
-		 * Record access and write to PTE.
-		 */
-		pte->a = 1;
-		pte->d = 1;
-	
-		entry_lo_t lo;
-		tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->w, pte->c,
-		    pte->frame);
-	
-		/*
-		 * The entry is to be updated in TLB.
-		 */
-		if ((badvaddr / PAGE_SIZE) % 2 == 0)
-			cp0_entry_lo0_write(lo.value);
-		else
-			cp0_entry_lo1_write(lo.value);
-	
-		cp0_pagemask_write(TLB_PAGE_MASK_16K);
-		tlbwi();
-	}
-}
-
-/** Print contents of TLB. */
-void tlb_print(void)
-{
-	entry_hi_t hi_save;
-	hi_save.value = cp0_entry_hi_read();
-	
-	printf("[nr] [asid] [vpn2] [mask] [gvdc] [pfn ]\n");
-	
-	for (unsigned int i = 0; i < TLB_ENTRY_COUNT; i++) {
-		cp0_index_write(i);
-		tlbr();
-		
-		page_mask_t mask;
-		mask.value = cp0_pagemask_read();
-		
-		entry_hi_t hi;
-		hi.value = cp0_entry_hi_read();
-		
-		entry_lo_t lo0;
-		lo0.value = cp0_entry_lo0_read();
-		
-		entry_lo_t lo1;
-		lo1.value = cp0_entry_lo1_read();
-		
-		printf("%-4u %-6u %#6x %#6x  %1u%1u%1u%1u  %#6x\n",
-		    i, hi.asid, hi.vpn2, mask.mask,
-		    lo0.g, lo0.v, lo0.d, lo0.c, lo0.pfn);
-		printf("                           %1u%1u%1u%1u  %#6x\n",
-		    lo1.g, lo1.v, lo1.d, lo1.c, lo1.pfn);
-	}
-	
-	cp0_entry_hi_write(hi_save.value);
-}
-
-/** Invalidate all not wired TLB entries. */
-void tlb_invalidate_all(void)
-{
-	entry_hi_t hi_save;
-	hi_save.value = cp0_entry_hi_read();
-	ipl_t ipl = interrupts_disable();
-	
-	for (unsigned int i = TLB_WIRED; i < TLB_ENTRY_COUNT; i++) {
-		cp0_index_write(i);
-		tlbr();
-		
-		entry_lo_t lo0;
-		lo0.value = cp0_entry_lo0_read();
-		
-		entry_lo_t lo1;
-		lo1.value = cp0_entry_lo1_read();
-		
-		lo0.v = 0;
-		lo1.v = 0;
-		
-		cp0_entry_lo0_write(lo0.value);
-		cp0_entry_lo1_write(lo1.value);
-		
-		tlbwi();
-	}
-	
-	interrupts_restore(ipl);
-	cp0_entry_hi_write(hi_save.value);
-}
-
-/** Invalidate all TLB entries belonging to specified address space.
- *
- * @param asid Address space identifier.
- *
- */
-void tlb_invalidate_asid(asid_t asid)
-{
-	ASSERT(asid != ASID_INVALID);
-	
-	entry_hi_t hi_save;
-	hi_save.value = cp0_entry_hi_read();
-	ipl_t ipl = interrupts_disable();
-	
-	for (unsigned int i = 0; i < TLB_ENTRY_COUNT; i++) {
-		cp0_index_write(i);
-		tlbr();
-		
-		entry_hi_t hi;
-		hi.value = cp0_entry_hi_read();
-		
-		if (hi.asid == asid) {
-			entry_lo_t lo0;
-			lo0.value = cp0_entry_lo0_read();
-			
-			entry_lo_t lo1;
-			lo1.value = cp0_entry_lo1_read();
-			
-			lo0.v = 0;
-			lo1.v = 0;
-			
-			cp0_entry_lo0_write(lo0.value);
-			cp0_entry_lo1_write(lo1.value);
-			
-			tlbwi();
-		}
-	}
-	
-	interrupts_restore(ipl);
-	cp0_entry_hi_write(hi_save.value);
-}
-
-/** Invalidate TLB entries for specified page range belonging to specified
- * address space.
- *
- * @param asid Address space identifier.
- * @param page First page whose TLB entry is to be invalidated.
- * @param cnt  Number of entries to invalidate.
- *
- */
-void tlb_invalidate_pages(asid_t asid, uintptr_t page, size_t cnt)
-{
-	if (asid == ASID_INVALID)
-		return;
-	
-	entry_hi_t hi_save;
-	hi_save.value = cp0_entry_hi_read();
-	ipl_t ipl = interrupts_disable();
-	
-	for (unsigned int i = 0; i < cnt + 1; i += 2) {
-		entry_hi_t hi;
-		hi.value = 0;
-		tlb_prepare_entry_hi(&hi, asid, page + i * PAGE_SIZE);
-		cp0_entry_hi_write(hi.value);
-		
-		tlbp();
-		
-		tlb_index_t index;
-		index.value = cp0_index_read();
-		
-		if (!index.p) {
-			/*
-			 * Entry was found, index register contains valid
-			 * index.
-			 */
-			tlbr();
-			
-			entry_lo_t lo0;
-			lo0.value = cp0_entry_lo0_read();
-			
-			entry_lo_t lo1;
-			lo1.value = cp0_entry_lo1_read();
-			
-			lo0.v = 0;
-			lo1.v = 0;
-			
-			cp0_entry_lo0_write(lo0.value);
-			cp0_entry_lo1_write(lo1.value);
-			
-			tlbwi();
-		}
-	}
-	
-	interrupts_restore(ipl);
-	cp0_entry_hi_write(hi_save.value);
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/smp/dorder.c
===================================================================
--- kernel/arch/mips64/src/smp/dorder.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*
- * Copyright (c) 2007 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 mips64
- * @{
- */
-/** @file
- */
-
-#include <typedefs.h>
-#include <smp/ipi.h>
-#include <arch/smp/dorder.h>
-
-#define MSIM_DORDER_ADDRESS  0xffffffffb0000100
-
-#ifdef CONFIG_SMP
-
-void ipi_broadcast_arch(int ipi)
-{
-	*((volatile uint32_t *) MSIM_DORDER_ADDRESS) = 0x7fffffff;
-}
-
-#endif
-
-uint32_t dorder_cpuid(void)
-{
-	return *((volatile uint32_t *) MSIM_DORDER_ADDRESS);
-}
-
-void dorder_ipi_ack(uint32_t mask)
-{
-	*((volatile uint32_t *) (MSIM_DORDER_ADDRESS + 4)) = mask;
-}
-
-/** @}
- */
Index: rnel/arch/mips64/src/smp/smp.c
===================================================================
--- kernel/arch/mips64/src/smp/smp.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,53 +1,0 @@
-/*
- * Copyright (c) 2009 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 mips64
- * @{
- */
-/** @file
- */
-
-#include <config.h>
-#include <smp/smp.h>
-#include <arch/arch.h>
-
-#ifdef CONFIG_SMP
-
-void smp_init(void)
-{
-	config.cpu_count = cpu_count;
-}
-
-void kmp(void *arg __attribute__((unused)))
-{
-}
-
-#endif /* CONFIG_SMP */
-
-/** @}
- */
Index: rnel/arch/mips64/src/start.S
===================================================================
--- kernel/arch/mips64/src/start.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,392 +1,0 @@
-#
-# Copyright (c) 2003-2004 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-#include <arch/asm/regname.h>
-#include <arch/mm/page.h>
-#include <arch/asm/boot.h>
-#include <arch/context_offset.h>
-#include <arch/stack.h>
-
-.text
-
-.set noat
-.set noreorder
-.set nomacro
-
-.global kernel_image_start
-.global tlb_refill_entry
-.global cache_error_entry
-.global exception_entry
-.global userspace_asm
-
-/*
- * Which status bits are thread-local:
- * KSU(UM), EXL, ERL, IE
- */
-#define REG_SAVE_MASK 0x1f
-
-#define ISTATE_OFFSET_A0         0
-#define ISTATE_OFFSET_A1         8
-#define ISTATE_OFFSET_A2         16
-#define ISTATE_OFFSET_A3         24
-#define ISTATE_OFFSET_T0         32
-#define ISTATE_OFFSET_T1         40
-#define ISTATE_OFFSET_V0         48
-#define ISTATE_OFFSET_V1         56
-#define ISTATE_OFFSET_AT         64
-#define ISTATE_OFFSET_T2         72
-#define ISTATE_OFFSET_T3         80
-#define ISTATE_OFFSET_T4         88
-#define ISTATE_OFFSET_T5         96
-#define ISTATE_OFFSET_T6         104
-#define ISTATE_OFFSET_T7         112
-#define ISTATE_OFFSET_S0         120
-#define ISTATE_OFFSET_S1         128
-#define ISTATE_OFFSET_S2         136
-#define ISTATE_OFFSET_S3         144
-#define ISTATE_OFFSET_S4         152
-#define ISTATE_OFFSET_S5         160
-#define ISTATE_OFFSET_S6         168
-#define ISTATE_OFFSET_S7         176
-#define ISTATE_OFFSET_T8         184
-#define ISTATE_OFFSET_T9         192
-#define ISTATE_OFFSET_KT0        200
-#define ISTATE_OFFSET_KT1        208
-#define ISTATE_OFFSET_GP         216
-#define ISTATE_OFFSET_SP         224
-#define ISTATE_OFFSET_S8         232
-#define ISTATE_OFFSET_RA         240
-#define ISTATE_OFFSET_LO         248
-#define ISTATE_OFFSET_HI         252
-#define ISTATE_OFFSET_STATUS     256
-#define ISTATE_OFFSET_EPC        264
-#define ISTATE_OFFSET_ALIGNMENT  272
-
-#define ISTATE_SOFT_SIZE         280
-
-/*
- * The fake ABI prologue is never executed and may not be part of the
- * procedure's body. Instead, it should be immediately preceding the procedure's
- * body. Its only purpose is to trick the stack trace walker into thinking that
- * the exception is more or less just a normal function call.
- */
-.macro FAKE_ABI_PROLOGUE
-	sub $sp, ISTATE_SOFT_SIZE
-	sd $ra, ISTATE_OFFSET_EPC($sp)
-.endm
-
-/*
- * Save registers to space defined by \r
- * We will change status: Disable ERL, EXL, UM, IE
- * These changes will be automatically reversed in REGISTER_LOAD
- * %sp is NOT saved as part of these registers
- */
-.macro REGISTERS_STORE_AND_EXC_RESET r
-	sd $at, ISTATE_OFFSET_AT(\r)
-	sd $v0, ISTATE_OFFSET_V0(\r)
-	sd $v1, ISTATE_OFFSET_V1(\r)
-	sd $a0, ISTATE_OFFSET_A0(\r)
-	sd $a1, ISTATE_OFFSET_A1(\r)
-	sd $a2, ISTATE_OFFSET_A2(\r)
-	sd $a3, ISTATE_OFFSET_A3(\r)
-	sd $t0, ISTATE_OFFSET_T0(\r)
-	sd $t1, ISTATE_OFFSET_T1(\r)
-	sd $t2, ISTATE_OFFSET_T2(\r)
-	sd $t3, ISTATE_OFFSET_T3(\r)
-	sd $t4, ISTATE_OFFSET_T4(\r)
-	sd $t5, ISTATE_OFFSET_T5(\r)
-	sd $t6, ISTATE_OFFSET_T6(\r)
-	sd $t7, ISTATE_OFFSET_T7(\r)
-	sd $t8, ISTATE_OFFSET_T8(\r)
-	sd $t9, ISTATE_OFFSET_T9(\r)
-	sd $s0, ISTATE_OFFSET_S0(\r)
-	sd $s1, ISTATE_OFFSET_S1(\r)
-	sd $s2, ISTATE_OFFSET_S2(\r)
-	sd $s3, ISTATE_OFFSET_S3(\r)
-	sd $s4, ISTATE_OFFSET_S4(\r)
-	sd $s5, ISTATE_OFFSET_S5(\r)
-	sd $s6, ISTATE_OFFSET_S6(\r)
-	sd $s7, ISTATE_OFFSET_S7(\r)
-	sd $s8, ISTATE_OFFSET_S8(\r)
-	
-	mflo $at
-	sw $at, ISTATE_OFFSET_LO(\r)
-	mfhi $at
-	sw $at, ISTATE_OFFSET_HI(\r)
-	
-	sd $gp, ISTATE_OFFSET_GP(\r)
-	sd $ra, ISTATE_OFFSET_RA(\r)
-	sd $k0, ISTATE_OFFSET_KT0(\r)
-	sd $k1, ISTATE_OFFSET_KT1(\r)
-	
-	dmfc0 $t0, $status
-	dmfc0 $t1, $epc
-	
-	/* save only KSU, EXL, ERL, IE */
-	and $t2, $t0, REG_SAVE_MASK
-	
-	/* clear KSU, EXL, ERL, IE */
-	li $t3, ~(REG_SAVE_MASK)
-	and $t0, $t0, $t3
-	
-	sd $t2, ISTATE_OFFSET_STATUS(\r)
-	sd $t1, ISTATE_OFFSET_EPC(\r)
-	dmtc0 $t0, $status
-.endm
-
-.macro REGISTERS_LOAD r
-	/*
-	 * Update only UM, EXR, IE from status, the rest
-	 * is controlled by OS and not bound to task.
-	 */
-	dmfc0 $t0, $status
-	ld $t1, ISTATE_OFFSET_STATUS(\r)
-	
-	/* mask UM, EXL, ERL, IE */
-	li $t2, ~REG_SAVE_MASK
-	and $t0, $t0, $t2
-	
-	/* copy UM, EXL, ERL, IE from saved status */
-	or $t0, $t0, $t1
-	dmtc0 $t0, $status
-	
-	ld $v0, ISTATE_OFFSET_V0(\r)
-	ld $v1, ISTATE_OFFSET_V1(\r)
-	ld $a0, ISTATE_OFFSET_A0(\r)
-	ld $a1, ISTATE_OFFSET_A1(\r)
-	ld $a2, ISTATE_OFFSET_A2(\r)
-	ld $a3, ISTATE_OFFSET_A3(\r)
-	ld $t0, ISTATE_OFFSET_T0(\r)
-	ld $t1, ISTATE_OFFSET_T1(\r)
-	ld $t2, ISTATE_OFFSET_T2(\r)
-	ld $t3, ISTATE_OFFSET_T3(\r)
-	ld $t4, ISTATE_OFFSET_T4(\r)
-	ld $t5, ISTATE_OFFSET_T5(\r)
-	ld $t6, ISTATE_OFFSET_T6(\r)
-	ld $t7, ISTATE_OFFSET_T7(\r)
-	ld $t8, ISTATE_OFFSET_T8(\r)
-	ld $t9, ISTATE_OFFSET_T9(\r)
-	
-	ld $gp, ISTATE_OFFSET_GP(\r)
-	ld $ra, ISTATE_OFFSET_RA(\r)
-	ld $k1, ISTATE_OFFSET_KT1(\r)
-	
-	lw $at, ISTATE_OFFSET_LO(\r)
-	mtlo $at
-	lw $at, ISTATE_OFFSET_HI(\r)
-	mthi $at
-	
-	ld $at, ISTATE_OFFSET_EPC(\r)
-	dmtc0 $at, $epc
-	
-	ld $at, ISTATE_OFFSET_AT(\r)
-	ld $sp, ISTATE_OFFSET_SP(\r)
-.endm
-
-/*
- * Move kernel stack pointer address to register $k0.
- * If we are in user mode, load the appropriate stack address.
- */
-.macro KERNEL_STACK_TO_K0
-	/* if we are in user mode */
-	dmfc0 $k0, $status
-	andi $k0, 0x10
-	
-	beq $k0, $0, 1f
-	move $k0, $sp
-	
-	/* move $k0 pointer to kernel stack */
-	dla $k0, supervisor_sp
-	
-	/* move $k0 (supervisor_sp) */
-	lw $k0, ($k0)
-	
-	1:
-.endm
-
-.org 0x0
-kernel_image_start:
-	/* load temporary stack */
-	lui $sp, %hi(end_stack)
-	ori $sp, $sp, %lo(end_stack)
-	
-	/* not sure about this, but might be needed for PIC code */
-	lui $gp, 0x8000
-	
-	/* $a1 contains physical address of bootinfo_t */
-	jal arch_pre_main
-	addiu $sp, -ABI_STACK_FRAME
-	
-	j main_bsp
-	nop
-
-.space TEMP_STACK_SIZE
-end_stack:
-
-tlb_refill_entry:
-	j tlb_refill_handler
-	nop
-
-cache_error_entry:
-	j cache_error_handler
-	nop
-
-exception_entry:
-	j exception_handler
-	nop
-
-	FAKE_ABI_PROLOGUE
-exception_handler:
-	KERNEL_STACK_TO_K0
-	
-	sub $k0, ISTATE_SOFT_SIZE
-	sw $sp, ISTATE_OFFSET_SP($k0)
-	move $sp, $k0
-	
-	mfc0 $k0, $cause
-	
-	sra $k0, $k0, 0x2    /* cp0_exc_cause() part 1 */
-	andi $k0, $k0, 0x1f  /* cp0_exc_cause() part 2 */
-	sub $k0, 8           /* 8 = SYSCALL */
-	
-	beqz $k0, syscall_shortcut
-	add $k0, 8           /* revert $k0 back to correct exc number */
-	
-	REGISTERS_STORE_AND_EXC_RESET $sp
-	
-	move $a1, $sp
-	move $a0, $k0
-	jal exc_dispatch     /* exc_dispatch(excno, register_space) */
-	addiu $sp, -ABI_STACK_FRAME
-	addiu $sp, ABI_STACK_FRAME
-	
-	REGISTERS_LOAD $sp
-	/* the $sp is automatically restored to former value */
-	eret
-
-/** Syscall entry
- *
- * Registers:
- *
- * @param $v0 Syscall number.
- * @param $a0 1st argument.
- * @param $a1 2nd argument.
- * @param $a2 3rd argument.
- * @param $a3 4th argument.
- * @param $t0 5th argument.
- * @param $t1 6th argument.
- *
- * @return The return value will be stored in $v0.
- *
- */
-syscall_shortcut:
-	mfc0 $t3, $epc
-	mfc0 $t2, $status
-	sw $t3, ISTATE_OFFSET_EPC($sp)  /* save EPC */
-	sw $k1, ISTATE_OFFSET_KT1($sp)  /* save $k1 not saved on context switch */
-	
-	and $t4, $t2, REG_SAVE_MASK  /* save only KSU, EXL, ERL, IE */
-	li $t5, ~(0x1f)
-	and $t2, $t2, $t5  /* clear KSU, EXL, ERL */
-	ori $t2, $t2, 0x1  /* set IE */
-	
-	sw $t4, ISTATE_OFFSET_STATUS($sp)
-	mtc0 $t2, $status
-	
-	/*
-	 * Call the higher level system call handler.
-	 *
-	 */
-	sw $t0, ISTATE_OFFSET_T0($sp)  /* save the 5th argument on the stack */
-	sw $t1, ISTATE_OFFSET_T1($sp)  /* save the 6th argument on the stack */
-	
-	jal syscall_handler
-	sw $v0, ISTATE_OFFSET_V0($sp)  /* save the syscall number on the stack */
-	
-	/* restore status */
-	mfc0 $t2, $status
-	lw $t3, ISTATE_OFFSET_STATUS($sp)
-	
-	/*
-	 * Change back to EXL = 1 (from last exception), otherwise
-	 * an interrupt could rewrite the CP0 - EPC.
-	 *
-	 */
-	li $t4, ~REG_SAVE_MASK  /* mask UM, EXL, ERL, IE */
-	and $t2, $t2, $t4
-	or $t2, $t2, $t3  /* copy saved UM, EXL, ERL, IE */
-	mtc0 $t2, $status
-	
-	/* restore epc + 4 */
-	lw $t2, ISTATE_OFFSET_EPC($sp)
-	lw $k1, ISTATE_OFFSET_KT1($sp)
-	addi $t2, $t2, 4
-	mtc0 $t2, $epc
-	
-	lw $sp, ISTATE_OFFSET_SP($sp)  /* restore $sp */
-	eret
-
-	FAKE_ABI_PROLOGUE
-tlb_refill_handler:
-	KERNEL_STACK_TO_K0
-	sub $k0, ISTATE_SOFT_SIZE
-	REGISTERS_STORE_AND_EXC_RESET $k0
-	sw $sp, ISTATE_OFFSET_SP($k0)
-	move $sp, $k0
-	
-	move $a0, $sp
-	jal tlb_refill
-	addiu $sp, -ABI_STACK_FRAME
-	addiu $sp, ABI_STACK_FRAME
-	
-	REGISTERS_LOAD $sp
-	eret
-
-	FAKE_ABI_PROLOGUE
-cache_error_handler:
-	KERNEL_STACK_TO_K0
-	sub $k0, ISTATE_SOFT_SIZE
-	REGISTERS_STORE_AND_EXC_RESET $k0
-	sw $sp, ISTATE_OFFSET_SP($k0)
-	move $sp, $k0
-	
-	move $a0, $sp
-	jal cache_error
-	addiu $sp, -ABI_STACK_FRAME
-	addiu $sp, ABI_STACK_FRAME
-	
-	REGISTERS_LOAD $sp
-	eret
-
-userspace_asm:
-	move $sp, $a0
-	move $v0, $a1
-	move $t9, $a2      /* set up correct entry into PIC code */
-	xor $a0, $a0, $a0  /* $a0 is defined to hold pcb_ptr */
-	                   /* set it to 0 */
-	eret
Index: kernel/arch/ppc32/Makefile.inc
===================================================================
--- kernel/arch/ppc32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -51,5 +51,4 @@
 	arch/$(KARCH)/src/cpu/cpu.c \
 	arch/$(KARCH)/src/proc/scheduler.c \
-	arch/$(KARCH)/src/ddi/ddi.c \
 	arch/$(KARCH)/src/mm/km.c \
 	arch/$(KARCH)/src/mm/as.c \
@@ -59,2 +58,8 @@
 	arch/$(KARCH)/src/mm/tlb.c \
 	arch/$(KARCH)/src/drivers/pic.c
+
+ARCH_AUTOGENS_AG = \
+	arch/$(KARCH)/include/arch/istate_struct.ag \
+	arch/$(KARCH)/include/arch/context_struct.ag \
+	arch/$(KARCH)/include/arch/fpu_context_struct.ag
+
Index: kernel/arch/ppc32/include/arch/context.h
===================================================================
--- kernel/arch/ppc32/include/arch/context.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/include/arch/context.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,5 +36,5 @@
 #define KERN_ppc32_CONTEXT_H_
 
-#include <typedefs.h>
+#include <arch/context_struct.h>
 
 #define SP_DELTA  16
@@ -43,34 +43,4 @@
     context_set_generic(ctx, pc, stack, size)
 
-typedef struct {
-	uintptr_t sp;
-	uintptr_t pc;
-	
-	uint32_t r2;
-	uint32_t r13;
-	uint32_t r14;
-	uint32_t r15;
-	uint32_t r16;
-	uint32_t r17;
-	uint32_t r18;
-	uint32_t r19;
-	uint32_t r20;
-	uint32_t r21;
-	uint32_t r22;
-	uint32_t r23;
-	uint32_t r24;
-	uint32_t r25;
-	uint32_t r26;
-	uint32_t r27;
-	uint32_t r28;
-	uint32_t r29;
-	uint32_t r30;
-	uint32_t r31;
-	
-	uint32_t cr;
-	
-	ipl_t ipl;
-} __attribute__((packed)) context_t;
-
 #endif
 
Index: rnel/arch/ppc32/include/arch/context_offset.h
===================================================================
--- kernel/arch/ppc32/include/arch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,140 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KERN_ppc32_CONTEXT_OFFSET_H_
-#define KERN_ppc32_CONTEXT_OFFSET_H_
-
-#define OFFSET_SP    0x0
-#define OFFSET_PC    0x4
-#define OFFSET_R2    0x8
-#define OFFSET_R13   0xc
-#define OFFSET_R14   0x10
-#define OFFSET_R15   0x14
-#define OFFSET_R16   0x18
-#define OFFSET_R17   0x1c
-#define OFFSET_R18   0x20
-#define OFFSET_R19   0x24
-#define OFFSET_R20   0x28
-#define OFFSET_R21   0x2c
-#define OFFSET_R22   0x30
-#define OFFSET_R23   0x34
-#define OFFSET_R24   0x38
-#define OFFSET_R25   0x3c
-#define OFFSET_R26   0x40
-#define OFFSET_R27   0x44
-#define OFFSET_R28   0x48
-#define OFFSET_R29   0x4c
-#define OFFSET_R30   0x50
-#define OFFSET_R31   0x54
-#define OFFSET_CR    0x58
-
-#define OFFSET_FR14  0x0
-#define OFFSET_FR15  0x8
-#define OFFSET_FR16  0x10
-#define OFFSET_FR17  0x18
-#define OFFSET_FR18  0x20
-#define OFFSET_FR19  0x28
-#define OFFSET_FR20  0x30
-#define OFFSET_FR21  0x38
-#define OFFSET_FR22  0x40
-#define OFFSET_FR23  0x48
-#define OFFSET_FR24  0x50
-#define OFFSET_FR25  0x58
-#define OFFSET_FR26  0x60
-#define OFFSET_FR27  0x68
-#define OFFSET_FR28  0x70
-#define OFFSET_FR29  0x78
-#define OFFSET_FR30  0x80
-#define OFFSET_FR31  0x88
-#define OFFSET_FPSCR 0x90
-
-#ifdef __ASM__
-
-#ifdef KERNEL
-
-#include <arch/asm/regname.h>
-
-#else /* KERNEL */
-
-#include <libarch/regname.h>
-
-#endif /* KERNEL */
-
-/* ctx: address of the structure with saved context */
-.macro CONTEXT_SAVE_ARCH_CORE ctx:req
-	stw sp, OFFSET_SP(\ctx)
-	stw r2, OFFSET_R2(\ctx)
-	stw r13, OFFSET_R13(\ctx)
-	stw r14, OFFSET_R14(\ctx)
-	stw r15, OFFSET_R15(\ctx)
-	stw r16, OFFSET_R16(\ctx)
-	stw r17, OFFSET_R17(\ctx)
-	stw r18, OFFSET_R18(\ctx)
-	stw r19, OFFSET_R19(\ctx)
-	stw r20, OFFSET_R20(\ctx)
-	stw r21, OFFSET_R21(\ctx)
-	stw r22, OFFSET_R22(\ctx)
-	stw r23, OFFSET_R23(\ctx)
-	stw r24, OFFSET_R24(\ctx)
-	stw r25, OFFSET_R25(\ctx)
-	stw r26, OFFSET_R26(\ctx)
-	stw r27, OFFSET_R27(\ctx)
-	stw r28, OFFSET_R28(\ctx)
-	stw r29, OFFSET_R29(\ctx)
-	stw r30, OFFSET_R30(\ctx)
-	stw r31, OFFSET_R31(\ctx)
-.endm
-
-/* ctx: address of the structure with saved context */
-.macro CONTEXT_RESTORE_ARCH_CORE ctx:req
-	lwz sp, OFFSET_SP(\ctx)
-	lwz r2, OFFSET_R2(\ctx)
-	lwz r13, OFFSET_R13(\ctx)
-	lwz r14, OFFSET_R14(\ctx)
-	lwz r15, OFFSET_R15(\ctx)
-	lwz r16, OFFSET_R16(\ctx)
-	lwz r17, OFFSET_R17(\ctx)
-	lwz r18, OFFSET_R18(\ctx)
-	lwz r19, OFFSET_R19(\ctx)
-	lwz r20, OFFSET_R20(\ctx)
-	lwz r21, OFFSET_R21(\ctx)
-	lwz r22, OFFSET_R22(\ctx)
-	lwz r23, OFFSET_R23(\ctx)
-	lwz r24, OFFSET_R24(\ctx)
-	lwz r25, OFFSET_R25(\ctx)
-	lwz r26, OFFSET_R26(\ctx)
-	lwz r27, OFFSET_R27(\ctx)
-	lwz r28, OFFSET_R28(\ctx)
-	lwz r29, OFFSET_R29(\ctx)
-	lwz r30, OFFSET_R30(\ctx)
-	lwz r31, OFFSET_R31(\ctx)
-.endm
-
-#endif /* __ASM__ */
-
-#endif
Index: kernel/arch/ppc32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/ppc32/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/ppc32/include/arch/context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,139 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <typedefs.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : sp,
+                        type : uint32_t
+                },
+                {
+                        name : pc,
+                        type : uint32_t
+                },
+
+                {
+                        name : r2,
+                        type : uint32_t
+                },
+                {
+                        name : r13,
+                        type : uint32_t
+                },
+                {
+                        name : r14,
+                        type : uint32_t
+                },
+                {
+                        name : r15,
+                        type : uint32_t
+                },
+                {
+                        name : r16,
+                        type : uint32_t
+                },
+                {
+                        name : r17,
+                        type : uint32_t
+                },
+                {
+                        name : r18,
+                        type : uint32_t
+                },
+                {
+                        name : r19,
+                        type : uint32_t
+                },
+                {
+                        name : r20,
+                        type : uint32_t
+                },
+                {
+                        name : r21,
+                        type : uint32_t
+                },
+                {
+                        name : r22,
+                        type : uint32_t
+                },
+                {
+                        name : r23,
+                        type : uint32_t
+                },
+                {
+                        name : r24,
+                        type : uint32_t
+                },
+                {
+                        name : r25,
+                        type : uint32_t
+                },
+                {
+                        name : r26,
+                        type : uint32_t
+                },
+                {
+                        name : r27,
+                        type : uint32_t
+                },
+                {
+                        name : r28,
+                        type : uint32_t
+                },
+                {
+                        name : r29,
+                        type : uint32_t
+                },
+                {
+                        name : r30,
+                        type : uint32_t
+                },
+                {
+                        name : r31,
+                        type : uint32_t
+                },
+
+                {
+                        name : cr,
+                        type : uint32_t
+                },
+
+                {
+                        name : ipl,
+                        type : ipl_t
+                }
+        ]
+}
+
Index: rnel/arch/ppc32/include/arch/exception.h
===================================================================
--- kernel/arch/ppc32/include/arch/exception.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,113 +1,0 @@
-/*
- * Copyright (c) 2006 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 ppc32
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_ppc32_EXCEPTION_H_
-#define KERN_ppc32_EXCEPTION_H_
-
-#include <typedefs.h>
-#include <arch/msr.h>
-#include <trace.h>
-
-typedef struct istate {
-	uint32_t r0;
-	uint32_t r2;
-	uint32_t r3;
-	uint32_t r4;
-	uint32_t r5;
-	uint32_t r6;
-	uint32_t r7;
-	uint32_t r8;
-	uint32_t r9;
-	uint32_t r10;
-	uint32_t r11;
-	uint32_t r13;
-	uint32_t r14;
-	uint32_t r15;
-	uint32_t r16;
-	uint32_t r17;
-	uint32_t r18;
-	uint32_t r19;
-	uint32_t r20;
-	uint32_t r21;
-	uint32_t r22;
-	uint32_t r23;
-	uint32_t r24;
-	uint32_t r25;
-	uint32_t r26;
-	uint32_t r27;
-	uint32_t r28;
-	uint32_t r29;
-	uint32_t r30;
-	uint32_t r31;
-	uint32_t cr;
-	uint32_t pc;
-	uint32_t srr1;
-	uint32_t lr;
-	uint32_t ctr;
-	uint32_t xer;
-	uint32_t dar;
-	uint32_t r12;
-	uint32_t sp;
-} istate_t;
-
-NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
-    uintptr_t retaddr)
-{
-	istate->pc = retaddr;
-}
-
-/** Return true if exception happened while in userspace
- *
- * The contexts of MSR register was stored in SRR1.
- *
- */
-NO_TRACE static inline int istate_from_uspace(istate_t *istate)
-{
-	return (istate->srr1 & MSR_PR) != 0;
-}
-
-NO_TRACE static inline sysarg_t istate_get_pc(istate_t *istate)
-{
-	return istate->pc;
-}
-
-NO_TRACE static inline sysarg_t istate_get_fp(istate_t *istate)
-{
-	return istate->sp;
-}
-
-#endif
-
-/** @}
- */
Index: kernel/arch/ppc32/include/arch/fpu_context.h
===================================================================
--- kernel/arch/ppc32/include/arch/fpu_context.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/include/arch/fpu_context.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,27 +36,7 @@
 #define KERN_ppc32_FPU_CONTEXT_H_
 
-#include <typedefs.h>
+#define FPU_CONTEXT_ALIGN	8	
 
-typedef struct {
-	uint64_t fr14;
-	uint64_t fr15;
-	uint64_t fr16;
-	uint64_t fr17;
-	uint64_t fr18;
-	uint64_t fr19;
-	uint64_t fr20;
-	uint64_t fr21;
-	uint64_t fr22;
-	uint64_t fr23;
-	uint64_t fr24;
-	uint64_t fr25;
-	uint64_t fr26;
-	uint64_t fr27;
-	uint64_t fr28;
-	uint64_t fr29;
-	uint64_t fr30;
-	uint64_t fr31;
-	uint32_t fpscr;
-} __attribute__ ((packed)) fpu_context_t;
+#include <arch/fpu_context_struct.h>
 
 #endif
Index: kernel/arch/ppc32/include/arch/fpu_context_struct.ag
===================================================================
--- kernel/arch/ppc32/include/arch/fpu_context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/ppc32/include/arch/fpu_context_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,173 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : fpu_context,
+
+        includes : [
+                {
+                        include : <typedefs.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : fr0,
+                        type : uint64_t
+                },
+                {
+                        name : fr1,
+                        type : uint64_t
+                },
+                {
+                        name : fr2,
+                        type : uint64_t
+                },
+                {
+                        name : fr3,
+                        type : uint64_t
+                },
+                {
+                        name : fr4,
+                        type : uint64_t
+                },
+                {
+                        name : fr5,
+                        type : uint64_t
+                },
+                {
+                        name : fr6,
+                        type : uint64_t
+                },
+                {
+                        name : fr7,
+                        type : uint64_t
+                },
+                {
+                        name : fr8,
+                        type : uint64_t
+                },
+                {
+                        name : fr9,
+                        type : uint64_t
+                },
+                {
+                        name : fr10,
+                        type : uint64_t
+                },
+                {
+                        name : fr11,
+                        type : uint64_t
+                },
+                {
+                        name : fr12,
+                        type : uint64_t
+                },
+                {
+                        name : fr13,
+                        type : uint64_t
+                },
+                {
+                        name : fr14,
+                        type : uint64_t
+                },
+                {
+                        name : fr15,
+                        type : uint64_t
+                },
+                {
+                        name : fr16,
+                        type : uint64_t
+                },
+                {
+                        name : fr17,
+                        type : uint64_t
+                },
+                {
+                        name : fr18,
+                        type : uint64_t
+                },
+                {
+                        name : fr19,
+                        type : uint64_t
+                },
+                {
+                        name : fr20,
+                        type : uint64_t
+                },
+                {
+                        name : fr21,
+                        type : uint64_t
+                },
+                {
+                        name : fr22,
+                        type : uint64_t
+                },
+                {
+                        name : fr23,
+                        type : uint64_t
+                },
+                {
+                        name : fr24,
+                        type : uint64_t
+                },
+                {
+                        name : fr25,
+                        type : uint64_t
+                },
+                {
+                        name : fr26,
+                        type : uint64_t
+                },
+                {
+                        name : fr27,
+                        type : uint64_t
+                },
+                {
+                        name : fr28,
+                        type : uint64_t
+                },
+                {
+                        name : fr29,
+                        type : uint64_t
+                },
+                {
+                        name : fr30,
+                        type : uint64_t
+                },
+                {
+                        name : fr31,
+                        type : uint64_t
+                },
+                {
+                        name : fpscr,
+                        type : uint64_t
+                }
+
+        ]
+}
+
Index: kernel/arch/ppc32/include/arch/interrupt.h
===================================================================
--- kernel/arch/ppc32/include/arch/interrupt.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/include/arch/interrupt.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,5 +36,5 @@
 #define KERN_ppc32_INTERRUPT_H_
 
-#include <arch/exception.h>
+#include <arch/istate.h>
 
 #define IVT_ITEMS  16
@@ -44,4 +44,5 @@
 #define VECTOR_INSTRUCTION_STORAGE  3
 #define VECTOR_EXTERNAL             4
+#define VECTOR_FP_UNAVAILABLE       7
 #define VECTOR_DECREMENTER          8
 #define VECTOR_ITLB_MISS            13
@@ -49,5 +50,6 @@
 #define VECTOR_DTLB_MISS_STORE      15
 
-extern void start_decrementer(void);
+extern void decrementer_start(uint32_t);
+extern void decrementer_restart(void);
 extern void interrupt_init(void);
 extern void extint_handler(unsigned int, istate_t *);
Index: kernel/arch/ppc32/include/arch/istate.h
===================================================================
--- kernel/arch/ppc32/include/arch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/include/arch/istate.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,53 +40,13 @@
 #ifdef KERNEL
 
+#include <arch/istate_struct.h>
 #include <arch/msr.h>
 
 #else /* KERNEL */
 
+#include <libarch/istate_struct.h>
 #include <libarch/msr.h>
 
 #endif /* KERNEL */
-
-typedef struct istate {
-	uint32_t r0;
-	uint32_t r2;
-	uint32_t r3;
-	uint32_t r4;
-	uint32_t r5;
-	uint32_t r6;
-	uint32_t r7;
-	uint32_t r8;
-	uint32_t r9;
-	uint32_t r10;
-	uint32_t r11;
-	uint32_t r13;
-	uint32_t r14;
-	uint32_t r15;
-	uint32_t r16;
-	uint32_t r17;
-	uint32_t r18;
-	uint32_t r19;
-	uint32_t r20;
-	uint32_t r21;
-	uint32_t r22;
-	uint32_t r23;
-	uint32_t r24;
-	uint32_t r25;
-	uint32_t r26;
-	uint32_t r27;
-	uint32_t r28;
-	uint32_t r29;
-	uint32_t r30;
-	uint32_t r31;
-	uint32_t cr;
-	uint32_t pc;
-	uint32_t msr;
-	uint32_t lr;
-	uint32_t ctr;
-	uint32_t xer;
-	uint32_t dar;
-	uint32_t r12;
-	uint32_t sp;
-} istate_t;
 
 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
@@ -98,19 +58,22 @@
 /** Return true if exception happened while in userspace
  *
+ * The contexts of MSR register was stored in SRR1.
+ *
  */
 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
 {
-	return (istate->msr & MSR_PR) != 0;
+	return (istate->srr1 & MSR_PR) != 0;
 }
 
-NO_TRACE static inline uintptr_t istate_get_pc(istate_t *istate)
+NO_TRACE static inline sysarg_t istate_get_pc(istate_t *istate)
 {
 	return istate->pc;
 }
 
-NO_TRACE static inline uintptr_t istate_get_fp(istate_t *istate)
+NO_TRACE static inline sysarg_t istate_get_fp(istate_t *istate)
 {
 	return istate->sp;
 }
+
 
 #endif
Index: kernel/arch/ppc32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/ppc32/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/ppc32/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,212 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : istate,
+
+        includes : [
+                {
+                        guard : KERNEL,
+                        include : <typedefs.h>
+                },
+                {
+                        negative-guard : KERNEL,
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                {
+                        # imitation of frame pointer linkage
+                        name : sp_frame,
+                        type : uint32_t
+                },
+                {
+                        # imitation of return adress linkage
+                        name : lr_frame,
+                        type : uint32_t
+                },
+                {
+                        name : r0,
+                        type : uint32_t
+                },
+                {
+                        name : r2,
+                        type : uint32_t
+                },
+                {
+                        name : r3,
+                        type : uint32_t
+                },
+                {
+                        name : r4,
+                        type : uint32_t
+                },
+                {
+                        name : r5,
+                        type : uint32_t
+                },
+                {
+                        name : r6,
+                        type : uint32_t
+                },
+                {
+                        name : r7,
+                        type : uint32_t
+                },
+                {
+                        name : r8,
+                        type : uint32_t
+                },
+                {
+                        name : r9,
+                        type : uint32_t
+                },
+                {
+                        name : r10,
+                        type : uint32_t
+                },
+                {
+                        name : r11,
+                        type : uint32_t
+                },
+                {
+                        name : r13,
+                        type : uint32_t
+                },
+                {
+                        name : r14,
+                        type : uint32_t
+                },
+                {
+                        name : r15,
+                        type : uint32_t
+                },
+                {
+                        name : r16,
+                        type : uint32_t
+                },
+                {
+                        name : r17,
+                        type : uint32_t
+                },
+                {
+                        name : r18,
+                        type : uint32_t
+                },
+                {
+                        name : r19,
+                        type : uint32_t
+                },
+                {
+                        name : r20,
+                        type : uint32_t
+                },
+                {
+                        name : r21,
+                        type : uint32_t
+                },
+                {
+                        name : r22,
+                        type : uint32_t
+                },
+                {
+                        name : r23,
+                        type : uint32_t
+                },
+                {
+                        name : r24,
+                        type : uint32_t
+                },
+                {
+                        name : r25,
+                        type : uint32_t
+                },
+                {
+                        name : r26,
+                        type : uint32_t
+                },
+                {
+                        name : r27,
+                        type : uint32_t
+                },
+                {
+                        name : r28,
+                        type : uint32_t
+                },
+                {
+                        name : r29,
+                        type : uint32_t
+                },
+                {
+                        name : r30,
+                        type : uint32_t
+                },
+                {
+                        name : r31,
+                        type : uint32_t
+                },
+                {
+                        name : cr,
+                        type : uint32_t
+                },
+                {
+                        name : pc,
+                        type : uint32_t
+                },
+                {
+                        name : srr1,
+                        type : uint32_t
+                },
+                {
+                        name : lr,
+                        type : uint32_t
+                },
+                {
+                        name : ctr,
+                        type : uint32_t
+                },
+                {
+                        name : xer,
+                        type : uint32_t
+                },
+                {
+                        name : dar,
+                        type : uint32_t
+                },
+                {
+                        name : r12,
+                        type : uint32_t
+                },
+                {
+                        name : sp,
+                        type : uint32_t
+                }
+
+        ]
+}
+
Index: kernel/arch/ppc32/include/arch/msr.h
===================================================================
--- kernel/arch/ppc32/include/arch/msr.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/include/arch/msr.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,4 +39,7 @@
 #define MSR_DR  (1 << 4)
 #define MSR_IR  (1 << 5)
+#define MSR_FE1 (1 << 8)
+#define MSR_FE0 (1 << 11)
+#define MSR_FP  (1 << 13)
 #define MSR_PR  (1 << 14)
 #define MSR_EE  (1 << 15)
Index: kernel/arch/ppc32/include/arch/stack.h
===================================================================
--- kernel/arch/ppc32/include/arch/stack.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/include/arch/stack.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,4 +40,6 @@
 #define MEM_STACK_SIZE	STACK_SIZE
 
+#define STACK_ALIGNMENT	16
+
 #endif
 
Index: kernel/arch/ppc32/src/asm.S
===================================================================
--- kernel/arch/ppc32/src/asm.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/src/asm.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -29,4 +29,5 @@
 #include <arch/asm/regname.h>
 #include <arch/msr.h>
+#include <arch/istate_struct.h>
 
 .text
@@ -59,5 +60,5 @@
 	mtsrr0 r5
 	
-	/* Set problem state, enable interrupts */
+	/* Set privileged state, enable interrupts */
 	
 	ori r31, r31, MSR_PR
@@ -85,55 +86,55 @@
 	mtmsr r31
 	
-	lwz r0, 8(sp)
-	lwz r2, 12(sp)
-	lwz r3, 16(sp)
-	lwz r4, 20(sp)
-	lwz r5, 24(sp)
-	lwz r6, 28(sp)
-	lwz r7, 32(sp)
-	lwz r8, 36(sp)
-	lwz r9, 40(sp)
-	lwz r10, 44(sp)
-	lwz r11, 48(sp)
-	lwz r13, 52(sp)
-	lwz r14, 56(sp)
-	lwz r15, 60(sp)
-	lwz r16, 64(sp)
-	lwz r17, 68(sp)
-	lwz r18, 72(sp)
-	lwz r19, 76(sp)
-	lwz r20, 80(sp)
-	lwz r21, 84(sp)
-	lwz r22, 88(sp)
-	lwz r23, 92(sp)
-	lwz r24, 96(sp)
-	lwz r25, 100(sp)
-	lwz r26, 104(sp)
-	lwz r27, 108(sp)
-	lwz r28, 112(sp)
-	lwz r29, 116(sp)
-	lwz r30, 120(sp)
-	lwz r31, 124(sp)
-	
-	lwz r12, 128(sp)
+	lwz r0, ISTATE_OFFSET_R0(sp)
+	lwz r2, ISTATE_OFFSET_R2(sp)
+	lwz r3, ISTATE_OFFSET_R3(sp)
+	lwz r4, ISTATE_OFFSET_R4(sp)
+	lwz r5, ISTATE_OFFSET_R5(sp)
+	lwz r6, ISTATE_OFFSET_R6(sp)
+	lwz r7, ISTATE_OFFSET_R7(sp)
+	lwz r8, ISTATE_OFFSET_R8(sp)
+	lwz r9, ISTATE_OFFSET_R9(sp)
+	lwz r10, ISTATE_OFFSET_R10(sp)
+	lwz r11, ISTATE_OFFSET_R11(sp)
+	lwz r13, ISTATE_OFFSET_R13(sp)
+	lwz r14, ISTATE_OFFSET_R14(sp)
+	lwz r15, ISTATE_OFFSET_R15(sp)
+	lwz r16, ISTATE_OFFSET_R16(sp)
+	lwz r17, ISTATE_OFFSET_R17(sp)
+	lwz r18, ISTATE_OFFSET_R18(sp)
+	lwz r19, ISTATE_OFFSET_R19(sp)
+	lwz r20, ISTATE_OFFSET_R20(sp)
+	lwz r21, ISTATE_OFFSET_R21(sp)
+	lwz r22, ISTATE_OFFSET_R22(sp)
+	lwz r23, ISTATE_OFFSET_R23(sp)
+	lwz r24, ISTATE_OFFSET_R24(sp)
+	lwz r25, ISTATE_OFFSET_R25(sp)
+	lwz r26, ISTATE_OFFSET_R26(sp)
+	lwz r27, ISTATE_OFFSET_R27(sp)
+	lwz r28, ISTATE_OFFSET_R28(sp)
+	lwz r29, ISTATE_OFFSET_R29(sp)
+	lwz r30, ISTATE_OFFSET_R30(sp)
+	lwz r31, ISTATE_OFFSET_R31(sp)
+	
+	lwz r12, ISTATE_OFFSET_CR(sp)
 	mtcr r12
 	
-	lwz r12, 132(sp)
+	lwz r12, ISTATE_OFFSET_PC(sp)
 	mtsrr0 r12
 	
-	lwz r12, 136(sp)
+	lwz r12, ISTATE_OFFSET_SRR1(sp)
 	mtsrr1 r12
 	
-	lwz r12, 140(sp)
+	lwz r12, ISTATE_OFFSET_LR(sp)
 	mtlr r12
 	
-	lwz r12, 144(sp)
+	lwz r12, ISTATE_OFFSET_CTR(sp)
 	mtctr r12
 	
-	lwz r12, 148(sp)
+	lwz r12, ISTATE_OFFSET_XER(sp)
 	mtxer r12
 	
-	lwz r12, 156(sp)
-	lwz sp, 160(sp)
+	lwz r12, ISTATE_OFFSET_R12(sp)
+	lwz sp, ISTATE_OFFSET_SP(sp)
 	
 	rfi
@@ -152,54 +153,54 @@
 	mtmsr r31
 	
-	lwz r0, 8(sp)
-	lwz r2, 12(sp)
-	lwz r4, 20(sp)
-	lwz r5, 24(sp)
-	lwz r6, 28(sp)
-	lwz r7, 32(sp)
-	lwz r8, 36(sp)
-	lwz r9, 40(sp)
-	lwz r10, 44(sp)
-	lwz r11, 48(sp)
-	lwz r13, 52(sp)
-	lwz r14, 56(sp)
-	lwz r15, 60(sp)
-	lwz r16, 64(sp)
-	lwz r17, 68(sp)
-	lwz r18, 72(sp)
-	lwz r19, 76(sp)
-	lwz r20, 80(sp)
-	lwz r21, 84(sp)
-	lwz r22, 88(sp)
-	lwz r23, 92(sp)
-	lwz r24, 96(sp)
-	lwz r25, 100(sp)
-	lwz r26, 104(sp)
-	lwz r27, 108(sp)
-	lwz r28, 112(sp)
-	lwz r29, 116(sp)
-	lwz r30, 120(sp)
-	lwz r31, 124(sp)
-	
-	lwz r12, 128(sp)
+	lwz r0, ISTATE_OFFSET_R0(sp)
+	lwz r2, ISTATE_OFFSET_R2(sp)
+	lwz r4, ISTATE_OFFSET_R4(sp)
+	lwz r5, ISTATE_OFFSET_R5(sp)
+	lwz r6, ISTATE_OFFSET_R6(sp)
+	lwz r7, ISTATE_OFFSET_R7(sp)
+	lwz r8, ISTATE_OFFSET_R8(sp)
+	lwz r9, ISTATE_OFFSET_R9(sp)
+	lwz r10, ISTATE_OFFSET_R10(sp)
+	lwz r11, ISTATE_OFFSET_R11(sp)
+	lwz r13, ISTATE_OFFSET_R13(sp)
+	lwz r14, ISTATE_OFFSET_R14(sp)
+	lwz r15, ISTATE_OFFSET_R15(sp)
+	lwz r16, ISTATE_OFFSET_R16(sp)
+	lwz r17, ISTATE_OFFSET_R17(sp)
+	lwz r18, ISTATE_OFFSET_R18(sp)
+	lwz r19, ISTATE_OFFSET_R19(sp)
+	lwz r20, ISTATE_OFFSET_R20(sp)
+	lwz r21, ISTATE_OFFSET_R21(sp)
+	lwz r22, ISTATE_OFFSET_R22(sp)
+	lwz r23, ISTATE_OFFSET_R23(sp)
+	lwz r24, ISTATE_OFFSET_R24(sp)
+	lwz r25, ISTATE_OFFSET_R25(sp)
+	lwz r26, ISTATE_OFFSET_R26(sp)
+	lwz r27, ISTATE_OFFSET_R27(sp)
+	lwz r28, ISTATE_OFFSET_R28(sp)
+	lwz r29, ISTATE_OFFSET_R29(sp)
+	lwz r30, ISTATE_OFFSET_R30(sp)
+	lwz r31, ISTATE_OFFSET_R31(sp)
+	
+	lwz r12, ISTATE_OFFSET_CR(sp)
 	mtcr r12
 	
-	lwz r12, 132(sp)
+	lwz r12, ISTATE_OFFSET_PC(sp)
 	mtsrr0 r12
 	
-	lwz r12, 136(sp)
+	lwz r12, ISTATE_OFFSET_SRR1(sp)
 	mtsrr1 r12
 	
-	lwz r12, 140(sp)
+	lwz r12, ISTATE_OFFSET_LR(sp)
 	mtlr r12
 	
-	lwz r12, 144(sp)
+	lwz r12, ISTATE_OFFSET_CTR(sp)
 	mtctr r12
 	
-	lwz r12, 148(sp)
+	lwz r12, ISTATE_OFFSET_XER(sp)
 	mtxer r12
 	
-	lwz r12, 156(sp)
-	lwz sp, 160(sp)
+	lwz r12, ISTATE_OFFSET_R12(sp)
+	lwz sp, ISTATE_OFFSET_SP(sp)
 	
 	rfi
Index: kernel/arch/ppc32/src/context.S
===================================================================
--- kernel/arch/ppc32/src/context.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/src/context.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -27,5 +27,6 @@
 #
 
-#include <arch/context_offset.h>
+#include <arch/context_struct.h>
+#include <arch/asm/regname.h>
 
 .text
@@ -35,11 +36,31 @@
 
 context_save_arch:
-	CONTEXT_SAVE_ARCH_CORE r3
+	stw sp, CONTEXT_OFFSET_SP(r3)
+	stw r2, CONTEXT_OFFSET_R2(r3)
+	stw r13, CONTEXT_OFFSET_R13(r3)
+	stw r14, CONTEXT_OFFSET_R14(r3)
+	stw r15, CONTEXT_OFFSET_R15(r3)
+	stw r16, CONTEXT_OFFSET_R16(r3)
+	stw r17, CONTEXT_OFFSET_R17(r3)
+	stw r18, CONTEXT_OFFSET_R18(r3)
+	stw r19, CONTEXT_OFFSET_R19(r3)
+	stw r20, CONTEXT_OFFSET_R20(r3)
+	stw r21, CONTEXT_OFFSET_R21(r3)
+	stw r22, CONTEXT_OFFSET_R22(r3)
+	stw r23, CONTEXT_OFFSET_R23(r3)
+	stw r24, CONTEXT_OFFSET_R24(r3)
+	stw r25, CONTEXT_OFFSET_R25(r3)
+	stw r26, CONTEXT_OFFSET_R26(r3)
+	stw r27, CONTEXT_OFFSET_R27(r3)
+	stw r28, CONTEXT_OFFSET_R28(r3)
+	stw r29, CONTEXT_OFFSET_R29(r3)
+	stw r30, CONTEXT_OFFSET_R30(r3)
+	stw r31, CONTEXT_OFFSET_R31(r3)
 	
 	mflr r4
-	stw r4, OFFSET_PC(r3)
+	stw r4, CONTEXT_OFFSET_PC(r3)
 	
 	mfcr r4
-	stw r4, OFFSET_CR(r3)
+	stw r4, CONTEXT_OFFSET_CR(r3)
 	
 	# context_save returns 1
@@ -48,10 +69,30 @@
 
 context_restore_arch:
-	CONTEXT_RESTORE_ARCH_CORE r3
+	lwz sp, CONTEXT_OFFSET_SP(r3)
+	lwz r2, CONTEXT_OFFSET_R2(r3)
+	lwz r13, CONTEXT_OFFSET_R13(r3)
+	lwz r14, CONTEXT_OFFSET_R14(r3)
+	lwz r15, CONTEXT_OFFSET_R15(r3)
+	lwz r16, CONTEXT_OFFSET_R16(r3)
+	lwz r17, CONTEXT_OFFSET_R17(r3)
+	lwz r18, CONTEXT_OFFSET_R18(r3)
+	lwz r19, CONTEXT_OFFSET_R19(r3)
+	lwz r20, CONTEXT_OFFSET_R20(r3)
+	lwz r21, CONTEXT_OFFSET_R21(r3)
+	lwz r22, CONTEXT_OFFSET_R22(r3)
+	lwz r23, CONTEXT_OFFSET_R23(r3)
+	lwz r24, CONTEXT_OFFSET_R24(r3)
+	lwz r25, CONTEXT_OFFSET_R25(r3)
+	lwz r26, CONTEXT_OFFSET_R26(r3)
+	lwz r27, CONTEXT_OFFSET_R27(r3)
+	lwz r28, CONTEXT_OFFSET_R28(r3)
+	lwz r29, CONTEXT_OFFSET_R29(r3)
+	lwz r30, CONTEXT_OFFSET_R30(r3)
+	lwz r31, CONTEXT_OFFSET_R31(r3)
 	
-	lwz r4, OFFSET_CR(r3)
+	lwz r4, CONTEXT_OFFSET_CR(r3)
 	mtcr r4
 	
-	lwz r4, OFFSET_PC(r3)
+	lwz r4, CONTEXT_OFFSET_PC(r3)
 	mtlr r4
 	
Index: kernel/arch/ppc32/src/cpu/cpu.c
===================================================================
--- kernel/arch/ppc32/src/cpu/cpu.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/src/cpu/cpu.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,7 +37,11 @@
 #include <arch.h>
 #include <print.h>
+#include <fpu_context.h>
 
 void cpu_arch_init(void)
 {
+#ifdef CONFIG_FPU
+	fpu_enable();
+#endif
 }
 
@@ -52,18 +56,18 @@
 	
 	switch (cpu->arch.version) {
-		case 8:
-			name = "PowerPC 750";
-			break;
-		case 9:
-			name = "PowerPC 604e";
-			break;
-		case 0x81:
-			name = "PowerPC 8260";
-			break;
-		case 0x8081:
-			name = "PowerPC 826xA";
-			break;
-		default:
-			name = "unknown";
+	case 8:
+		name = "PowerPC 750";
+		break;
+	case 9:
+		name = "PowerPC 604e";
+		break;
+	case 0x81:
+		name = "PowerPC 8260";
+		break;
+	case 0x8081:
+		name = "PowerPC 826xA";
+		break;
+	default:
+		name = "unknown";
 	}
 	
Index: rnel/arch/ppc32/src/ddi/ddi.c
===================================================================
--- kernel/arch/ppc32/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup ppc32ddi
- * @{
- */
-/** @file
- */
-
-#include <ddi/ddi.h>
-#include <proc/task.h>
-#include <typedefs.h>
-
-/** Enable I/O space range for task.
- *
- * Interrupts are disabled and task is locked.
- *
- * @param task Task.
- * @param ioaddr Startign I/O space address.
- * @param size Size of the enabled I/O range.
- *
- * @return 0 on success or an error code from errno.h.
- *
- */
-int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
-{
-	return 0;
-}
-
-/** @}
- */
Index: kernel/arch/ppc32/src/exception.S
===================================================================
--- kernel/arch/ppc32/src/exception.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/src/exception.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -30,4 +30,7 @@
 #include <arch/msr.h>
 #include <arch/mm/page.h>
+#include <arch/istate_struct.h>
+#include <arch/stack.h>
+#include <align.h>
 
 .section K_UNMAPPED_TEXT_START, "ax"
@@ -42,81 +45,82 @@
 	mtsprg2 sp
 	
-	# check whether SP is in kernel
-	
-	andis. sp, sp, 0x8000
+	# check whether the previous mode was user or kernel
+	
+	mfsrr1 sp # use sp as a temporary register to hold SRR1
+	andi. sp, sp, MSR_PR 
 	bne 1f
-	
-		# stack is in user-space
-		
-		mfsprg0 sp
-	
-	b 2f
-	
-	1:
-	
-		# stack is in kernel
+		# previous mode was kernel
 		
 		mfsprg2 sp
 		subis sp, sp, 0x8000
-	
+	b 2f
+	
+	1:
+		# previous mode was user
+		
+		mfsprg0 sp
 	2:
 	
-	subi sp, sp, 164
-	stw r0, 8(sp)
-	stw r2, 12(sp)
-	stw r3, 16(sp)
-	stw r4, 20(sp)
-	stw r5, 24(sp)
-	stw r6, 28(sp)
-	stw r7, 32(sp)
-	stw r8, 36(sp)
-	stw r9, 40(sp)
-	stw r10, 44(sp)
-	stw r11, 48(sp)
-	stw r13, 52(sp)
-	stw r14, 56(sp)
-	stw r15, 60(sp)
-	stw r16, 64(sp)
-	stw r17, 68(sp)
-	stw r18, 72(sp)
-	stw r19, 76(sp)
-	stw r20, 80(sp)
-	stw r21, 84(sp)
-	stw r22, 88(sp)
-	stw r23, 92(sp)
-	stw r24, 96(sp)
-	stw r25, 100(sp)
-	stw r26, 104(sp)
-	stw r27, 108(sp)
-	stw r28, 112(sp)
-	stw r29, 116(sp)
-	stw r30, 120(sp)
-	stw r31, 124(sp)
-	
-	stw r12, 128(sp)
+	subi sp, sp, ALIGN_UP(ISTATE_SIZE, STACK_ALIGNMENT)
+	stw r0, ISTATE_OFFSET_R0(sp)
+	stw r2, ISTATE_OFFSET_R2(sp)
+	stw r3, ISTATE_OFFSET_R3(sp)
+	stw r4, ISTATE_OFFSET_R4(sp)
+	stw r5, ISTATE_OFFSET_R5(sp)
+	stw r6, ISTATE_OFFSET_R6(sp)
+	stw r7, ISTATE_OFFSET_R7(sp)
+	stw r8, ISTATE_OFFSET_R8(sp)
+	stw r9, ISTATE_OFFSET_R9(sp)
+	stw r10, ISTATE_OFFSET_R10(sp)
+	stw r11, ISTATE_OFFSET_R11(sp)
+	stw r13, ISTATE_OFFSET_R13(sp)
+	stw r14, ISTATE_OFFSET_R14(sp)
+	stw r15, ISTATE_OFFSET_R15(sp)
+	stw r16, ISTATE_OFFSET_R16(sp)
+	stw r17, ISTATE_OFFSET_R17(sp)
+	stw r18, ISTATE_OFFSET_R18(sp)
+	stw r19, ISTATE_OFFSET_R19(sp)
+	stw r20, ISTATE_OFFSET_R20(sp)
+	stw r21, ISTATE_OFFSET_R21(sp)
+	stw r22, ISTATE_OFFSET_R22(sp)
+	stw r23, ISTATE_OFFSET_R23(sp)
+	stw r24, ISTATE_OFFSET_R24(sp)
+	stw r25, ISTATE_OFFSET_R25(sp)
+	stw r26, ISTATE_OFFSET_R26(sp)
+	stw r27, ISTATE_OFFSET_R27(sp)
+	stw r28, ISTATE_OFFSET_R28(sp)
+	stw r29, ISTATE_OFFSET_R29(sp)
+	stw r30, ISTATE_OFFSET_R30(sp)
+	stw r31, ISTATE_OFFSET_R31(sp)
+	
+	stw r12, ISTATE_OFFSET_CR(sp)
 	
 	mfsrr0 r12
-	stw r12, 132(sp)
+	stw r12, ISTATE_OFFSET_PC(sp)
 	
 	mfsrr1 r12
-	stw r12, 136(sp)
+	stw r12, ISTATE_OFFSET_SRR1(sp)
 	
 	mflr r12
-	stw r12, 140(sp)
+	stw r12, ISTATE_OFFSET_LR(sp)
 	
 	mfctr r12
-	stw r12, 144(sp)
+	stw r12, ISTATE_OFFSET_CTR(sp)
 	
 	mfxer r12
-	stw r12, 148(sp)
+	stw r12, ISTATE_OFFSET_XER(sp)
 	
 	mfdar r12
-	stw r12, 152(sp)
+	stw r12, ISTATE_OFFSET_DAR(sp)
 	
 	mfsprg1 r12
-	stw r12, 156(sp)
+	stw r12, ISTATE_OFFSET_R12(sp)
 	
 	mfsprg2 r12
-	stw r12, 160(sp)
+	stw r12, ISTATE_OFFSET_SP(sp)
+
+	li r12, 0
+	stw r12, ISTATE_OFFSET_LR_FRAME(sp)
+	stw r12, ISTATE_OFFSET_SP_FRAME(sp)
 .endm
 
@@ -250,19 +254,33 @@
 .org 0x4000
 jump_to_kernel:
+	mfsrr1 r5
+	andi. r5, r5, MSR_PR
+	bne 1f
+		# Previous mode was kernel.
+		# We can construct a proper frame linkage.
+		
+		mfsrr0 r12
+		stw r12, ISTATE_OFFSET_LR_FRAME(sp)
+		mfsprg2 r12
+		stw r12, ISTATE_OFFSET_SP_FRAME(sp)
+	1:
+
 	lis r12, iret@ha
 	addi r12, r12, iret@l
 	mtlr r12
-	
+
 	lis r12, exc_dispatch@ha
 	addi r12, r12, exc_dispatch@l
 	mtsrr0 r12
-	
+
 	mfmsr r12
-	ori r12, r12, (MSR_IR | MSR_DR)@l
+	mfsrr1 r5
+	andi. r5, r5, MSR_FP
+	or r12, r12, r5		# Propagate MSR_FP from SRR1 to MSR
+	ori r12, r12, (MSR_IR | MSR_DR)
 	mtsrr1 r12
 	
 	addis sp, sp, 0x8000
 	mr r4, sp
-	addi r4, r4, 8
 	
 	rfi
@@ -276,7 +294,10 @@
 	addi r12, r12, iret_syscall@l
 	mtlr r12
-	
+
+	mfsrr1 r0
+	andi. r0, r0, MSR_FP
 	mfmsr r12
-	ori r12, r12, (MSR_IR | MSR_DR)@l
+	or r12, r12, r0		# Propagate MSR_FP from SRR1 to MSR
+	ori r12, r12, (MSR_IR | MSR_DR)
 	mtsrr1 r12
 	
Index: kernel/arch/ppc32/src/fpu_context.S
===================================================================
--- kernel/arch/ppc32/src/fpu_context.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/src/fpu_context.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -28,5 +28,6 @@
 
 #include <arch/asm/regname.h>
-#include <arch/context_offset.h>
+#include <arch/fpu_context_struct.h>
+#include <arch/msr.h>
 
 .text
@@ -39,67 +40,111 @@
 
 .macro FPU_CONTEXT_STORE r
-	stfd fr14, OFFSET_FR14(\r)
-	stfd fr15, OFFSET_FR15(\r)
-	stfd fr16, OFFSET_FR16(\r)
-	stfd fr17, OFFSET_FR17(\r)
-	stfd fr18, OFFSET_FR18(\r)
-	stfd fr19, OFFSET_FR19(\r)
-	stfd fr20, OFFSET_FR20(\r)
-	stfd fr21, OFFSET_FR21(\r)
-	stfd fr22, OFFSET_FR22(\r)
-	stfd fr23, OFFSET_FR23(\r)
-	stfd fr24, OFFSET_FR24(\r)
-	stfd fr25, OFFSET_FR25(\r)
-	stfd fr26, OFFSET_FR26(\r)
-	stfd fr27, OFFSET_FR27(\r)
-	stfd fr28, OFFSET_FR28(\r)
-	stfd fr29, OFFSET_FR29(\r)
-	stfd fr30, OFFSET_FR30(\r)
-	stfd fr31, OFFSET_FR31(\r)
+	stfd fr0, FPU_CONTEXT_OFFSET_FR0(\r)
+	stfd fr1, FPU_CONTEXT_OFFSET_FR1(\r)
+	stfd fr2, FPU_CONTEXT_OFFSET_FR2(\r)
+	stfd fr3, FPU_CONTEXT_OFFSET_FR3(\r)
+	stfd fr4, FPU_CONTEXT_OFFSET_FR4(\r)
+	stfd fr5, FPU_CONTEXT_OFFSET_FR5(\r)
+	stfd fr6, FPU_CONTEXT_OFFSET_FR6(\r)
+	stfd fr7, FPU_CONTEXT_OFFSET_FR7(\r)
+	stfd fr8, FPU_CONTEXT_OFFSET_FR8(\r)
+	stfd fr9, FPU_CONTEXT_OFFSET_FR9(\r)
+	stfd fr10, FPU_CONTEXT_OFFSET_FR10(\r)
+	stfd fr11, FPU_CONTEXT_OFFSET_FR11(\r)
+	stfd fr12, FPU_CONTEXT_OFFSET_FR12(\r)
+	stfd fr13, FPU_CONTEXT_OFFSET_FR13(\r)
+	stfd fr14, FPU_CONTEXT_OFFSET_FR14(\r)
+	stfd fr15, FPU_CONTEXT_OFFSET_FR15(\r)
+	stfd fr16, FPU_CONTEXT_OFFSET_FR16(\r)
+	stfd fr17, FPU_CONTEXT_OFFSET_FR17(\r)
+	stfd fr18, FPU_CONTEXT_OFFSET_FR18(\r)
+	stfd fr19, FPU_CONTEXT_OFFSET_FR19(\r)
+	stfd fr20, FPU_CONTEXT_OFFSET_FR20(\r)
+	stfd fr21, FPU_CONTEXT_OFFSET_FR21(\r)
+	stfd fr22, FPU_CONTEXT_OFFSET_FR22(\r)
+	stfd fr23, FPU_CONTEXT_OFFSET_FR23(\r)
+	stfd fr24, FPU_CONTEXT_OFFSET_FR24(\r)
+	stfd fr25, FPU_CONTEXT_OFFSET_FR25(\r)
+	stfd fr26, FPU_CONTEXT_OFFSET_FR26(\r)
+	stfd fr27, FPU_CONTEXT_OFFSET_FR27(\r)
+	stfd fr28, FPU_CONTEXT_OFFSET_FR28(\r)
+	stfd fr29, FPU_CONTEXT_OFFSET_FR29(\r)
+	stfd fr30, FPU_CONTEXT_OFFSET_FR30(\r)
+	stfd fr31, FPU_CONTEXT_OFFSET_FR31(\r)
 .endm
 
 .macro FPU_CONTEXT_LOAD r
-	lfd fr14, OFFSET_FR14(\r)
-	lfd fr15, OFFSET_FR15(\r)
-	lfd fr16, OFFSET_FR16(\r)
-	lfd fr17, OFFSET_FR17(\r)
-	lfd fr18, OFFSET_FR18(\r)
-	lfd fr19, OFFSET_FR19(\r)
-	lfd fr20, OFFSET_FR20(\r)
-	lfd fr21, OFFSET_FR21(\r)
-	lfd fr22, OFFSET_FR22(\r)
-	lfd fr23, OFFSET_FR23(\r)
-	lfd fr24, OFFSET_FR24(\r)
-	lfd fr25, OFFSET_FR25(\r)
-	lfd fr26, OFFSET_FR26(\r)
-	lfd fr27, OFFSET_FR27(\r)
-	lfd fr28, OFFSET_FR28(\r)
-	lfd fr29, OFFSET_FR29(\r)
-	lfd fr30, OFFSET_FR30(\r)
-	lfd fr31, OFFSET_FR31(\r)
+	lfd fr0, FPU_CONTEXT_OFFSET_FR0(\r)
+	lfd fr1, FPU_CONTEXT_OFFSET_FR1(\r)
+	lfd fr2, FPU_CONTEXT_OFFSET_FR2(\r)
+	lfd fr3, FPU_CONTEXT_OFFSET_FR3(\r)
+	lfd fr4, FPU_CONTEXT_OFFSET_FR4(\r)
+	lfd fr5, FPU_CONTEXT_OFFSET_FR5(\r)
+	lfd fr6, FPU_CONTEXT_OFFSET_FR6(\r)
+	lfd fr7, FPU_CONTEXT_OFFSET_FR7(\r)
+	lfd fr8, FPU_CONTEXT_OFFSET_FR8(\r)
+	lfd fr9, FPU_CONTEXT_OFFSET_FR9(\r)
+	lfd fr10, FPU_CONTEXT_OFFSET_FR10(\r)
+	lfd fr11, FPU_CONTEXT_OFFSET_FR11(\r)
+	lfd fr12, FPU_CONTEXT_OFFSET_FR12(\r)
+	lfd fr13, FPU_CONTEXT_OFFSET_FR13(\r)
+	lfd fr14, FPU_CONTEXT_OFFSET_FR14(\r)
+	lfd fr15, FPU_CONTEXT_OFFSET_FR15(\r)
+	lfd fr16, FPU_CONTEXT_OFFSET_FR16(\r)
+	lfd fr17, FPU_CONTEXT_OFFSET_FR17(\r)
+	lfd fr18, FPU_CONTEXT_OFFSET_FR18(\r)
+	lfd fr19, FPU_CONTEXT_OFFSET_FR19(\r)
+	lfd fr20, FPU_CONTEXT_OFFSET_FR20(\r)
+	lfd fr21, FPU_CONTEXT_OFFSET_FR21(\r)
+	lfd fr22, FPU_CONTEXT_OFFSET_FR22(\r)
+	lfd fr23, FPU_CONTEXT_OFFSET_FR23(\r)
+	lfd fr24, FPU_CONTEXT_OFFSET_FR24(\r)
+	lfd fr25, FPU_CONTEXT_OFFSET_FR25(\r)
+	lfd fr26, FPU_CONTEXT_OFFSET_FR26(\r)
+	lfd fr27, FPU_CONTEXT_OFFSET_FR27(\r)
+	lfd fr28, FPU_CONTEXT_OFFSET_FR28(\r)
+	lfd fr29, FPU_CONTEXT_OFFSET_FR29(\r)
+	lfd fr30, FPU_CONTEXT_OFFSET_FR30(\r)
+	lfd fr31, FPU_CONTEXT_OFFSET_FR31(\r)
 .endm
 
 fpu_context_save:
-//	FPU_CONTEXT_STORE r3
-//	
-//	mffs fr0
-//	stfd fr0, OFFSET_FPSCR(r3)
+	FPU_CONTEXT_STORE r3
+	
+	mffs fr0
+	stfd fr0, FPU_CONTEXT_OFFSET_FPSCR(r3)
 	
 	blr
 
 fpu_context_restore:
-//	FPU_CONTEXT_LOAD r3
-//	
-//	lfd fr0, OFFSET_FPSCR(r3)
-//	mtfsf 7, fr0
+	lfd fr0, FPU_CONTEXT_OFFSET_FPSCR(r3)
+	mtfsf 7, fr0
+
+	FPU_CONTEXT_LOAD r3
 	
 	blr
 
 fpu_init:
+	mfmsr r0
+	ori r0, r0, MSR_FP
+
+	# Disable FPU exceptions
+	li r3, MSR_FE0 | MSR_FE1
+	andc r0, r0, r3
+
+	mtmsr r0
 	blr
 
 fpu_enable:
+	mfmsr r0
+	ori r0, r0, MSR_FP
+	mtmsr r0
 	blr
 
 fpu_disable:
+	mfmsr r0
+	li r3, MSR_FP
+	andc r0, r0, r3
+	mtmsr r0
 	blr
+
Index: kernel/arch/ppc32/src/interrupt.c
===================================================================
--- kernel/arch/ppc32/src/interrupt.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/src/interrupt.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,7 +36,7 @@
 #include <interrupt.h>
 #include <arch/interrupt.h>
+#include <arch/istate.h>
 #include <typedefs.h>
 #include <arch.h>
-#include <time/clock.h>
 #include <ipc/sysipc.h>
 #include <arch/drivers/pic.h>
@@ -46,9 +46,17 @@
 #include <log.h>
 
-void start_decrementer(void)
+static uint32_t decrementer_value;
+
+void decrementer_start(uint32_t val)
+{
+	decrementer_value = val;
+	decrementer_restart();
+}
+
+void decrementer_restart(void)
 {
 	asm volatile (
 		"mtdec %[dec]\n"
-		:: [dec] "r" (1000)
+		:: [dec] "r" (decrementer_value)
 	);
 }
@@ -104,5 +112,5 @@
 {
 	uint8_t inum;
-	
+
 	while ((inum = pic_get_pending()) != 255) {
 		irq_t *irq = irq_dispatch_and_lock(inum);
@@ -138,7 +146,22 @@
 }
 
+static void exception_fp_unavailable(unsigned int n, istate_t *istate)
+{
+#ifdef CONFIG_FPU_LAZY
+	scheduler_fpu_lazy_request();
+	/*
+	 * Propagate MSR_FP from MSR back to istate's SRR1, which will become
+	 * the next MSR.
+	 */
+	istate->srr1 |= msr_read() & MSR_FP;
+#else
+	fault_if_from_uspace(istate, "FPU fault.");
+	panic_badtrap(istate, n, "FPU fault.");
+#endif
+}
+
 static void exception_decrementer(unsigned int n, istate_t *istate)
 {
-	start_decrementer();
+	decrementer_restart();
 	clock();
 }
@@ -153,4 +176,6 @@
 	exc_register(VECTOR_EXTERNAL, "external", true,
 	    exception_external);
+	exc_register(VECTOR_FP_UNAVAILABLE, "fp_unavailable", true,
+	    exception_fp_unavailable);
 	exc_register(VECTOR_DECREMENTER, "timer", true,
 	    exception_decrementer);
Index: kernel/arch/ppc32/src/ppc32.c
===================================================================
--- kernel/arch/ppc32/src/ppc32.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/ppc32/src/ppc32.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -47,4 +47,5 @@
 #include <mm/page.h>
 #include <mm/km.h>
+#include <time/clock.h>
 #include <abi/proc/uarg.h>
 #include <console/console.h>
@@ -99,6 +100,25 @@
 	interrupt_init();
 	
+	ofw_tree_node_t *cpus_node;
+	ofw_tree_node_t *cpu_node;
+	ofw_tree_property_t *freq_prop;
+
+	cpus_node = ofw_tree_lookup("/cpus");
+	if (!cpus_node)
+		panic("Could not find cpus node.");
+
+	cpu_node = cpus_node->child;
+	if (!cpu_node)
+		panic("Could not find first cpu.");	
+
+	freq_prop = ofw_tree_getprop(cpu_node, "timebase-frequency");
+	if (!freq_prop)
+		panic("Could not get frequency property.");
+
+	uint32_t freq;
+	freq = *((uint32_t *) freq_prop->value);
+
 	/* Start decrementer */
-	start_decrementer();
+	decrementer_start(freq / HZ);
 }
 
Index: kernel/arch/sparc32/Makefile.inc
===================================================================
--- kernel/arch/sparc32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/sparc32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -45,5 +45,4 @@
 	arch/$(KARCH)/src/exception.c \
 	arch/$(KARCH)/src/cpu/cpu.c \
-	arch/$(KARCH)/src/ddi/ddi.c \
 	arch/$(KARCH)/src/smp/smp.c \
 	arch/$(KARCH)/src/smp/ipi.c \
Index: rnel/arch/sparc32/src/ddi/ddi.c
===================================================================
--- kernel/arch/sparc32/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Copyright (c) 2010 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 sparc32ddi
- * @{
- */
-/** @file
- *  @brief DDI.
- */
-
-#include <ddi/ddi.h>
-#include <proc/task.h>
-#include <typedefs.h>
-
-/** Enable I/O space range for task.
- *
- */
-int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
-{
-	return 0;
-}
-
-/** @}
- */
Index: kernel/arch/sparc64/Makefile.inc
===================================================================
--- kernel/arch/sparc64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/sparc64/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -81,5 +81,4 @@
 	arch/$(KARCH)/src/trap/exception.c \
 	arch/$(KARCH)/src/trap/interrupt.c \
-	arch/$(KARCH)/src/ddi/ddi.c \
 	arch/$(KARCH)/src/drivers/tick.c \
 	arch/$(KARCH)/src/drivers/kbd.c \
@@ -108,2 +107,6 @@
 		arch/$(KARCH)/src/mm/$(USARCH)/tsb.c
 endif
+
+ARCH_AUTOGENS_AG = \
+	arch/$(KARCH)/include/arch/istate_struct.ag
+
Index: kernel/arch/sparc64/include/arch/istate.h
===================================================================
--- kernel/arch/sparc64/include/arch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/sparc64/include/arch/istate.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -41,17 +41,13 @@
 #ifdef KERNEL
 
+#include <arch/istate_struct.h>
 #include <arch/regdef.h>
 
 #else /* KERNEL */
 
+#include <libarch/istate_struct.h>
 #include <libarch/regdef.h>
 
 #endif /* KERNEL */
-
-typedef struct istate {
-	uint64_t tnpc;
-	uint64_t tpc;
-	uint64_t tstate;
-} istate_t;
 
 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
Index: kernel/arch/sparc64/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/sparc64/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/arch/sparc64/include/arch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,57 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : istate,
+
+        includes : [
+                {
+                        guard : KERNEL,
+                        include : <typedefs.h>
+                },
+                {
+                        negative-guard : KERNEL,
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : tnpc,
+                        type : uint64_t
+                },
+                {
+                        name : tpc,
+                        type : uint64_t
+                },
+                {
+                        name : tstate,
+                        type : uint64_t
+                }
+        ]
+}
+
Index: kernel/arch/sparc64/include/arch/trap/trap_table.h
===================================================================
--- kernel/arch/sparc64/include/arch/trap/trap_table.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/arch/sparc64/include/arch/trap/trap_table.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,4 +37,5 @@
 
 #include <arch/stack.h>
+#include <arch/istate_struct.h>
 
 #define TRAP_TABLE_ENTRY_COUNT	1024
@@ -42,7 +43,8 @@
 #define TRAP_TABLE_SIZE		(TRAP_TABLE_ENTRY_COUNT * TRAP_TABLE_ENTRY_SIZE)
 
+#define ISTATE_END_OFFSET(o)	((o) - ISTATE_SIZE)
+
 /*
- * The following needs to be in sync with the definition of the istate
- * structure. The one STACK_ITEM_SIZE is counted for space holding the 7th
+ * The one STACK_ITEM_SIZE is counted for space holding the 7th
  * argument to syscall_handler (i.e. syscall number) and the other
  * STACK_ITEM_SIZE is counted because of the required alignment.
@@ -50,17 +52,19 @@
 #define PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE \
     (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE + \
-    (2 * STACK_ITEM_SIZE) + (12 * 8))
-#define SAVED_TSTATE	-(1 * 8)
-#define SAVED_TPC	-(2 * 8)
-#define SAVED_TNPC	-(3 * 8)	/* <-- istate_t begins here */
-#define SAVED_Y		-(4 * 8)
-#define SAVED_I0	-(5 * 8)
-#define SAVED_I1	-(6 * 8)
-#define SAVED_I2	-(7 * 8)
-#define SAVED_I3	-(8 * 8)
-#define SAVED_I4	-(9 * 8)
-#define SAVED_I5	-(10 * 8)
-#define SAVED_I6	-(11 * 8)
-#define SAVED_I7	-(12 * 8)
+    (2 * STACK_ITEM_SIZE) + (ISTATE_SIZE + 9 * 8))
+/* <-- istate_t ends here */
+#define SAVED_TSTATE	ISTATE_END_OFFSET(ISTATE_OFFSET_TSTATE)	
+#define SAVED_TPC	ISTATE_END_OFFSET(ISTATE_OFFSET_TPC)
+#define SAVED_TNPC	ISTATE_END_OFFSET(ISTATE_OFFSET_TNPC)
+/* <-- istate_t begins here */
+#define SAVED_Y		-(1 * 8 + ISTATE_SIZE)
+#define SAVED_I0	-(2 * 8 + ISTATE_SIZE)
+#define SAVED_I1	-(3 * 8 + ISTATE_SIZE)
+#define SAVED_I2	-(4 * 8 + ISTATE_SIZE)
+#define SAVED_I3	-(5 * 8 + ISTATE_SIZE)
+#define SAVED_I4	-(6 * 8 + ISTATE_SIZE)
+#define SAVED_I5	-(7 * 8 + ISTATE_SIZE)
+#define SAVED_I6	-(8 * 8 + ISTATE_SIZE)
+#define SAVED_I7	-(9 * 8 + ISTATE_SIZE)
 
 #ifndef __ASM__
Index: rnel/arch/sparc64/src/ddi/ddi.c
===================================================================
--- kernel/arch/sparc64/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,55 +1,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup sparc64ddi
- * @{
- */
-/** @file
- */
-
-#include <ddi/ddi.h>
-#include <proc/task.h>
-#include <typedefs.h>
-
-/** Enable I/O space range for task.
- *
- * Interrupts are disabled and task is locked.
- *
- * @param task Task.
- * @param ioaddr Starting I/O space address.
- * @param size Size of the enabled I/O range.
- *
- * @return 0 on success or an error code from errno.h.
- */
-int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
-{
-	return 0;
-}
-
-/** @}
- */
Index: kernel/genarch/Makefile.inc
===================================================================
--- kernel/genarch/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/genarch/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -181,2 +181,13 @@
 		genarch/src/drivers/ega/ega.c
 endif
+
+ifeq ($(CONFIG_IOMAP_BITMAP), y)
+	GENARCH_SOURCES += \
+		genarch/src/ddi/ddi-bitmap.c
+endif
+
+ifeq ($(CONFIG_IOMAP_DUMMY), y)
+	GENARCH_SOURCES += \
+		genarch/src/ddi/ddi-dummy.c
+endif
+
Index: kernel/genarch/src/ddi/ddi-bitmap.c
===================================================================
--- kernel/genarch/src/ddi/ddi-bitmap.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/genarch/src/ddi/ddi-bitmap.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2006 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amd64ddi
+ * @{
+ */
+/** @file
+ */
+
+#include <ddi/ddi.h>
+#include <arch/ddi/ddi.h>
+#include <proc/task.h>
+#include <typedefs.h>
+#include <adt/bitmap.h>
+#include <mm/slab.h>
+#include <arch/pm.h>
+#include <errno.h>
+#include <arch/cpu.h>
+#include <cpu.h>
+#include <arch.h>
+#include <align.h>
+
+/** Enable I/O space range for task.
+ *
+ * Interrupts are disabled and task is locked.
+ *
+ * @param task   Task.
+ * @param ioaddr Starting I/O space address.
+ * @param size   Size of the enabled I/O range.
+ *
+ * @return EOK on success or an error code from errno.h.
+ *
+ */
+int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
+{
+	size_t elements = ioaddr + size;
+	if (elements > IO_PORTS)
+		return ENOENT;
+	
+	if (task->arch.iomap.elements < elements) {
+		/*
+		 * The I/O permission bitmap is too small and needs to be grown.
+		 */
+		
+		void *store = malloc(bitmap_size(elements), FRAME_ATOMIC);
+		if (!store)
+			return ENOMEM;
+		
+		bitmap_t oldiomap;
+		bitmap_initialize(&oldiomap, task->arch.iomap.elements,
+		    task->arch.iomap.bits);
+		
+		bitmap_initialize(&task->arch.iomap, elements, store);
+		
+		/*
+		 * Mark the new range inaccessible.
+		 */
+		bitmap_set_range(&task->arch.iomap, oldiomap.elements,
+		    elements - oldiomap.elements);
+		
+		/*
+		 * In case there really existed smaller iomap,
+		 * copy its contents and deallocate it.
+		 */
+		if (oldiomap.bits) {
+			bitmap_copy(&task->arch.iomap, &oldiomap,
+			    oldiomap.elements);
+			
+			free(oldiomap.bits);
+		}
+	}
+	
+	/*
+	 * Enable the range and we are done.
+	 */
+	bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);
+	
+	/*
+	 * Increment I/O Permission bitmap generation counter.
+	 */
+	task->arch.iomapver++;
+	
+	return EOK;
+}
+
+/** Disable I/O space range for task.
+ *
+ * Interrupts are disabled and task is locked.
+ *
+ * @param task   Task.
+ * @param ioaddr Starting I/O space address.
+ * @param size   Size of the enabled I/O range.
+ *
+ * @return EOK on success or an error code from errno.h.
+ *
+ */
+int ddi_iospace_disable_arch(task_t *task, uintptr_t ioaddr, size_t size)
+{
+	size_t elements = ioaddr + size;
+	if (elements > IO_PORTS)
+		return ENOENT;
+	
+	if (ioaddr >= task->arch.iomap.elements)
+		return EINVAL;	
+
+	if (task->arch.iomap.elements < elements)
+		size -= elements - task->arch.iomap.elements;
+
+	/*
+	 * Disable the range.
+	 */
+	bitmap_set_range(&task->arch.iomap, (size_t) ioaddr, size);
+	
+	/*
+	 * Increment I/O Permission bitmap generation counter.
+	 */
+	task->arch.iomapver++;
+	
+	return 0;
+}
+
+/** @}
+ */
Index: kernel/genarch/src/ddi/ddi-dummy.c
===================================================================
--- kernel/genarch/src/ddi/ddi-dummy.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ kernel/genarch/src/ddi/ddi-dummy.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2006 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup genarch 
+ * @{
+ */
+/** @file
+ *  @brief DDI.
+ */
+
+#include <ddi/ddi.h>
+#include <proc/task.h>
+#include <typedefs.h>
+
+/** Enable I/O space range for task.
+ *
+ * Interrupts are disabled and task is locked.
+ *
+ * @param task   Task.
+ * @param ioaddr Starting I/O space address.
+ * @param size   Size of the enabled I/O range.
+ *
+ * @return EOK on success or an error code from errno.h.
+ */
+int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
+{
+	return 0;
+}
+
+/** Disable I/O space range for task.
+ *
+ * Interrupts are disabled and task is locked.
+ *
+ * @param task   Task.
+ * @param ioaddr Starting I/O space address.
+ * @param size   Size of the disabled I/O range.
+ *
+ * @return EOK on success or an error code from errno.h.
+ */
+int ddi_iospace_disable_arch(task_t *task, uintptr_t ioaddr, size_t size)
+{
+	return 0;
+}
+
+/** @}
+ */
Index: kernel/generic/include/console/console.h
===================================================================
--- kernel/generic/include/console/console.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/include/console/console.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -76,5 +76,5 @@
 extern void release_console(void);
 
-extern sysarg_t sys_debug_activate_console(void);
+extern sysarg_t sys_debug_console(void);
 
 #endif /* KERN_CONSOLE_H_ */
Index: kernel/generic/include/ddi/ddi.h
===================================================================
--- kernel/generic/include/ddi/ddi.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/include/ddi/ddi.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -70,4 +70,5 @@
  */
 extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t);
+extern int ddi_iospace_disable_arch(task_t *, uintptr_t, size_t);
 
 #endif
Index: kernel/generic/include/interrupt.h
===================================================================
--- kernel/generic/include/interrupt.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/include/interrupt.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -45,4 +45,5 @@
 #include <ddi/irq.h>
 #include <stacktrace.h>
+#include <arch/istate.h>
 
 typedef void (* iroutine_t)(unsigned int, istate_t *);
Index: kernel/generic/include/ipc/event.h
===================================================================
--- kernel/generic/include/ipc/event.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/include/ipc/event.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -100,6 +100,7 @@
     sysarg_t, sysarg_t, sysarg_t);
 
-extern sysarg_t sys_event_subscribe(sysarg_t, sysarg_t);
-extern sysarg_t sys_event_unmask(sysarg_t);
+extern sysarg_t sys_ipc_event_subscribe(sysarg_t, sysarg_t);
+extern sysarg_t sys_ipc_event_unsubscribe(sysarg_t);
+extern sysarg_t sys_ipc_event_unmask(sysarg_t);
 
 #endif
Index: kernel/generic/include/ipc/irq.h
===================================================================
--- kernel/generic/include/ipc/irq.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/include/ipc/irq.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -47,5 +47,5 @@
 #include <adt/list.h>
 
-extern int ipc_irq_register(answerbox_t *, inr_t, devno_t, sysarg_t,
+extern int ipc_irq_subscribe(answerbox_t *, inr_t, devno_t, sysarg_t,
     irq_code_t *);
 
@@ -53,5 +53,5 @@
 extern void ipc_irq_top_half_handler(irq_t *);
 
-extern int ipc_irq_unregister(answerbox_t *, inr_t, devno_t);
+extern int ipc_irq_unsubscribe(answerbox_t *, inr_t, devno_t);
 extern void ipc_irq_cleanup(answerbox_t *);
 
Index: kernel/generic/include/ipc/sysipc.h
===================================================================
--- kernel/generic/include/ipc/sysipc.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/include/ipc/sysipc.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -53,6 +53,7 @@
     unsigned int);
 extern sysarg_t sys_ipc_hangup(sysarg_t);
-extern sysarg_t sys_irq_register(inr_t, devno_t, sysarg_t, irq_code_t *);
-extern sysarg_t sys_irq_unregister(inr_t, devno_t);
+
+extern sysarg_t sys_ipc_irq_subscribe(inr_t, devno_t, sysarg_t, irq_code_t *);
+extern sysarg_t sys_ipc_irq_unsubscribe(inr_t, devno_t);
 
 #ifdef __32_BITS__
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/console/cmd.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -1357,6 +1357,4 @@
 	printf("The kernel will now relinquish the console.\n");
 	release_console();
-	
-	event_notify_0(EVENT_KCONSOLE, false);
 	indev_pop_character(stdin);
 	
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/console/console.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -204,4 +204,5 @@
 void grab_console(void)
 {
+	event_notify_1(EVENT_KCONSOLE, false, true);
 	bool prev = console_override;
 	
@@ -221,8 +222,9 @@
 {
 	console_override = false;
+	event_notify_1(EVENT_KCONSOLE, false, false);
 }
 
 /** Activate kernel console override */
-sysarg_t sys_debug_activate_console(void)
+sysarg_t sys_debug_console(void)
 {
 #ifdef CONFIG_KCONSOLE
Index: kernel/generic/src/ddi/ddi.c
===================================================================
--- kernel/generic/src/ddi/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/ddi/ddi.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -211,6 +211,7 @@
 NO_TRACE static int physmem_unmap(uintptr_t virt)
 {
-	// TODO: implement unmap
-	return EOK;
+	ASSERT(TASK);
+
+	return as_area_destroy(TASK->as, virt);
 }
 
@@ -255,7 +256,7 @@
 /** Enable range of I/O space for task.
  *
- * @param id Task ID of the destination task.
+ * @param id     Task ID of the destination task.
  * @param ioaddr Starting I/O address.
- * @param size Size of the enabled I/O space..
+ * @param size   Size of the enabled I/O space.
  *
  * @return 0 on success, EPERM if the caller lacks capabilities to use this
@@ -290,4 +291,45 @@
 	int rc = ddi_iospace_enable_arch(task, ioaddr, size);
 	irq_spinlock_unlock(&task->lock, true);
+
+	return rc;
+}
+
+/** Disable range of I/O space for task.
+ *
+ * @param id     Task ID of the destination task.
+ * @param ioaddr Starting I/O address.
+ * @param size   Size of the enabled I/O space.
+ *
+ * @return 0 on success, EPERM if the caller lacks capabilities to use this
+ *           syscall, ENOENT if there is no task matching the specified ID.
+ *
+ */
+NO_TRACE static int iospace_disable(task_id_t id, uintptr_t ioaddr, size_t size)
+{
+	/*
+	 * Make sure the caller is authorised to make this syscall.
+	 */
+	cap_t caps = cap_get(TASK);
+	if (!(caps & CAP_IO_MANAGER))
+		return EPERM;
+	
+	irq_spinlock_lock(&tasks_lock, true);
+	
+	task_t *task = task_find_by_id(id);
+	
+	if ((!task) || (!container_check(CONTAINER, task->container))) {
+		/*
+		 * There is no task with the specified ID
+		 * or the task belongs to a different security
+		 * context.
+		 */
+		irq_spinlock_unlock(&tasks_lock, true);
+		return ENOENT;
+	}
+	
+	/* Lock the task and release the lock protecting tasks_btree. */
+	irq_spinlock_exchange(&tasks_lock, &task->lock);
+	int rc = ddi_iospace_disable_arch(task, ioaddr, size);
+	irq_spinlock_unlock(&task->lock, true);
 	
 	return rc;
@@ -314,6 +356,11 @@
 sysarg_t sys_iospace_disable(ddi_ioarg_t *uspace_io_arg)
 {
-	// TODO: implement
-	return ENOTSUP;
+	ddi_ioarg_t arg;
+	int rc = copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t));
+	if (rc != 0)
+		return (sysarg_t) rc;
+
+	return (sysarg_t) iospace_disable((task_id_t) arg.task_id,
+	    (uintptr_t) arg.ioaddr, (size_t) arg.size);
 }
 
Index: kernel/generic/src/ipc/event.c
===================================================================
--- kernel/generic/src/ipc/event.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/ipc/event.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -58,15 +58,15 @@
 }
 
-static event_t *evno2event(int evno, task_t *t)
+static event_t *evno2event(int evno, task_t *task)
 {
 	ASSERT(evno < EVENT_TASK_END);
-
+	
 	event_t *event;
-
+	
 	if (evno < EVENT_END)
 		event = &events[(event_type_t) evno];
 	else
-		event = &t->events[(event_task_type_t) evno - EVENT_END];
-
+		event = &task->events[(event_task_type_t) evno - EVENT_END];
+	
 	return event;
 }
@@ -86,5 +86,4 @@
 		event_initialize(evno2event(i, task));
 }
-
 
 /** Unsubscribe kernel events associated with an answerbox
@@ -260,5 +259,5 @@
 {
 	int res;
-
+	
 	spinlock_lock(&event->lock);
 	
@@ -277,4 +276,34 @@
 }
 
+/** Unsubscribe event notifications
+ *
+ * @param evno      Event type.
+ * @param answerbox Answerbox used to send the notifications to.
+ *
+ * @return EOK if the subscription was successful.
+ * @return EEXISTS if the notifications of the given type are
+ *         already subscribed.
+ *
+ */
+static int event_unsubscribe(event_t *event, answerbox_t *answerbox)
+{
+	int res;
+	
+	spinlock_lock(&event->lock);
+	
+	if (event->answerbox == answerbox) {
+		event->answerbox = NULL;
+		event->counter = 0;
+		event->imethod = 0;
+		event->masked = false;
+		res = EOK;
+	} else
+		res = ENOENT;
+	
+	spinlock_unlock(&event->lock);
+	
+	return res;
+}
+
 /** Unmask event notifications
  *
@@ -297,5 +326,5 @@
 }
 
-/** Event notification syscall wrapper
+/** Event notification subscription syscall wrapper
  *
  * @param evno    Event type to subscribe.
@@ -309,5 +338,5 @@
  *
  */
-sysarg_t sys_event_subscribe(sysarg_t evno, sysarg_t imethod)
+sysarg_t sys_ipc_event_subscribe(sysarg_t evno, sysarg_t imethod)
 {
 	if (evno >= EVENT_TASK_END)
@@ -316,4 +345,23 @@
 	return (sysarg_t) event_subscribe(evno2event(evno, TASK),
 	    (sysarg_t) imethod, &TASK->answerbox);
+}
+
+/** Event notification unsubscription syscall wrapper
+ *
+ * @param evno    Event type to unsubscribe.
+ *
+ * @return EOK on success.
+ * @return ELIMIT on unknown event type.
+ * @return ENOENT if the notification of the given type is not
+           subscribed.
+ *
+ */
+sysarg_t sys_ipc_event_unsubscribe(sysarg_t evno)
+{
+	if (evno >= EVENT_TASK_END)
+		return ELIMIT;
+	
+	return (sysarg_t) event_unsubscribe(evno2event(evno, TASK),
+	    &TASK->answerbox);
 }
 
@@ -331,5 +379,5 @@
  *
  */
-sysarg_t sys_event_unmask(sysarg_t evno)
+sysarg_t sys_ipc_event_unmask(sysarg_t evno)
 {
 	if (evno >= EVENT_TASK_END)
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/ipc/irq.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,5 +36,5 @@
  * @brief IRQ notification framework.
  *
- * This framework allows applications to register to receive a notification
+ * This framework allows applications to subscribe to receive a notification
  * when interrupt is detected. The application may provide a simple 'top-half'
  * handler as part of its registration, which can perform simple operations
@@ -42,6 +42,5 @@
  *
  * The structure of a notification message is as follows:
- * - IMETHOD: interface and method as registered by
- *            the SYS_IRQ_REGISTER syscall
+ * - IMETHOD: interface and method as set by the SYS_IPC_IRQ_SUBSCRIBE syscall
  * - ARG1: payload modified by a 'top-half' handler (scratch[1])
  * - ARG2: payload modified by a 'top-half' handler (scratch[2])
@@ -52,5 +51,5 @@
  *                  in multithreaded drivers)
  *
- * Note on synchronization for ipc_irq_register(), ipc_irq_unregister(),
+ * Note on synchronization for ipc_irq_subscribe(), ipc_irq_unsubscribe(),
  * ipc_irq_cleanup() and IRQ handlers:
  *
@@ -289,5 +288,5 @@
 }
 
-/** Register an answerbox as a receiving end for IRQ notifications.
+/** Subscribe an answerbox as a receiving end for IRQ notifications.
  *
  * @param box     Receiving answerbox.
@@ -301,5 +300,5 @@
  *
  */
-int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno,
+int ipc_irq_subscribe(answerbox_t *box, inr_t inr, devno_t devno,
     sysarg_t imethod, irq_code_t *ucode)
 {
@@ -369,5 +368,5 @@
 }
 
-/** Unregister task from IRQ notification.
+/** Unsubscribe task from IRQ notification.
  *
  * @param box   Answerbox associated with the notification.
@@ -378,5 +377,5 @@
  *
  */
-int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno)
+int ipc_irq_unsubscribe(answerbox_t *box, inr_t inr, devno_t devno)
 {
 	sysarg_t key[] = {
@@ -432,5 +431,5 @@
  *
  * This function is effective because the answerbox contains
- * list of all irq_t structures that are registered to
+ * list of all irq_t structures that are subscribed to
  * send notifications to it.
  *
Index: kernel/generic/src/ipc/sysipc.c
===================================================================
--- kernel/generic/src/ipc/sysipc.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/ipc/sysipc.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -736,8 +736,8 @@
  * @param ucode   Uspace pointer to the top-half pseudocode.
  *
- * @return EPERM or a return code returned by ipc_irq_register().
- *
- */
-sysarg_t sys_irq_register(inr_t inr, devno_t devno, sysarg_t imethod,
+ * @return EPERM or a return code returned by ipc_irq_subscribe().
+ *
+ */
+sysarg_t sys_ipc_irq_subscribe(inr_t inr, devno_t devno, sysarg_t imethod,
     irq_code_t *ucode)
 {
@@ -745,5 +745,5 @@
 		return EPERM;
 	
-	return ipc_irq_register(&TASK->answerbox, inr, devno, imethod, ucode);
+	return ipc_irq_subscribe(&TASK->answerbox, inr, devno, imethod, ucode);
 }
 
@@ -756,10 +756,10 @@
  *
  */
-sysarg_t sys_irq_unregister(inr_t inr, devno_t devno)
+sysarg_t sys_ipc_irq_unsubscribe(inr_t inr, devno_t devno)
 {
 	if (!(cap_get(TASK) & CAP_IRQ_REG))
 		return EPERM;
 	
-	ipc_irq_unregister(&TASK->answerbox, inr, devno);
+	ipc_irq_unsubscribe(&TASK->answerbox, inr, devno);
 	
 	return 0;
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/mm/as.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -572,5 +572,5 @@
  * @param attrs        Attributes of the area.
  * @param backend      Address space area backend. NULL if no backend is used.
- * @param backend_data NULL or a pointer to an array holding two void *.
+ * @param backend_data NULL or a pointer to custom backend data.
  * @param base         Starting virtual address of the area.
  *                     If set to -1, a suitable mappable area is found.
Index: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/proc/program.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -91,4 +91,5 @@
 	if (!area) {
 		task_destroy(prg->task);
+		prg->task = NULL;
 		return ENOMEM;
 	}
@@ -113,4 +114,5 @@
 		as_area_destroy(as, virt);
 		task_destroy(prg->task);
+		prg->task = NULL;
 		return ELIMIT;
 	}
Index: kernel/generic/src/syscall/syscall.c
===================================================================
--- kernel/generic/src/syscall/syscall.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ kernel/generic/src/syscall/syscall.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -165,6 +165,7 @@
 	
 	/* Event notification syscalls. */
-	(syshandler_t) sys_event_subscribe,
-	(syshandler_t) sys_event_unmask,
+	(syshandler_t) sys_ipc_event_subscribe,
+	(syshandler_t) sys_ipc_event_unsubscribe,
+	(syshandler_t) sys_ipc_event_unmask,
 	
 	/* Capabilities related syscalls. */
@@ -180,6 +181,7 @@
 	(syshandler_t) sys_iospace_enable,
 	(syshandler_t) sys_iospace_disable,
-	(syshandler_t) sys_irq_register,
-	(syshandler_t) sys_irq_unregister,
+	
+	(syshandler_t) sys_ipc_irq_subscribe,
+	(syshandler_t) sys_ipc_irq_unsubscribe,
 	
 	/* Sysinfo syscalls. */
@@ -192,5 +194,5 @@
 	
 	/* Kernel console syscalls. */
-	(syshandler_t) sys_debug_activate_console,
+	(syshandler_t) sys_debug_console,
 	
 	(syshandler_t) sys_klog,
Index: tools/autogen.py
===================================================================
--- tools/autogen.py	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ tools/autogen.py	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,159 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+import sys
+import yaml 
+import re
+
+def usage():
+	print("%s - Automated structure and offsets generator" % sys.argv[0])
+	print("%s file.ag probe|generate struct.ag" % sys.argv[0])
+	sys.exit()
+
+def generate_includes(struct):
+	code = ""
+	for include in struct['includes']:
+		if 'guard' in include.keys():
+			code = code + "#ifdef %s\n" % include['guard']
+		if 'negative-guard' in include.keys():
+			code = code + "#ifndef %s\n" % include['negative-guard']
+		code = code + "#include %s\n" % include['include']
+		if 'guard' in include.keys():
+			code = code + "#endif\n"
+		if 'negative-guard' in include.keys():
+			code = code + "#endif\n"
+	return code.strip()
+
+def generate_struct(struct):
+	code = "typedef struct %s {\n" % struct['name']
+	for i in range(len(struct['members'])):
+		member = struct['members'][i]
+		code = code + "\t%s %s;\n" % (member['type'], member['name'])
+	code = code + "} %s_t;" % struct['name']
+	return code
+
+def generate_probes(struct):
+	code = ""
+	for i in range(len(struct['members'])):
+		member = struct['members'][i]
+		code = code + ("\temit_constant(%s_OFFSET_%s, offsetof(%s_t, %s));\n" % 
+		    (struct['name'].upper(), member['name'].upper(), struct['name'],
+		    member['name']))
+	return code
+
+def probe(struct):
+	name = struct['name']
+	typename = struct['name'] + "_t"
+
+	code = """
+%s		
+
+#define str(s) #s
+#define emit_constant(n, v) \
+    asm volatile ("EMITTED_CONSTANT " str(n) \" = %%0\" :: \"i\" (v))
+#define offsetof(t, m) ((size_t) &(((t *) 0)->m))
+
+%s
+
+int main()
+{
+%s
+	emit_constant(%s_SIZE, sizeof(%s));
+	return 0;
+}
+	""" % (generate_includes(struct), generate_struct(struct),
+	    generate_probes(struct), name.upper(), typename)
+
+	return code
+
+def generate_defines(pairs):
+	code = ""
+	for pair in pairs:
+		code = code + "#define %s %s\n" % (pair[0], pair[1])
+	return code.strip()
+
+def generate(struct, lines):
+	code = """
+/***************************************************************************** 
+ * AUTO-GENERATED FILE, DO NOT EDIT!!!
+ * Generated by: tools/autogen.py
+ * Generated from: %s
+ *****************************************************************************/
+
+#ifndef AUTOGEN_%s_H
+#define AUTOGEN_%s_H
+
+#ifndef __ASM__
+%s
+#endif
+
+%s
+
+#ifndef __ASM__
+%s
+#endif
+
+#endif
+	""" % (sys.argv[2], struct['name'].upper(), struct['name'].upper(),
+	    generate_includes(struct), generate_defines(lines),
+	    generate_struct(struct))
+
+	return code
+
+def filter_pairs(lines):
+	pattern = re.compile("^\tEMITTED_CONSTANT ([A-Z_][A-Z0-9_]*) = (\$|#)?([0-9]+)$");
+	pairs = []
+	for line in lines:
+		res = pattern.match(line)
+		if res == None:
+			continue
+		pairs = pairs + [res.group(1, 3)]
+	return pairs
+	
+
+def run():
+	if len(sys.argv) != 3:
+		usage()
+
+	with open(sys.argv[2], "rb") as fp:
+		struct = yaml.load(fp)
+
+	if sys.argv[1] == "probe":
+		code = probe(struct)
+		print(code)
+	elif sys.argv[1] == "generate":
+		lines = sys.stdin.readlines()
+		pairs = filter_pairs(lines)
+		code = generate(struct, pairs)
+		print(code)
+	else:
+		usage()
+
+run()
+
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ tools/autotool.py	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -355,4 +355,18 @@
 	check_app([common['OBJDUMP'], "--version"], "GNU Objdump utility", details)
 	check_app([common['STRIP'], "--version"], "GNU strip", details)
+
+def check_python():
+	"Check for Python dependencies"
+	
+	try:
+		sys.stderr.write("Checking for PyYAML ... ")
+		import yaml
+	except ImportError:
+		print_error(["PyYAML is missing.",
+		             "",
+		             "Please make sure that it is installed in your",
+		             "system (usually part of PyYAML package)."])
+	
+	sys.stderr.write("ok\n")
 
 def decode_value(value):
@@ -810,4 +824,6 @@
 			common['CLANG_TARGET'] = clang_target
 		
+		check_python()
+		
 		# Platform-specific utilities
 		if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")):
@@ -834,4 +850,6 @@
 		sandbox_leave(owd)
 	
+	common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0]))
+
 	create_makefile(MAKEFILE, common)
 	create_header(HEADER, maps)
Index: tools/ew.py
===================================================================
--- tools/ew.py	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ tools/ew.py	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -137,5 +137,5 @@
 	if is_override('nosnd'):
 		return ''
-	return ' -soundhw sb16' 
+	return ' -device intel-hda -device hda-duplex'
 
 def qemu_run(platform, machine):
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,4 +44,5 @@
 	app/download \
 	app/edit \
+	app/fontviewer \
 	app/getterm \
 	app/hdisk \
@@ -132,9 +133,10 @@
 	drv/audio/hdaudio \
 	drv/audio/sb16 \
-	drv/infrastructure/root \
-	drv/infrastructure/rootvirt \
+	drv/root/root \
+	drv/root/virt \
 	drv/block/ahci \
 	drv/block/ata_bd \
 	drv/char/i8042 \
+	drv/char/pl050 \
 	drv/char/ps2mouse \
 	drv/char/xtkbd \
@@ -156,5 +158,6 @@
 	drv/nic/e1k \
 	drv/nic/rtl8139 \
-	drv/nic/rtl8169
+	drv/nic/rtl8169 \
+	drv/platform/icp
 
 ## Platform-specific hardware support
@@ -163,5 +166,5 @@
 ifeq ($(UARCH), $(filter $(UARCH),amd64 ia32 ia64))
 	DIRS += \
-		drv/infrastructure/rootpc \
+		drv/platform/pc \
 		drv/bus/pci/pciintel \
 		drv/bus/isa \
@@ -174,5 +177,5 @@
 ifeq ($(UARCH), $(filter $(UARCH),mips32 mips32eb))
 	DIRS += \
-		drv/infrastructure/rootmalta \
+		drv/platform/malta \
 		drv/bus/pci/pciintel \
 		drv/bus/isa
@@ -181,5 +184,5 @@
 ifeq ($(UARCH),ppc32)
 	DIRS += \
-		drv/infrastructure/rootmac \
+		drv/platform/mac \
 		drv/bus/pci/pciintel \
 		srv/hw/bus/cuda_adb
@@ -193,6 +196,7 @@
 ifeq ($(UARCH),arm32)
 	DIRS += \
-		drv/infrastructure/rootamdm37x \
-		drv/fb/amdm37x_dispc
+		drv/platform/amdm37x \
+		drv/fb/amdm37x_dispc \
+		srv/hw/irc/icp-ic
 endif
 
Index: uspace/app/bdsh/exec.c
===================================================================
--- uspace/app/bdsh/exec.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/bdsh/exec.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -97,4 +97,5 @@
 {
 	task_id_t tid;
+	task_wait_t twait;
 	task_exit_t texit;
 	char *tmp;
@@ -121,5 +122,5 @@
 	file_handles_p[i] = NULL;
 
-	rc = task_spawnvf(&tid, tmp, (const char **) argv, file_handles_p);
+	rc = task_spawnvf(&tid, &twait, tmp, (const char **) argv, file_handles_p);
 	free(tmp);
 
@@ -130,5 +131,5 @@
 	}
 	
-	rc = task_wait(tid, &texit, &retval);
+	rc = task_wait(&twait, &texit, &retval);
 	if (rc != EOK) {
 		printf("%s: Failed waiting for command (%s)\n", progname,
Index: uspace/app/blkdump/Makefile
===================================================================
--- uspace/app/blkdump/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/blkdump/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -30,5 +30,5 @@
 USPACE_PREFIX = ../..
 LIBS = $(LIBBLOCK_PREFIX)/libblock.a
-EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
+EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBSCSI_PREFIX)/include
 BINARY = blkdump
 
Index: uspace/app/blkdump/blkdump.c
===================================================================
--- uspace/app/blkdump/blkdump.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/blkdump/blkdump.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,4 +44,5 @@
 #include <loc.h>
 #include <byteorder.h>
+#include <scsi/mmc.h>
 #include <sys/types.h>
 #include <sys/typefmt.h>
@@ -214,13 +215,18 @@
 static int print_toc(void)
 {
-	toc_block_t *toc;
-
-	toc = block_get_toc(service_id, 0);
-	if (toc == NULL)
+	scsi_toc_multisess_data_t toc;
+	int rc;
+
+	rc = block_read_toc(service_id, 0, &toc, sizeof(toc));
+	if (rc != EOK)
 		return 1;
 
-	printf("TOC size: %" PRIu16 " bytes\n", toc->size);
-	printf("First session: %" PRIu8 "\n", toc->first_session);
-	printf("Last_session: %" PRIu8 "\n", toc->last_session);
+	printf("Multisession Information:\n");
+	printf("\tFirst complete session: %" PRIu8 "\n", toc.first_sess);
+	printf("\tLast complete session: %" PRIu8 "\n", toc.last_sess);
+	printf("\tFirst track of last complete session:\n");
+	printf("\t\tADR / Control: 0x%" PRIx8 "\n", toc.ftrack_lsess.adr_control);
+	printf("\t\tTrack number: %" PRIu8 "\n", toc.ftrack_lsess.track_no);
+	printf("\t\tStart block address: %" PRIu32 "\n", toc.ftrack_lsess.start_addr);
 
 	return 0;
@@ -271,5 +277,6 @@
 static void syntax_print(void)
 {
-	printf("syntax: blkdump [--relative] [--offset <num_blocks>] [--count <num_blocks>] <device_name>\n");
+	printf("syntax: blkdump [--toc] [--relative] [--offset <num_blocks>] "
+	    "[--count <num_blocks>] <device_name>\n");
 }
 
Index: uspace/app/fontviewer/Makefile
===================================================================
--- uspace/app/fontviewer/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/app/fontviewer/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,48 @@
+#
+# Copyright (c) 2014 Martin Sucha
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../..
+
+LIBS = \
+	$(LIBGUI_PREFIX)/libgui.a \
+	$(LIBDRAW_PREFIX)/libdraw.a \
+	$(LIBSOFTREND_PREFIX)/libsoftrend.a \
+	$(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
+
+EXTRA_CFLAGS += \
+	-I$(LIBGUI_PREFIX) \
+	-I$(LIBDRAW_PREFIX) \
+	-I$(LIBSOFTREND_PREFIX)
+
+BINARY = fontviewer
+MATH = y
+
+SOURCES = \
+	fontviewer.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/fontviewer/fontviewer.c
===================================================================
--- uspace/app/fontviewer/fontviewer.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/app/fontviewer/fontviewer.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,303 @@
+/*
+ * Copyright (c) 2014 Martin Sucha
+ * 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 fontviewer
+ * @{
+ */
+/** @file
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <malloc.h>
+#include <stdbool.h>
+#include <window.h>
+#include <canvas.h>
+#include <surface.h>
+#include <codec/tga.h>
+#include <task.h>
+#include <drawctx.h>
+#include <font/embedded.h>
+#include <font/pcf.h>
+#include <stdarg.h>
+#include <io/verify.h>
+
+#define NAME  "fontviewer"
+
+#define WINDOW_WIDTH   640
+#define WINDOW_HEIGHT  480
+
+static window_t *main_window;
+static surface_t *surface = NULL;
+static canvas_t *canvas = NULL;
+static surface_coord_t width, height;
+uint16_t points = 16;
+bool show_metrics = true;
+char *font_path = NULL;
+
+static int draw(void);
+
+static void on_keyboard_event(widget_t *widget, void *data)
+{
+	kbd_event_t *event = (kbd_event_t *) data;
+	
+	if (event->type == KEY_PRESS) {
+		if (event->c == 'q')
+			exit(0);
+		
+		if (event->key == KC_UP || event->key == KC_DOWN) {
+			uint16_t increment = (event->mods & KM_SHIFT) ? 10 : 1;
+
+			if (event->key == KC_UP)
+				points += increment;
+		
+			if ((event->key == KC_DOWN)) {
+				if (points <= increment) {
+					points = 1;
+				}
+				else {
+					points-= increment;
+				}
+			}
+			
+			if (points < 1)
+				points = 1;
+		}
+		
+		if (event->c == 'm')
+			show_metrics = !show_metrics;
+	}
+	
+	int rc = draw();
+	if (rc != EOK) {
+		printf("Failed drawing: %d.\n", rc);
+		exit(1);
+	}
+	update_canvas(canvas, surface);
+}
+
+static int create_font(font_t **font, uint16_t points)
+{
+	if (font_path == NULL) {
+		return embedded_font_create(font, points);
+	}
+	
+	return pcf_font_create(font, font_path, points);
+}
+
+static source_t rgb(uint8_t r, uint8_t g, uint8_t b)
+{
+	source_t source;
+	source_init(&source);
+	source_set_color(&source, PIXEL(255, r, g, b));
+	return source;
+}
+
+static void horizontal_rectangle(drawctx_t *drawctx, surface_coord_t x1,
+    surface_coord_t y1, surface_coord_t x2, surface_coord_t y2,
+    source_t *source)
+{
+	if (y2 < y1)
+		return;
+	
+	drawctx_set_source(drawctx, source);
+	drawctx_transfer(drawctx, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
+}
+
+static void horizontal_line(drawctx_t *drawctx, surface_coord_t y,
+    surface_coord_t x1, surface_coord_t x2, source_t *source)
+{
+	horizontal_rectangle(drawctx, x1, y, x2, y, source);
+}
+
+static int text(drawctx_t *, font_t *, source_t *, surface_coord_t x,
+    surface_coord_t , const char *, ...) PRINTF_ATTRIBUTE(6, 7);
+static int text(drawctx_t *drawctx, font_t *font, source_t *source,
+    surface_coord_t x, surface_coord_t y, const char *fmt, ...)
+{
+	char *str = NULL;
+	va_list args;
+	va_start(args, fmt);
+	int ret = vasprintf(&str, fmt, args);
+	va_end(args);
+	
+	if (ret <= 0)
+		return ret;
+	
+	drawctx_set_source(drawctx, source);
+	drawctx_set_font(drawctx, font);
+	drawctx_print(drawctx, str, x, y);
+	
+	free(str);
+	
+	return ret;
+}
+
+
+static int draw(void)
+{
+	source_t background = rgb(255, 255, 255);
+	source_t foreground = rgb(0, 0, 0);
+	source_t glyphs = rgb(0, 0, 255);
+	source_t ascender_bg = rgb(255, 230, 128);
+	source_t ascender_fg = rgb(255, 153, 85);
+	source_t descender_bg = rgb(204, 255, 170);
+	source_t descender_fg = rgb(85, 212, 0);
+	source_t leading_bg = rgb(170, 238, 255);
+	source_t leading_fg = rgb(0, 170, 212);
+	
+	font_t *font;
+	int rc = create_font(&font, points);
+	if (rc != EOK) {
+		printf("Failed creating font\n");
+		return rc;
+	}
+	
+	font_t *info_font;
+	rc = embedded_font_create(&info_font, 16);
+	if (rc != EOK) {
+		printf("Failed creating info font\n");
+		return rc;
+	}
+	
+	font_metrics_t font_metrics;
+	rc = font_get_metrics(font, &font_metrics);
+	if (rc != EOK)
+		return rc;
+	
+	surface_coord_t top = 50;
+	metric_t ascender_top = top;
+	metric_t descender_top = ascender_top + font_metrics.ascender;
+	metric_t leading_top = descender_top + font_metrics.descender;
+	metric_t line_bottom = leading_top + font_metrics.leading;
+
+	drawctx_t drawctx;
+	drawctx_init(&drawctx, surface);
+	
+	drawctx_set_source(&drawctx, &background);
+	drawctx_transfer(&drawctx, 0, 0,
+	    width, height);
+	
+	if (show_metrics) {
+		horizontal_rectangle(&drawctx, 0, ascender_top, width,
+		    descender_top - 1, &ascender_bg);
+		horizontal_line(&drawctx, ascender_top, 0, width,
+		    &ascender_fg);
+		
+		horizontal_rectangle(&drawctx, 0, descender_top, width,
+		    leading_top - 1, &descender_bg);
+		horizontal_line(&drawctx, descender_top, 0, width,
+		    &descender_fg);
+		
+		horizontal_rectangle(&drawctx, 0, leading_top,
+		    width, line_bottom - 1, &leading_bg);
+		horizontal_line(&drawctx, leading_top, 0, width,
+		    &leading_fg);
+	}
+	
+	drawctx_set_source(&drawctx, &glyphs);
+	drawctx_set_font(&drawctx, font);
+	drawctx_print(&drawctx, "Čaj'_", 0, top);
+	
+	if (show_metrics) {
+		surface_coord_t infos_top = line_bottom + 10;
+		text(&drawctx, info_font, &ascender_fg, 0, infos_top,
+		    "Ascender: %d", font_metrics.ascender);
+		text(&drawctx, info_font, &descender_fg, 0, infos_top + 16,
+		    "Descender: %d", font_metrics.descender);
+		text(&drawctx, info_font, &foreground, 0, infos_top + 32,
+		    "Line height: %d",
+		    font_metrics.ascender + font_metrics.descender);
+		text(&drawctx, info_font, &leading_fg, 0, infos_top + 48,
+		    "Leading: %d", font_metrics.leading);
+
+	}
+	
+	font_release(font);
+	return EOK;
+}
+
+int main(int argc, char *argv[])
+{
+	if (argc < 2) {
+		printf("Compositor server not specified.\n");
+		return 1;
+	}
+	
+	if (argc < 3) {
+		font_path = NULL;
+	}
+	else {
+		font_path = argv[2];
+	}
+	
+	main_window = window_open(argv[1], true, false, "fontviewer");
+	if (!main_window) {
+		printf("Cannot open main window.\n");
+		return 2;
+	}
+	
+	surface = surface_create(WINDOW_WIDTH, WINDOW_HEIGHT, NULL,
+	    SURFACE_FLAG_NONE);
+	if (surface == NULL) {
+		printf("Cannot create surface.\n");
+		return 2;
+	}
+	
+	width = WINDOW_WIDTH;
+	height = WINDOW_HEIGHT;
+	
+	int rc = draw();
+	if (rc != EOK) {
+		printf("Failed drawing: %d.\n", rc);
+		return 2;
+	}
+	
+	canvas = create_canvas(window_root(main_window),
+	    WINDOW_WIDTH, WINDOW_HEIGHT, surface);
+	if (canvas == NULL) {
+		printf("Cannot create canvas.\n");
+		return 2;
+	}
+	sig_connect(&canvas->keyboard_event, NULL, on_keyboard_event);
+	
+	window_resize(main_window, 200, 200, WINDOW_WIDTH, WINDOW_HEIGHT,
+	    WINDOW_PLACEMENT_ABSOLUTE);
+	window_exec(main_window);
+	
+	task_retval(0);
+	async_manager();
+	
+	return 0;
+}
+
+/** @}
+ */
Index: uspace/app/getterm/getterm.c
===================================================================
--- uspace/app/getterm/getterm.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/getterm/getterm.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -42,4 +42,5 @@
 #include <str_error.h>
 #include <errno.h>
+#include <loc.h>
 #include "version.h"
 #include "welcome.h"
@@ -49,8 +50,14 @@
 static void usage(void)
 {
-	printf("Usage: %s <terminal> [-w] <command> [<arguments...>]\n", APP_NAME);
+	printf("Usage: %s <terminal> <locfs> [--msg] [--wait] -- "
+	    "<command> [<arguments...>]\n", APP_NAME);
+	printf(" <terminal>    Terminal device\n");
+	printf(" <locfs>       Mount point of locfs\n");
+	printf(" --msg         Print welcome message\n");
+	printf(" --wait        Wait for the terminal to be ready\n");
 }
 
-static void reopen(FILE **stream, int fd, const char *path, int flags, const char *mode)
+static void reopen(FILE **stream, int fd, const char *path, int flags,
+    const char *mode)
 {
 	if (fclose(*stream))
@@ -76,48 +83,74 @@
 int main(int argc, char *argv[])
 {
-	int rc;
-	task_exit_t texit;
-	int retval;
-	task_id_t id;
-	char *fname, *term;
-	char **cmd_args;
-	bool print_wmsg;
-
 	argv++;
 	argc--;
+	if (argc < 4) {
+		usage();
+		return 1;
+	}
+	
+	char *term = *argv;
+	argv++;
+	argc--;
+	
+	char *locfs = *argv;
+	argv++;
+	argc--;
+	
+	bool print_msg = false;
+	bool wait = false;
+	
+	while ((argc > 0) && (str_cmp(*argv, "--") != 0)) {
+		if (str_cmp(*argv, "--msg") == 0) {
+			print_msg = true;
+		} else if (str_cmp(*argv, "--wait") == 0) {
+			wait = true;
+		} else {
+			usage();
+			return 2;
+		}
+		
+		argv++;
+		argc--;
+	}
+	
 	if (argc < 1) {
 		usage();
-		return -1;
+		return 3;
 	}
-
-	if (str_cmp(*argv, "-w") == 0) {
-		print_wmsg = true;
-		argv++;
-		argc--;
-	} else {
-		print_wmsg = false;
+	
+	/* Skip "--" */
+	argv++;
+	argc--;
+	
+	char *cmd = *argv;
+	char **args = argv;
+	
+	if (wait) {
+		/* Wait for the terminal service to be ready */
+		service_id_t service_id;
+		int rc = loc_service_get_id(term, &service_id, IPC_FLAG_BLOCKING);
+		if (rc != EOK) {
+			printf("%s: Error waiting on %s (%s)\n", APP_NAME, term,
+			    str_error(rc));
+			return rc;
+		}
 	}
-
-	if (argc < 2) {
-		usage();
-		return -1;
-	}
-
-	term = *argv++;
-	fname = *argv;
-	cmd_args = argv;
 	
-	reopen(&stdin, 0, term, O_RDONLY, "r");
-	reopen(&stdout, 1, term, O_WRONLY, "w");
-	reopen(&stderr, 2, term, O_WRONLY, "w");
+	char term_node[LOC_NAME_MAXLEN];
+	snprintf(term_node, LOC_NAME_MAXLEN, "%s/%s", locfs, term);
+	
+	reopen(&stdin, 0, term_node, O_RDONLY, "r");
+	reopen(&stdout, 1, term_node, O_WRONLY, "w");
+	reopen(&stderr, 2, term_node, O_WRONLY, "w");
 	
 	if (stdin == NULL)
-		return -2;
+		return 4;
 	
 	if (stdout == NULL)
-		return -3;
+		return 5;
 	
 	if (stderr == NULL)
-		return -4;
+		return 6;
 	
 	/*
@@ -128,21 +161,26 @@
 	
 	version_print(term);
-	if (print_wmsg)
+	if (print_msg)
 		welcome_msg_print();
-
-	rc = task_spawnv(&id, fname, (const char * const *) cmd_args);
+	
+	task_id_t id;
+	task_wait_t twait;
+	
+	int rc = task_spawnv(&id, &twait, cmd, (const char * const *) args);
 	if (rc != EOK) {
-		printf("%s: Error spawning %s (%s)\n", APP_NAME, fname,
+		printf("%s: Error spawning %s (%s)\n", APP_NAME, cmd,
 		    str_error(rc));
-		return -5;
+		return rc;
 	}
-
-	rc = task_wait(id, &texit, &retval);
+	
+	task_exit_t texit;
+	int retval;
+	rc = task_wait(&twait, &texit, &retval);
 	if (rc != EOK) {
-		printf("%s: Error waiting for %s (%s)\n", APP_NAME, fname,
+		printf("%s: Error waiting for %s (%s)\n", APP_NAME, cmd,
 		    str_error(rc));
-		return -6;
+		return rc;
 	}
-
+	
 	return 0;
 }
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/init/init.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -172,5 +172,6 @@
 	va_start(ap, path);
 	task_id_t id;
-	int rc = task_spawn(&id, path, cnt, ap);
+	task_wait_t wait;
+	int rc = task_spawn(&id, &wait, path, cnt, ap);
 	va_end(ap);
 	
@@ -189,5 +190,5 @@
 	task_exit_t texit;
 	int retval;
-	rc = task_wait(id, &texit, &retval);
+	rc = task_wait(&wait, &texit, &retval);
 	if (rc != EOK) {
 		printf("%s: Error waiting for %s (%s)\n", NAME, path,
@@ -253,5 +254,6 @@
 	
 	task_id_t id;
-	int rc = task_spawnl(&id, app, app, winreg, NULL);
+	task_wait_t wait;
+	int rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
 	if (rc != EOK) {
 		printf("%s: Error spawning %s %s (%s)\n", NAME, app,
@@ -262,5 +264,5 @@
 	task_exit_t texit;
 	int retval;
-	rc = task_wait(id, &texit, &retval);
+	rc = task_wait(&wait, &texit, &retval);
 	if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
 		printf("%s: Error retrieving retval from %s (%s)\n", NAME,
@@ -272,34 +274,24 @@
 }
 
-static void getterm(const char *svc, const char *app, bool wmsg)
-{
-	char term[LOC_NAME_MAXLEN];
-	snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc);
-	
-	printf("%s: Spawning %s %s %s\n", NAME, APP_GETTERM, term, app);
-	
-	/* Wait for the terminal service to be ready */
-	service_id_t service_id;
-	int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);
-	if (rc != EOK) {
-		printf("%s: Error waiting on %s (%s)\n", NAME, term,
-		    str_error(rc));
-		return;
-	}
-	
-	if (wmsg) {
-		rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, "-w", term,
-		    app, NULL);
-		if (rc != EOK) {
-			printf("%s: Error spawning %s -w %s %s (%s)\n", NAME,
-			    APP_GETTERM, term, app, str_error(rc));
-		}
+static void getterm(const char *svc, const char *app, bool msg)
+{
+	if (msg) {
+		printf("%s: Spawning %s %s %s --msg --wait -- %s\n", NAME,
+		    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
+		
+		int rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
+		    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
+		if (rc != EOK)
+			printf("%s: Error spawning %s %s %s --msg --wait -- %s\n",
+			    NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
 	} else {
-		rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, term, app,
-		    NULL);
-		if (rc != EOK) {
-			printf("%s: Error spawning %s %s %s (%s)\n", NAME,
-			    APP_GETTERM, term, app, str_error(rc));
-		}
+		printf("%s: Spawning %s %s %s --wait -- %s\n", NAME,
+		    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
+		
+		int rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
+		    LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);
+		if (rc != EOK)
+			printf("%s: Error spawning %s %s %s --wait -- %s\n",
+			    NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
 	}
 }
@@ -339,4 +331,5 @@
 	srv_start("/srv/apic");
 	srv_start("/srv/i8259");
+	srv_start("/srv/icp-ic");
 	srv_start("/srv/obio");
 	srv_start("/srv/cuda_adb");
@@ -364,15 +357,14 @@
 		gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER);
 		gui_start("/app/vterm", HID_COMPOSITOR_SERVER);
-	} else {
-		rc = console(HID_INPUT, HID_OUTPUT);
-		if (rc == EOK) {
-			getterm("term/vc0", "/app/bdsh", true);
-			getterm("term/vc1", "/app/bdsh", false);
-			getterm("term/vc2", "/app/bdsh", false);
-			getterm("term/vc3", "/app/bdsh", false);
-			getterm("term/vc4", "/app/bdsh", false);
-			getterm("term/vc5", "/app/bdsh", false);
-			getterm("term/vc6", "/app/klog", false);
-		}
+	}
+	
+	rc = console(HID_INPUT, HID_OUTPUT);
+	if (rc == EOK) {
+		getterm("term/vc0", "/app/bdsh", true);
+		getterm("term/vc1", "/app/bdsh", false);
+		getterm("term/vc2", "/app/bdsh", false);
+		getterm("term/vc3", "/app/bdsh", false);
+		getterm("term/vc4", "/app/bdsh", false);
+		getterm("term/vc5", "/app/bdsh", false);
 	}
 	
Index: uspace/app/kio/kio.c
===================================================================
--- uspace/app/kio/kio.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/kio/kio.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,5 +39,4 @@
 #include <as.h>
 #include <ddi.h>
-#include <event.h>
 #include <errno.h>
 #include <str_error.h>
@@ -149,5 +148,6 @@
  *
  */
-static void notification_received(ipc_callid_t callid, ipc_call_t *call)
+static void kio_notification_handler(ipc_callid_t callid, ipc_call_t *call,
+    void *arg)
 {
 	/*
@@ -181,5 +181,5 @@
 		producer(kio_stored, kio + offset);
 	
-	event_unmask(EVENT_KIO);
+	async_event_unmask(EVENT_KIO);
 	fibril_mutex_unlock(&mtx);
 }
@@ -214,6 +214,5 @@
 	
 	prodcons_initialize(&pc);
-	async_set_interrupt_received(notification_received);
-	rc = event_subscribe(EVENT_KIO, 0);
+	rc = async_event_subscribe(EVENT_KIO, kio_notification_handler, NULL);
 	if (rc != EOK) {
 		fprintf(stderr, "%s: Unable to register kio notifications\n",
@@ -233,8 +232,8 @@
 		fprintf(stderr, "%s: Could not create input\n", NAME);
 		return ENOMEM;
-	}	
+	}
 
 	fibril_add_ready(fid);
-	event_unmask(EVENT_KIO);
+	async_event_unmask(EVENT_KIO);
 	kio_update();
 	
@@ -251,7 +250,7 @@
 		free(str);
 	}
- 
+
 	if (rc == ENOENT)
-		rc = EOK;	
+		rc = EOK;
 
 	return EOK;
Index: uspace/app/logset/main.c
===================================================================
--- uspace/app/logset/main.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/logset/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -33,4 +33,5 @@
  */
 #include <stdio.h>
+#include <stdlib.h>
 #include <async.h>
 #include <errno.h>
Index: uspace/app/nic/nic.c
===================================================================
--- uspace/app/nic/nic.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/nic/nic.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -49,4 +49,7 @@
 	nic_cable_state_t link_state;
 	nic_channel_mode_t duplex;
+	nic_unicast_mode_t unicast_mode;
+	nic_multicast_mode_t multicast_mode;
+	nic_broadcast_mode_t broadcast_mode;
 	int speed;
 } nic_info_t;
@@ -62,4 +65,7 @@
 	printf("\tduplex <half|full|simplex> - set duplex mode\n");
 	printf("\tauto - enable autonegotiation\n");
+	printf("\tunicast <block|default|list|promisc> - set unicast receive filtering\n");
+	printf("\tmulticast <block|list|promisc> - set multicast receive filtering\n");
+	printf("\tbroadcast <block|allow> - block or allow incoming broadcast frames\n");
 }
 
@@ -145,4 +151,24 @@
 	}
 
+	rc = nic_unicast_get_mode(sess, &info->unicast_mode, 0, NULL, NULL);
+	if (rc != EOK) {
+		printf("Error gettinc NIC unicast receive mode.\n");
+		rc = EIO;
+		goto error;
+	}
+
+	rc = nic_multicast_get_mode(sess, &info->multicast_mode, 0, NULL, NULL);
+	if (rc != EOK) {
+		printf("Error gettinc NIC multicast receive mode.\n");
+		rc = EIO;
+		goto error;
+	}
+
+	rc = nic_broadcast_get_mode(sess, &info->broadcast_mode);
+	if (rc != EOK) {
+		printf("Error gettinc NIC broadcast receive mode.\n");
+		rc = EIO;
+		goto error;
+	}
 
 	return EOK;
@@ -167,4 +193,37 @@
 	case NIC_CM_HALF_DUPLEX: return "half-duplex";
 	case NIC_CM_SIMPLEX: return "simplex";
+	default: assert(false); return NULL;
+	}
+}
+
+static const char *nic_unicast_mode_str(nic_unicast_mode_t mode)
+{
+	switch (mode) {
+	case NIC_UNICAST_UNKNOWN: return "unknown";
+	case NIC_UNICAST_BLOCKED: return "blocked";
+	case NIC_UNICAST_DEFAULT: return "default";
+	case NIC_UNICAST_LIST: return "list";
+	case NIC_UNICAST_PROMISC: return "promisc";
+	default: assert(false); return NULL;
+	}
+}
+
+static const char *nic_multicast_mode_str(nic_unicast_mode_t mode)
+{
+	switch (mode) {
+	case NIC_MULTICAST_UNKNOWN: return "unknown";
+	case NIC_MULTICAST_BLOCKED: return "blocked";
+	case NIC_MULTICAST_LIST: return "list";
+	case NIC_MULTICAST_PROMISC: return "promisc";
+	default: assert(false); return NULL;
+	}
+}
+
+static const char *nic_broadcast_mode_str(nic_unicast_mode_t mode)
+{
+	switch (mode) {
+	case NIC_BROADCAST_UNKNOWN: return "unknown";
+	case NIC_BROADCAST_BLOCKED: return "blocked";
+	case NIC_BROADCAST_ACCEPTED: return "accepted";
 	default: assert(false); return NULL;
 	}
@@ -234,4 +293,10 @@
 		printf("\tLink state: %s\n",
 		    nic_link_state_str(nic_info.link_state));
+		printf("\tUnicast receive mode: %s\n",
+		    nic_unicast_mode_str(nic_info.unicast_mode));
+		printf("\tMulticast receive mode: %s\n",
+		    nic_multicast_mode_str(nic_info.multicast_mode));
+		printf("\tBroadcast receive mode: %s\n",
+		    nic_broadcast_mode_str(nic_info.broadcast_mode));
 
 		if (nic_info.link_state == NIC_CS_PLUGGED) {
@@ -369,4 +434,92 @@
 
 	return nic_set_address(sess, &addr);
+}
+
+static int nic_set_rx_unicast(int i, char *str)
+{
+	async_sess_t *sess;
+
+	sess = get_nic_by_index(i);
+	if (sess == NULL) {
+		printf("Specified NIC doesn't exist or cannot connect to it.\n");
+		return EINVAL;
+	}
+
+	if (!str_cmp(str, "block")) {
+		nic_unicast_set_mode(sess, NIC_UNICAST_BLOCKED, NULL, 0);
+		return EOK;
+	}
+
+	if (!str_cmp(str, "default")) {
+		nic_unicast_set_mode(sess, NIC_UNICAST_DEFAULT, NULL, 0);
+		return EOK;
+	}
+
+	if (!str_cmp(str, "list")) {
+		nic_unicast_set_mode(sess, NIC_UNICAST_LIST, NULL, 0);
+		return EOK;
+	}
+
+	if (!str_cmp(str, "promisc")) {
+		nic_unicast_set_mode(sess, NIC_UNICAST_PROMISC, NULL, 0);
+		return EOK;
+	}
+
+
+	printf("Invalid pameter - should be one of: block, default, promisc\n");
+	return EINVAL;
+}
+
+static int nic_set_rx_multicast(int i, char *str)
+{
+	async_sess_t *sess;
+
+	sess = get_nic_by_index(i);
+	if (sess == NULL) {
+		printf("Specified NIC doesn't exist or cannot connect to it.\n");
+		return EINVAL;
+	}
+
+	if (!str_cmp(str, "block")) {
+		nic_multicast_set_mode(sess, NIC_MULTICAST_BLOCKED, NULL, 0);
+		return EOK;
+	}
+
+	if (!str_cmp(str, "list")) {
+		nic_multicast_set_mode(sess, NIC_MULTICAST_LIST, NULL, 0);
+		return EOK;
+	}
+
+	if (!str_cmp(str, "promisc")) {
+		nic_multicast_set_mode(sess, NIC_MULTICAST_PROMISC, NULL, 0);
+		return EOK;
+	}
+
+	printf("Invalid pameter - should be one of: block, promisc\n");
+	return EINVAL;
+}
+
+static int nic_set_rx_broadcast(int i, char *str)
+{
+	async_sess_t *sess;
+
+	sess = get_nic_by_index(i);
+	if (sess == NULL) {
+		printf("Specified NIC doesn't exist or cannot connect to it.\n");
+		return EINVAL;
+	}
+
+	if (!str_cmp(str, "block")) {
+		nic_broadcast_set_mode(sess, NIC_BROADCAST_BLOCKED);
+		return EOK;
+	}
+
+	if (!str_cmp(str, "accept")) {
+		nic_broadcast_set_mode(sess, NIC_BROADCAST_ACCEPTED);
+		return EOK;
+	}
+
+	printf("Invalid pameter - should be 'block' or 'accept'\n");
+	return EINVAL;
 }
 
@@ -400,4 +553,13 @@
 			return nic_set_autoneg(index);
 
+		if (!str_cmp(argv[2], "unicast"))
+			return nic_set_rx_unicast(index, argv[3]);
+
+		if (!str_cmp(argv[2], "multicast"))
+			return nic_set_rx_multicast(index, argv[3]);
+
+		if (!str_cmp(argv[2], "broadcast"))
+			return nic_set_rx_broadcast(index, argv[3]);
+
 	} else {
 		printf(NAME ": Invalid argument.\n");
Index: uspace/app/redir/redir.c
===================================================================
--- uspace/app/redir/redir.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/redir/redir.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -75,5 +75,5 @@
 }
 
-static task_id_t spawn(int argc, char *argv[])
+static task_id_t spawn(task_wait_t *wait, int argc, char *argv[])
 {
 	const char **args;
@@ -93,5 +93,5 @@
 	args[argc] = NULL;
 	
-	rc = task_spawnv(&id, argv[0], args);
+	rc = task_spawnv(&id, wait, argv[0], args);
 	
 	free(args);
@@ -152,11 +152,12 @@
 	 */
 	setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
-	
-	task_id_t id = spawn(argc - i, argv + i);
+
+	task_wait_t wait;	
+	task_id_t id = spawn(&wait, argc - i, argv + i);
 	
 	if (id != 0) {
 		task_exit_t texit;
 		int retval;
-		task_wait(id, &texit, &retval);
+		task_wait(&wait, &texit, &retval);
 		
 		return retval;
Index: uspace/app/sbi/src/os/helenos.c
===================================================================
--- uspace/app/sbi/src/os/helenos.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/sbi/src/os/helenos.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -250,8 +250,9 @@
 {
 	task_id_t tid;
+	task_wait_t twait;
 	task_exit_t texit;
 	int rc, retval;
 
-	rc = task_spawnv(&tid, cmd[0], (char const * const *) cmd);
+	rc = task_spawnv(&tid, &twait, cmd[0], (char const * const *) cmd);
 	if (rc != EOK) {
 		printf("Error: Failed spawning '%s' (%s).\n", cmd[0],
@@ -261,5 +262,5 @@
 
 	/* XXX Handle exit status and return value. */
-	rc = task_wait(tid, &texit, &retval);
+	rc = task_wait(&twait, &texit, &retval);
 	(void) rc;
 
Index: uspace/app/tester/hw/misc/virtchar1.c
===================================================================
--- uspace/app/tester/hw/misc/virtchar1.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/tester/hw/misc/virtchar1.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,4 +40,5 @@
 #include <sys/types.h>
 #include <async.h>
+#include <unistd.h>
 #include <char_dev_iface.h>
 #include <str.h>
Index: uspace/app/trace/syscalls.c
===================================================================
--- uspace/app/trace/syscalls.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/trace/syscalls.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -65,5 +65,7 @@
     [SYS_IPC_HANGUP] = { "ipc_hangup",			1,	V_ERRNO },
 
-    [SYS_EVENT_SUBSCRIBE] = { "event_subscribe",	2,	V_ERRNO },
+    [SYS_IPC_EVENT_SUBSCRIBE] = { "ipc_event_subscribe",	2,	V_ERRNO },
+    [SYS_IPC_EVENT_UNSUBSCRIBE] = { "ipc_event_unsubscribe",	1,	V_ERRNO },
+    [SYS_IPC_EVENT_UNMASK] = { "ipc_event_unmask",	1,	V_ERRNO },
 
     [SYS_CAP_GRANT] = { "cap_grant",			2,	V_ERRNO },
@@ -71,6 +73,7 @@
     [SYS_PHYSMEM_MAP] = { "physmem_map",		4,	V_ERRNO },
     [SYS_IOSPACE_ENABLE] = { "iospace_enable",		1,	V_ERRNO },
-    [SYS_IRQ_REGISTER] = { "irq_register",	4,	V_ERRNO },
-    [SYS_IRQ_UNREGISTER] = { "irq_unregister",	2,	V_ERRNO },
+
+    [SYS_IPC_IRQ_SUBSCRIBE] = { "ipc_irq_subscribe",	4,	V_ERRNO },
+    [SYS_IPC_IRQ_UNSUBSCRIBE] = { "ipc_irq_unsubscribe",	2,	V_ERRNO },
 
     [SYS_SYSINFO_GET_VAL_TYPE] = { "sysinfo_get_val_type",		2,	V_INTEGER },
@@ -79,5 +82,5 @@
     [SYS_SYSINFO_GET_DATA] = { "sysinfo_get_data",		5,	V_ERRNO },
 
-    [SYS_DEBUG_ACTIVATE_CONSOLE] = { "debug_activate_console", 0,	V_ERRNO },
+    [SYS_DEBUG_CONSOLE] = { "debug_console", 0,	V_ERRNO },
     [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox",	1,	V_ERRNO }
 };
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/trace/trace.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -876,5 +876,5 @@
 		printf("Waiting for task to exit.\n");
 
-		rc = task_wait(task_id, &texit, &retval);
+		rc = task_wait_task_id(task_id, &texit, &retval);
 		if (rc != EOK) {
 			printf("Failed waiting for task.\n");
Index: uspace/app/viewer/viewer.c
===================================================================
--- uspace/app/viewer/viewer.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/viewer/viewer.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,4 +44,5 @@
 #include <surface.h>
 #include <codec/tga.h>
+#include <task.h>
 
 #define NAME  "viewer"
Index: uspace/app/vlaunch/vlaunch.c
===================================================================
--- uspace/app/vlaunch/vlaunch.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/app/vlaunch/vlaunch.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -94,5 +94,6 @@
 	
 	task_id_t id;
-	int rc = task_spawnl(&id, app, app, winreg, NULL);
+	task_wait_t wait;
+	int rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
 	if (rc != EOK) {
 		printf("%s: Error spawning %s %s (%s)\n", NAME, app,
@@ -103,5 +104,5 @@
 	task_exit_t texit;
 	int retval;
-	rc = task_wait(id, &texit, &retval);
+	rc = task_wait(&wait, &texit, &retval);
 	if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
 		printf("%s: Error retrieving retval from %s (%s)\n", NAME,
Index: uspace/drv/audio/hdaudio/hdaudio.c
===================================================================
--- uspace/drv/audio/hdaudio/hdaudio.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/audio/hdaudio/hdaudio.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -58,5 +58,5 @@
 static int hda_fun_offline(ddf_fun_t *fun);
 
-static void hdaudio_interrupt(ddf_dev_t *, ipc_callid_t, ipc_call_t *);
+static void hdaudio_interrupt(ipc_callid_t, ipc_call_t *, ddf_dev_t *);
 
 static driver_ops_t driver_ops = {
@@ -366,6 +366,6 @@
 }
 
-static void hdaudio_interrupt(ddf_dev_t *dev, ipc_callid_t iid,
-    ipc_call_t *icall)
+static void hdaudio_interrupt(ipc_callid_t iid, ipc_call_t *icall,
+    ddf_dev_t *dev)
 {
 	hda_t *hda = (hda_t *)ddf_dev_data_get(dev);
Index: uspace/drv/audio/sb16/main.c
===================================================================
--- uspace/drv/audio/sb16/main.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/audio/sb16/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -77,5 +77,5 @@
 }
 
-static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
+static void irq_handler(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev)
 {
 	sb16_t *sb16_dev = ddf_dev_data_get(dev);
Index: uspace/drv/block/ahci/ahci.c
===================================================================
--- uspace/drv/block/ahci/ahci.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/block/ahci/ahci.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -890,10 +890,10 @@
 /** AHCI interrupt handler.
  *
- * @param dev   DDF device structure.
  * @param iid   The IPC call id.
  * @param icall The IPC call structure.
- *
- */
-static void ahci_interrupt(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *icall)
+ * @param dev   DDF device structure.
+ *
+ */
+static void ahci_interrupt(ipc_callid_t iid, ipc_call_t *icall, ddf_dev_t *dev)
 {
 	ahci_dev_t *ahci = dev_ahci_dev(dev);
Index: uspace/drv/block/ata_bd/ata_bd.c
===================================================================
--- uspace/drv/block/ata_bd/ata_bd.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/block/ata_bd/ata_bd.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -54,5 +54,7 @@
 #include <bd_srv.h>
 #include <fibril_synch.h>
+#include <scsi/mmc.h>
 #include <scsi/sbc.h>
+#include <scsi/spc.h>
 #include <stdint.h>
 #include <str.h>
@@ -95,4 +97,5 @@
 static int ata_bd_get_block_size(bd_srv_t *, size_t *);
 static int ata_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
+static int ata_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);
 
 static int ata_rcmd_read(disk_t *disk, uint64_t ba, size_t cnt,
@@ -100,4 +103,5 @@
 static int ata_rcmd_write(disk_t *disk, uint64_t ba, size_t cnt,
     const void *buf);
+static int ata_rcmd_flush_cache(disk_t *disk);
 static int disk_init(ata_ctrl_t *ctrl, disk_t *d, int disk_id);
 static int ata_identify_dev(disk_t *disk, void *buf);
@@ -127,5 +131,6 @@
 	.write_blocks = ata_bd_write_blocks,
 	.get_block_size = ata_bd_get_block_size,
-	.get_num_blocks = ata_bd_get_num_blocks
+	.get_num_blocks = ata_bd_get_num_blocks,
+	.sync_cache = ata_bd_sync_cache
 };
 
@@ -343,5 +348,5 @@
 	identify_data_t idata;
 	uint8_t model[40];
-	ata_inquiry_data_t inq_data;
+	scsi_std_inquiry_data_t inq_data;
 	size_t isize;
 	uint16_t w;
@@ -472,5 +477,5 @@
 
 		/* Check device type. */
-		if (INQUIRY_PDEV_TYPE(inq_data.pdev_type) != PDEV_TYPE_CDROM)
+		if (INQUIRY_PDEV_TYPE(inq_data.pqual_devtype) != SCSI_DEV_CD_DVD)
 			ddf_msg(LVL_WARN, "Peripheral device type is not CD-ROM.");
 
@@ -584,4 +589,16 @@
 }
 
+/** Flush cache. */
+static int ata_bd_sync_cache(bd_srv_t *bd, uint64_t ba, size_t cnt)
+{
+	disk_t *disk = bd_srv_disk(bd);
+
+	/* ATA cannot flush just some blocks, we just flush everything. */
+	(void)ba;
+	(void)cnt;
+
+	return ata_rcmd_flush_cache(disk);
+}
+
 /** PIO data-in command protocol. */
 static int ata_pio_data_in(disk_t *disk, void *obuf, size_t obuf_size,
@@ -637,4 +654,19 @@
 		}
 	}
+
+	if (status & SR_ERR)
+		return EIO;
+
+	return EOK;
+}
+
+/** PIO non-data command protocol. */
+static int ata_pio_nondata(disk_t *disk)
+{
+	ata_ctrl_t *ctrl = disk->ctrl;
+	uint8_t status;
+
+	if (wait_status(ctrl, 0, ~SR_BSY, &status, TIMEOUT_BSY) != EOK)
+		return EIO;
 
 	if (status & SR_ERR)
@@ -831,13 +863,20 @@
     size_t *rcvd_size)
 {
-	ata_pcmd_inquiry_t cp;
+	uint8_t cpb[12];
+	scsi_cdb_inquiry_t *cp = (scsi_cdb_inquiry_t *)cpb;
 	int rc;
 
-	memset(&cp, 0, sizeof(cp));
-
-	cp.opcode = PCMD_INQUIRY;
-	cp.alloc_len = min(obuf_size, 0xff); /* Allocation length */
-
-	rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size, rcvd_size);
+	memset(cpb, 0, sizeof(cpb));
+
+	/*
+	 * For SFF 8020 compliance the inquiry must be padded to 12 bytes
+	 * and allocation length must fit in one byte.
+	 */
+	cp->op_code = SCSI_CMD_INQUIRY;
+
+	/* Allocation length */
+	cp->alloc_len = host2uint16_t_be(min(obuf_size, 0xff));
+
+	rc = ata_cmd_packet(disk, cpb, sizeof(cpb), obuf, obuf_size, rcvd_size);
 	if (rc != EOK)
 		return rc;
@@ -894,5 +933,5 @@
     void *obuf, size_t obuf_size)
 {
-	ata_pcmd_read_12_t cp;
+	scsi_cdb_read_12_t cp;
 	int rc;
 
@@ -902,7 +941,7 @@
 	memset(&cp, 0, sizeof(cp));
 
-	cp.opcode = PCMD_READ_12;
-	cp.ba = host2uint32_t_be(ba);
-	cp.nblocks = host2uint32_t_be(cnt);
+	cp.op_code = SCSI_CMD_READ_12;
+	cp.lba = host2uint32_t_be(ba);
+	cp.xfer_len = host2uint32_t_be(cnt);
 
 	rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size, NULL);
@@ -933,20 +972,21 @@
     size_t obuf_size)
 {
-	ata_pcmd_read_toc_t cp;
+	uint8_t cpb[12];
+	scsi_cdb_read_toc_t *cp = (scsi_cdb_read_toc_t *)cpb;
 	int rc;
 
-	memset(&cp, 0, sizeof(cp));
-
-	cp.opcode = PCMD_READ_TOC;
-	cp.msf = 0;
-	cp.format = 0x01; /* 0x01 = multi-session mode */
-	cp.start = session;
-	cp.size = host2uint16_t_be(obuf_size);
-	cp.oldformat = 0x40; /* 0x01 = multi-session mode (shifted to MSB) */
-	
-	rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size, NULL);
+	memset(cpb, 0, sizeof(cpb));
+
+	cp->op_code = SCSI_CMD_READ_TOC;
+	cp->msf = 0;
+	cp->format = 0x01; /* 0x01 = multi-session mode */
+	cp->track_sess_no = session;
+	cp->alloc_len = host2uint16_t_be(obuf_size);
+	cp->control = 0x40; /* 0x01 = multi-session mode (shifted to MSB) */
+
+	rc = ata_cmd_packet(disk, cpb, sizeof(cpb), obuf, obuf_size, NULL);
 	if (rc != EOK)
 		return rc;
-	
+
 	return EOK;
 }
@@ -1066,4 +1106,44 @@
 	rc = ata_pio_data_out(disk, buf, cnt * disk->block_size,
 	    disk->block_size, cnt);
+
+	fibril_mutex_unlock(&ctrl->lock);
+	return rc;
+}
+
+/** Flush cached data to nonvolatile storage.
+ *
+ * @param disk		Disk
+ *
+ * @return EOK on success, EIO on error.
+ */
+static int ata_rcmd_flush_cache(disk_t *disk)
+{
+	ata_ctrl_t *ctrl = disk->ctrl;
+	uint8_t drv_head;
+	int rc;
+
+	/* New value for Drive/Head register */
+	drv_head =
+	    (disk_dev_idx(disk) != 0) ? DHR_DRV : 0;
+
+	fibril_mutex_lock(&ctrl->lock);
+
+	/* Program a Flush Cache operation. */
+
+	if (wait_status(ctrl, 0, ~SR_BSY, NULL, TIMEOUT_BSY) != EOK) {
+		fibril_mutex_unlock(&ctrl->lock);
+		return EIO;
+	}
+
+	pio_write_8(&ctrl->cmd->drive_head, drv_head);
+
+	if (wait_status(ctrl, SR_DRDY, ~SR_BSY, NULL, TIMEOUT_DRDY) != EOK) {
+		fibril_mutex_unlock(&ctrl->lock);
+		return EIO;
+	}
+
+	pio_write_8(&ctrl->cmd->command, CMD_FLUSH_CACHE);
+
+	rc = ata_pio_nondata(disk);
 
 	fibril_mutex_unlock(&ctrl->lock);
Index: uspace/drv/block/ata_bd/ata_hw.h
===================================================================
--- uspace/drv/block/ata_bd/ata_hw.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/block/ata_bd/ata_hw.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -136,5 +136,6 @@
 	CMD_PACKET		= 0xA0,
 	CMD_IDENTIFY_PKT_DEV	= 0xA1,
-	CMD_IDENTIFY_DRIVE	= 0xEC
+	CMD_IDENTIFY_DRIVE	= 0xEC,
+	CMD_FLUSH_CACHE		= 0xE7
 };
 
@@ -241,71 +242,6 @@
 };
 
-/** ATA packet command codes. */
-enum ata_pkt_command {
-	PCMD_INQUIRY		= 0x12,
-	PCMD_READ_12		= 0xa8,
-	PCMD_READ_TOC		= 0x43
-};
-
-/** ATAPI Inquiry command */
-typedef struct {
-	uint8_t opcode;		/**< Operation code (PCMD_INQUIRY) */
-	uint8_t _res0;
-	uint8_t _res1;
-	uint8_t _res2;
-	uint8_t alloc_len;	/**< Allocation length */
-	uint8_t _res3;
-	uint8_t _res4;
-	uint8_t _res5;
-	uint32_t _res6;
-} __attribute__ ((packed)) ata_pcmd_inquiry_t;
-
-/** ATAPI Read(12) command */
-typedef struct {
-	uint8_t opcode;		/**< Operation code (PCMD_READ_12) */
-	uint8_t _res0;
-	uint32_t ba;		/**< Starting block address */
-	uint32_t nblocks;	/**< Number of blocks to transfer */
-	uint8_t _res1;
-	uint8_t _res2;
-} __attribute__ ((packed)) ata_pcmd_read_12_t;
-
-/** ATAPI Read TOC command */
-typedef struct {
-	uint8_t opcode;		/**< Operation code (PCMD_READ_TOC) */
-	uint8_t msf;            /**< 0x2 = MSF bit set */
-	uint8_t format;         /**< low 3 bits */
-	uint8_t _res0;
-	uint8_t _res1;
-	uint8_t _res2;
-	uint8_t start;          /**< starting track/session number */
-	uint16_t size;		/**< Allocation length */
-	uint8_t oldformat;         /**< high 2 bits */
-	uint8_t _res3;
-	uint8_t _res4;
-} __attribute__ ((packed)) ata_pcmd_read_toc_t;
-
-/** Data returned from Inquiry command (mandatory part) */
-typedef struct {
-	uint8_t pdev_type;	/** Reserved, Peripheral device type */
-	uint8_t rmb;		/** RMB, Reserved */
-	uint8_t std_version;	/** ISO version, ECMA version, ANSI version */
-	uint8_t atapi_ver_rdf;	/** ATAPI version, Response data format */
-	uint8_t additional_len;	/** Additional length */
-	uint8_t _res0;
-	uint8_t _res1;
-	uint8_t _res2;
-	uint8_t vendor_id[8];	/** Vendor ID */
-	uint8_t product_id[8];	/** Product ID */
-	uint8_t product_rev[4];	/** Product revision level */
-} ata_inquiry_data_t;
-
-/** Extract value of ata_inquiry_data_t.pdev_type */
+/** Extract value of device type from scsi_std_inquiry_data_t.pqual_devtype */
 #define INQUIRY_PDEV_TYPE(val) ((val) & 0x1f)
-
-/** Values for ata_inquiry_data_t.pdev_type */
-enum ata_pdev_type {
-	PDEV_TYPE_CDROM		= 0x05
-};
 
 enum ata_pdev_signature {
Index: uspace/drv/bus/usb/ohci/ohci.c
===================================================================
--- uspace/drv/bus/usb/ohci/ohci.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/bus/usb/ohci/ohci.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -59,12 +59,13 @@
 /** IRQ handling callback, identifies device
  *
- * @param[in] dev DDF instance of the device to use.
  * @param[in] iid (Unused).
  * @param[in] call Pointer to the call that represents interrupt.
- */
-static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
+ * @param[in] dev DDF instance of the device to use.
+ *
+ */
+static void irq_handler(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev)
 {
 	assert(dev);
-
+	
 	ohci_t *ohci = dev_to_ohci(dev);
 	if (!ohci) {
@@ -72,4 +73,5 @@
 		return;
 	}
+	
 	const uint16_t status = IPC_GET_ARG1(*call);
 	hc_interrupt(&ohci->hc, status);
Index: uspace/drv/bus/usb/uhci/hc.c
===================================================================
--- uspace/drv/bus/usb/uhci/hc.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/bus/usb/uhci/hc.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -151,5 +151,5 @@
 		return rc;
 	}
-
+	
 	irq_code_t irq_code = {
 		.rangecount = hc_irq_pio_range_count,
@@ -158,13 +158,13 @@
 		.cmds = irq_cmds
 	};
-
-        /* Register handler to avoid interrupt lockup */
-        rc = register_interrupt_handler(device, irq, handler, &irq_code);
-        if (rc != EOK) {
-    		usb_log_error("Failed to register interrupt handler: %s.\n",
-    		    str_error(rc));
-    		return rc;
-    	}
-
+	
+	/* Register handler to avoid interrupt lockup */
+	rc = register_interrupt_handler(device, irq, handler, &irq_code);
+	if (rc != EOK) {
+		usb_log_error("Failed to register interrupt handler: %s.\n",
+		    str_error(rc));
+		return rc;
+	}
+	
 	return EOK;
 }
@@ -432,4 +432,6 @@
 	instance->transfers[USB_SPEED_FULL][USB_TRANSFER_BULK] =
 	  &instance->transfers_bulk_full;
+	instance->transfers[USB_SPEED_LOW][USB_TRANSFER_BULK] =
+	  &instance->transfers_bulk_full;
 
 	return EOK;
Index: uspace/drv/bus/usb/uhci/uhci.c
===================================================================
--- uspace/drv/bus/usb/uhci/uhci.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/bus/usb/uhci/uhci.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -69,11 +69,13 @@
 /** IRQ handling callback, forward status from call to diver structure.
  *
- * @param[in] dev DDF instance of the device to use.
  * @param[in] iid (Unused).
  * @param[in] call Pointer to the call from kernel.
- */
-static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
+ * @param[in] dev DDF instance of the device to use.
+ *
+ */
+static void irq_handler(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev)
 {
 	assert(dev);
+	
 	uhci_t *uhci = dev_to_uhci(dev);
 	if (!uhci) {
@@ -81,4 +83,5 @@
 		return;
 	}
+	
 	const uint16_t status = IPC_GET_ARG1(*call);
 	hc_interrupt(&uhci->hc, status);
Index: uspace/drv/bus/usb/usbmast/main.c
===================================================================
--- uspace/drv/bus/usb/usbmast/main.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/bus/usb/usbmast/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -85,4 +85,5 @@
 static int usbmast_bd_close(bd_srv_t *);
 static int usbmast_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
+static int usbmast_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);
 static int usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
 static int usbmast_bd_get_block_size(bd_srv_t *, size_t *);
@@ -93,4 +94,5 @@
 	.close = usbmast_bd_close,
 	.read_blocks = usbmast_bd_read_blocks,
+	.sync_cache = usbmast_bd_sync_cache,
 	.write_blocks = usbmast_bd_write_blocks,
 	.get_block_size = usbmast_bd_get_block_size,
@@ -338,4 +340,12 @@
 }
 
+/** Synchronize blocks to nonvolatile storage. */
+static int usbmast_bd_sync_cache(bd_srv_t *bd, uint64_t ba, size_t cnt)
+{
+	usbmast_fun_t *mfun = bd_srv_usbmast(bd);
+
+	return usbmast_sync_cache(mfun, ba, cnt);
+}
+
 /** Write blocks to the device. */
 static int usbmast_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt,
Index: uspace/drv/bus/usb/usbmast/scsi_ms.c
===================================================================
--- uspace/drv/bus/usb/usbmast/scsi_ms.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/bus/usb/usbmast/scsi_ms.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -383,4 +383,51 @@
 }
 
+/** Perform SCSI Synchronize Cache command on USB mass storage device.
+ *
+ * @param mfun		Mass storage function
+ * @param ba		Address of first block
+ * @param nblocks	Number of blocks to read
+ * @param data		Data to write
+ *
+ * @return		Error code
+ */
+int usbmast_sync_cache(usbmast_fun_t *mfun, uint64_t ba, size_t nblocks)
+{
+	scsi_cmd_t cmd;
+	scsi_cdb_sync_cache_10_t cdb;
+	int rc;
+
+	if (ba > UINT32_MAX)
+		return ELIMIT;
+
+	if (nblocks > UINT16_MAX)
+		return ELIMIT;
+
+	memset(&cdb, 0, sizeof(cdb));
+	cdb.op_code = SCSI_CMD_SYNC_CACHE_10;
+	cdb.lba = host2uint32_t_be(ba);
+	cdb.numlb = host2uint16_t_be(nblocks);
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.cdb = &cdb;
+	cmd.cdb_size = sizeof(cdb);
+
+	rc = usbmast_run_cmd(mfun, &cmd);
+
+        if (rc != EOK) {
+		usb_log_error("Synchronize Cache (10) transport failed, device %s: %s.\n",
+		   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
+		return rc;
+	}
+
+	if (cmd.status != CMDS_GOOD) {
+		usb_log_error("Synchronize Cache (10) command failed, device %s.\n",
+		   ddf_dev_get_name(mfun->mdev->ddf_dev));
+		return EIO;
+	}
+
+	return EOK;
+}
+
 /**
  * @}
Index: uspace/drv/bus/usb/usbmast/scsi_ms.h
===================================================================
--- uspace/drv/bus/usb/usbmast/scsi_ms.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/bus/usb/usbmast/scsi_ms.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -64,4 +64,5 @@
 extern int usbmast_read(usbmast_fun_t *, uint64_t, size_t, void *);
 extern int usbmast_write(usbmast_fun_t *, uint64_t, size_t, const void *);
+extern int usbmast_sync_cache(usbmast_fun_t *, uint64_t, size_t);
 extern const char *usbmast_scsi_dev_type_str(unsigned);
 
Index: uspace/drv/char/i8042/i8042.c
===================================================================
--- uspace/drv/char/i8042/i8042.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/char/i8042/i8042.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -2,5 +2,5 @@
  * Copyright (c) 2001-2004 Jakub Jermar
  * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2009 Jiri Svoboda
+ * Copyright (c) 2014 Jiri Svoboda
  * Copyright (c) 2011 Jan Vesely
  * All rights reserved.
@@ -39,11 +39,13 @@
  */
 
+#include <ddf/log.h>
+#include <ddf/interrupt.h>
+#include <ddi.h>
 #include <device/hw_res.h>
-#include <ddi.h>
 #include <errno.h>
 #include <str_error.h>
 #include <inttypes.h>
-#include <ddf/log.h>
-#include <ddf/interrupt.h>
+#include <io/chardev_srv.h>
+
 #include "i8042.h"
 
@@ -64,9 +66,11 @@
 #define i8042_KBD_TRANSLATE  0x40  /* Use this to switch to XT scancodes */
 
-void default_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
-
-/** Port function operations. */
-static ddf_dev_ops_t ops = {
-	.default_handler = default_handler,
+static void i8042_char_conn(ipc_callid_t, ipc_call_t *, void *);
+static int i8042_read(chardev_srv_t *, void *, size_t);
+static int i8042_write(chardev_srv_t *, const void *, size_t);
+
+static chardev_ops_t i8042_chardev_ops = {
+	.read = i8042_read,
+	.write = i8042_write
 };
 
@@ -106,10 +110,4 @@
 };
 
-/** Get i8042 soft state from device node. */
-static i8042_t *dev_i8042(ddf_dev_t *dev)
-{
-	return ddf_dev_data_get(dev);
-}
-
 /** Wait until it is safe to write to the device. */
 static void wait_ready(i8042_t *dev)
@@ -123,13 +121,13 @@
  * Write new data to the corresponding buffer.
  *
- * @param dev  Device that caued the interrupt.
  * @param iid  Call id.
  * @param call pointerr to call data.
- *
- */
-static void i8042_irq_handler(ddf_dev_t *dev, ipc_callid_t iid,
-    ipc_call_t *call)
-{
-	i8042_t *controller = dev_i8042(dev);
+ * @param dev  Device that caued the interrupt.
+ *
+ */
+static void i8042_irq_handler(ipc_callid_t iid, ipc_call_t *call,
+    ddf_dev_t *dev)
+{
+	i8042_t *controller = ddf_dev_data_get(dev);
 	
 	const uint8_t status = IPC_GET_ARG1(*call);
@@ -186,4 +184,15 @@
 	};
 	
+	dev->kbd = ddf_fun_data_alloc(dev->kbd_fun, sizeof(i8042_port_t));
+	if (dev->kbd == NULL) {
+		rc = ENOMEM;
+		goto error;
+	}
+	
+	dev->kbd->ctl = dev;
+	chardev_srvs_init(&dev->kbd->cds);
+	dev->kbd->cds.ops = &i8042_chardev_ops;
+	dev->kbd->cds.sarg = dev->kbd;
+	
 	rc = ddf_fun_add_match_id(dev->kbd_fun, "char/xtkbd", 90);
 	if (rc != EOK)
@@ -196,10 +205,21 @@
 	}
 	
+	dev->aux = ddf_fun_data_alloc(dev->aux_fun, sizeof(i8042_port_t));
+	if (dev->aux == NULL) {
+		rc = ENOMEM;
+		goto error;
+	}
+	
+	dev->aux->ctl = dev;
+	chardev_srvs_init(&dev->aux->cds);
+	dev->aux->cds.ops = &i8042_chardev_ops;
+	dev->aux->cds.sarg = dev->aux;
+	
 	rc = ddf_fun_add_match_id(dev->aux_fun, "char/ps2mouse", 90);
 	if (rc != EOK)
 		goto error;
 	
-	ddf_fun_set_ops(dev->kbd_fun, &ops);
-	ddf_fun_set_ops(dev->aux_fun, &ops);
+	ddf_fun_set_conn_handler(dev->kbd_fun, i8042_char_conn);
+	ddf_fun_set_conn_handler(dev->aux_fun, i8042_char_conn);
 	
 	buffer_init(&dev->kbd_buffer, dev->kbd_data, BUFFER_SIZE);
@@ -298,36 +318,33 @@
 }
 
-// FIXME TODO use shared instead this
-enum {
-	IPC_CHAR_READ = DEV_FIRST_CUSTOM_METHOD,
-	IPC_CHAR_WRITE,
-};
-
 /** Write data to i8042 port.
  *
- * @param fun    DDF function.
- * @param buffer Data source.
- * @param size   Data size.
+ * @param srv	 Connection-specific data
+ * @param buffer Data source
+ * @param size   Data size
  *
  * @return Bytes written.
  *
  */
-static int i8042_write(ddf_fun_t *fun, char *buffer, size_t size)
-{
-	i8042_t *controller = dev_i8042(ddf_fun_get_dev(fun));
-	fibril_mutex_lock(&controller->write_guard);
+static int i8042_write(chardev_srv_t *srv, const void *data, size_t size)
+{
+	i8042_port_t *port = (i8042_port_t *)srv->srvs->sarg;
+	i8042_t *i8042 = port->ctl;
+	const char *dp = (const char *)data;
+	
+	fibril_mutex_lock(&i8042->write_guard);
 	
 	for (size_t i = 0; i < size; ++i) {
-		if (controller->aux_fun == fun) {
-			wait_ready(controller);
-			pio_write_8(&controller->regs->status,
+		if (port == i8042->aux) {
+			wait_ready(i8042);
+			pio_write_8(&i8042->regs->status,
 			    i8042_CMD_WRITE_AUX);
 		}
 		
-		wait_ready(controller);
-		pio_write_8(&controller->regs->data, buffer[i]);
-	}
-	
-	fibril_mutex_unlock(&controller->write_guard);
+		wait_ready(i8042);
+		pio_write_8(&i8042->regs->data, dp[i]);
+	}
+	
+	fibril_mutex_unlock(&i8042->write_guard);
 	return size;
 }
@@ -335,19 +352,22 @@
 /** Read data from i8042 port.
  *
- * @param fun    DDF function.
- * @param buffer Data place.
- * @param size   Data place size.
+ * @param srv	 Connection-specific data
+ * @param buffer Data place
+ * @param size   Data place size
  *
  * @return Bytes read.
  *
  */
-static int i8042_read(ddf_fun_t *fun, char *data, size_t size)
-{
-	i8042_t *controller = dev_i8042(ddf_fun_get_dev(fun));
-	buffer_t *buffer = (fun == controller->aux_fun) ?
-	    &controller->aux_buffer : &controller->kbd_buffer;
+static int i8042_read(chardev_srv_t *srv, void *dest, size_t size)
+{
+	i8042_port_t *port = (i8042_port_t *)srv->srvs->sarg;
+	i8042_t *i8042 = port->ctl;
+	uint8_t *destp = (uint8_t *)dest;
+	
+	buffer_t *buffer = (port == i8042->aux) ?
+	    &i8042->aux_buffer : &i8042->kbd_buffer;
 	
 	for (size_t i = 0; i < size; ++i)
-		*data++ = buffer_read(buffer);
+		*destp++ = buffer_read(buffer);
 	
 	return size;
@@ -356,42 +376,13 @@
 /** Handle data requests.
  *
- * @param fun  ddf_fun_t function.
  * @param id   callid
  * @param call IPC request.
- *
- */
-void default_handler(ddf_fun_t *fun, ipc_callid_t id, ipc_call_t *call)
-{
-	const sysarg_t method = IPC_GET_IMETHOD(*call);
-	const size_t size = IPC_GET_ARG1(*call);
-	
-	switch (method) {
-	case IPC_CHAR_READ:
-		if (size <= 4 * sizeof(sysarg_t)) {
-			sysarg_t message[4] = {};
-			
-			i8042_read(fun, (char *) message, size);
-			async_answer_4(id, size, message[0], message[1],
-			    message[2], message[3]);
-		} else
-			async_answer_0(id, ELIMIT);
-		break;
-	
-	case IPC_CHAR_WRITE:
-		if (size <= 3 * sizeof(sysarg_t)) {
-			const sysarg_t message[3] = {
-				IPC_GET_ARG2(*call),
-				IPC_GET_ARG3(*call),
-				IPC_GET_ARG4(*call)
-			};
-			
-			i8042_write(fun, (char *) message, size);
-			async_answer_0(id, size);
-		} else
-			async_answer_0(id, ELIMIT);
-	
-	default:
-		async_answer_0(id, EINVAL);
-	}
+ * @param arg  ddf_fun_t function.
+ */
+void i8042_char_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	i8042_port_t *port = ddf_fun_data_get((ddf_fun_t *)arg);
+
+	chardev_conn(iid, icall, &port->cds);
 }
 
Index: uspace/drv/char/i8042/i8042.h
===================================================================
--- uspace/drv/char/i8042/i8042.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/char/i8042/i8042.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,4 +40,5 @@
 #define i8042_H_
 
+#include <io/chardev_srv.h>
 #include <sys/types.h>
 #include <fibril_synch.h>
@@ -56,5 +57,11 @@
 } __attribute__ ((packed)) i8042_regs_t;
 
-/** i8042 driver structure. */
+/** i8042 Port. */
+typedef struct {
+	struct i8042 *ctl;		/**< Controller */
+	chardev_srvs_t cds;		/**< Character device server data */
+} i8042_port_t;
+
+/** i8042 Controller. */
 typedef struct i8042 {
 	i8042_regs_t *regs;             /**< I/O registers. */
@@ -65,8 +72,11 @@
 	uint8_t aux_data[BUFFER_SIZE];  /**< Primary port buffer space. */
 	uint8_t kbd_data[BUFFER_SIZE];  /**< Aux. port buffer space. */
+	i8042_port_t *kbd;
+	i8042_port_t *aux;
 	fibril_mutex_t write_guard;     /**< Prevents simultanous port writes.*/
 } i8042_t;
 
-int i8042_init(i8042_t *, addr_range_t *, int, int, ddf_dev_t *);
+
+extern int i8042_init(i8042_t *, addr_range_t *, int, int, ddf_dev_t *);
 
 #endif
Index: uspace/drv/char/i8042/main.c
===================================================================
--- uspace/drv/char/i8042/main.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/char/i8042/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -157,5 +157,5 @@
 	 * interrupt storms when the default large stacks are used.
 	 */
-	async_set_interrupt_handler_stack_size(PAGE_SIZE);
+	async_set_notification_handler_stack_size(PAGE_SIZE);
 
 	return ddf_driver_main(&i8042_driver);
Index: uspace/drv/char/ns8250/ns8250.c
===================================================================
--- uspace/drv/char/ns8250/ns8250.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/char/ns8250/ns8250.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -764,8 +764,9 @@
  * data and reading the line status register.
  *
- * @param dev		The serial port device.
- */
-static inline void ns8250_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid,
-    ipc_call_t *icall)
+ * @param dev The serial port device.
+ *
+ */
+static inline void ns8250_interrupt_handler(ipc_callid_t iid, ipc_call_t *icall,
+    ddf_dev_t *dev)
 {
 	ns8250_t *ns = dev_ns8250(dev);
Index: uspace/drv/char/pl050/Makefile
===================================================================
--- uspace/drv/char/pl050/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/char/pl050/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2014 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = pl050
+
+SOURCES = \
+	pl050.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/char/pl050/pl050.c
===================================================================
--- uspace/drv/char/pl050/pl050.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/char/pl050/pl050.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,383 @@
+/*
+ * Copyright (c) 2009 Vineeth Pillai
+ * Copyright (c) 2014 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.
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <bitops.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ddf/driver.h>
+#include <ddf/interrupt.h>
+#include <ddf/log.h>
+#include <device/hw_res_parsed.h>
+#include <io/chardev_srv.h>
+#include <irc.h>
+
+#include "pl050_hw.h"
+
+#define NAME "pl050"
+
+enum {
+	buffer_size = 64
+};
+
+static int pl050_dev_add(ddf_dev_t *);
+static int pl050_fun_online(ddf_fun_t *);
+static int pl050_fun_offline(ddf_fun_t *);
+static void pl050_char_conn(ipc_callid_t, ipc_call_t *, void *);
+static int pl050_read(chardev_srv_t *, void *, size_t);
+static int pl050_write(chardev_srv_t *, const void *, size_t);
+
+static driver_ops_t driver_ops = {
+	.dev_add = &pl050_dev_add,
+	.fun_online = &pl050_fun_online,
+	.fun_offline = &pl050_fun_offline
+};
+
+static driver_t pl050_driver = {
+	.name = NAME,
+	.driver_ops = &driver_ops
+};
+
+static chardev_ops_t pl050_chardev_ops = {
+	.read = pl050_read,
+	.write = pl050_write
+};
+
+typedef struct {
+	async_sess_t *parent_sess;
+	ddf_dev_t *dev;
+	char *name;
+
+	ddf_fun_t *fun_a;
+	chardev_srvs_t cds;
+
+	uintptr_t iobase;
+	size_t iosize;
+	kmi_regs_t *regs;
+	uint8_t buffer[buffer_size];
+	size_t buf_rp;
+	size_t buf_wp;
+	fibril_condvar_t buf_cv;
+	fibril_mutex_t buf_lock;
+} pl050_t;
+
+static irq_pio_range_t pl050_ranges[] = {
+	{
+		.base = 0,
+		.size = 9,
+	}
+};
+
+static irq_cmd_t pl050_cmds[] = {
+	{
+		.cmd = CMD_PIO_READ_8,
+		.addr = NULL,
+		.dstarg = 1
+	},
+	{
+		.cmd = CMD_AND,
+		.value = BIT_V(uint8_t, kmi_stat_rxfull),
+		.srcarg = 1,
+		.dstarg = 3
+	},
+	{
+		.cmd = CMD_PREDICATE,
+		.value = 2,
+		.srcarg = 3
+	},
+	{
+		.cmd = CMD_PIO_READ_8,
+		.addr = NULL,  /* Will be patched in run-time */
+		.dstarg = 2
+	},
+	{
+		.cmd = CMD_ACCEPT
+	}
+};
+
+static irq_code_t pl050_irq_code = {
+	sizeof(pl050_ranges) / sizeof(irq_pio_range_t),
+	pl050_ranges,
+	sizeof(pl050_cmds) / sizeof(irq_cmd_t),
+	pl050_cmds
+};
+
+static pl050_t *pl050_from_fun(ddf_fun_t *fun)
+{
+	return (pl050_t *)ddf_dev_data_get(ddf_fun_get_dev(fun));
+}
+
+static void pl050_interrupt(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev)
+{
+	pl050_t *pl050 = (pl050_t *)ddf_dev_data_get(dev);
+	size_t nidx;
+
+	fibril_mutex_lock(&pl050->buf_lock);
+	nidx = (pl050->buf_wp + 1) % buffer_size;
+	if (nidx == pl050->buf_rp) {
+		/** Buffer overrunt */
+		ddf_msg(LVL_WARN, "Buffer overrun.");
+		fibril_mutex_unlock(&pl050->buf_lock);
+		return;
+	}
+
+	pl050->buffer[pl050->buf_wp] = IPC_GET_ARG2(*call);
+	pl050->buf_wp = nidx;
+	fibril_condvar_broadcast(&pl050->buf_cv);
+	fibril_mutex_unlock(&pl050->buf_lock);
+}
+
+static int pl050_init(pl050_t *pl050)
+{
+	hw_res_list_parsed_t res;
+	void *regs;
+	int rc;
+
+	fibril_mutex_initialize(&pl050->buf_lock);
+	fibril_condvar_initialize(&pl050->buf_cv);
+	pl050->buf_rp = pl050->buf_wp = 0;
+
+	pl050->parent_sess = ddf_dev_parent_sess_create(pl050->dev,
+	    EXCHANGE_SERIALIZE);
+	if (pl050->parent_sess == NULL) {
+		ddf_msg(LVL_ERROR, "Failed connecitng parent driver.");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	hw_res_list_parsed_init(&res);
+	rc = hw_res_get_list_parsed(pl050->parent_sess, &res, 0);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed getting resource list.");
+		goto error;
+	}
+
+	if (res.mem_ranges.count != 1) {
+		ddf_msg(LVL_ERROR, "Expected exactly one memory range.");
+		rc = EINVAL;
+		goto error;
+	}
+
+	pl050->iobase = RNGABS(res.mem_ranges.ranges[0]);
+	pl050->iosize = RNGSZ(res.mem_ranges.ranges[0]);
+
+	pl050_irq_code.ranges[0].base = pl050->iobase;
+	kmi_regs_t *regsphys = (kmi_regs_t *) pl050->iobase;
+	pl050_irq_code.cmds[0].addr = &regsphys->stat;
+	pl050_irq_code.cmds[3].addr = &regsphys->data;
+
+	if (res.irqs.count != 1) {
+		ddf_msg(LVL_ERROR, "Expected exactly one IRQ.");
+		rc = EINVAL;
+		goto error;
+	}
+
+	ddf_msg(LVL_DEBUG, "iobase=%p irq=%d", (void *)pl050->iobase,
+	    res.irqs.irqs[0]);
+
+	rc = pio_enable((void *)pl050->iobase, sizeof(kmi_regs_t), &regs);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Error enabling PIO");
+		goto error;
+	}
+
+	pl050->regs = regs;
+
+	rc = register_interrupt_handler(pl050->dev, res.irqs.irqs[0],
+	    pl050_interrupt, &pl050_irq_code);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed registering interrupt handler. (%d)",
+		    rc);
+		goto error;
+	}
+
+	rc = irc_enable_interrupt(res.irqs.irqs[0]);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed enabling interrupt. (%d)", rc);
+		goto error;
+	}
+
+	pio_write_8(&pl050->regs->cr,
+	    BIT_V(uint8_t, kmi_cr_enable) |
+	    BIT_V(uint8_t, kmi_cr_rxintr));
+
+	return EOK;
+error:
+	return rc;
+}
+
+static int pl050_read(chardev_srv_t *srv, void *buffer, size_t size)
+{
+	pl050_t *pl050 = (pl050_t *)srv->srvs->sarg;
+	uint8_t *bp = buffer;
+	size_t left;
+
+	fibril_mutex_lock(&pl050->buf_lock);
+
+	left = size;
+	while (left > 0) {
+		while (pl050->buf_rp == pl050->buf_wp)
+			fibril_condvar_wait(&pl050->buf_cv, &pl050->buf_lock);
+		*bp++ = pl050->buffer[pl050->buf_rp];
+		--left;
+		pl050->buf_rp = (pl050->buf_rp + 1) % buffer_size;
+	}
+
+	fibril_mutex_unlock(&pl050->buf_lock);
+
+	return size;
+}
+
+static int pl050_write(chardev_srv_t *srv, const void *data, size_t size)
+{
+	pl050_t *pl050 = (pl050_t *)srv->srvs->sarg;
+	uint8_t *dp = (uint8_t *)data;
+	uint8_t status;
+	size_t i;
+
+	ddf_msg(LVL_NOTE, "%s/pl050_write(%zu bytes)", pl050->name, size);
+	for (i = 0; i < size; i++) {
+		while (true) {
+			status = pio_read_8(&pl050->regs->stat);
+			if ((status & BIT_V(uint8_t, kmi_stat_txempty)) != 0)
+				break;
+		}
+		pio_write_8(&pl050->regs->data, dp[i]);
+	}
+	ddf_msg(LVL_NOTE, "%s/pl050_write() success", pl050->name);
+
+	return size;
+}
+
+void pl050_char_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	pl050_t *pl050 = pl050_from_fun((ddf_fun_t *)arg);
+
+	chardev_conn(iid, icall, &pl050->cds);
+}
+
+/** Add device. */
+static int pl050_dev_add(ddf_dev_t *dev)
+{
+	ddf_fun_t *fun_a;
+	pl050_t *pl050 = NULL;
+	const char *mname;
+	int rc;
+
+	ddf_msg(LVL_DEBUG, "pl050_dev_add()");
+
+	pl050 = ddf_dev_data_alloc(dev, sizeof(pl050_t));
+	if (pl050 == NULL) {
+		ddf_msg(LVL_ERROR, "Failed allocating soft state.\n");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	pl050->name = (char *)ddf_dev_get_name(dev);
+	if (pl050->name == NULL) {
+		rc = ENOMEM;
+		goto error;
+	}
+
+	fun_a = ddf_fun_create(dev, fun_inner, "a");
+	if (fun_a == NULL) {
+		ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	pl050->fun_a = fun_a;
+	pl050->dev = dev;
+
+	rc = pl050_init(pl050);
+	if (rc != EOK)
+		goto error;
+
+	if (str_cmp(pl050->name, "kbd") == 0)
+		mname = "char/xtkbd";
+	else
+		mname = "char/ps2mouse";
+
+	rc = ddf_fun_add_match_id(fun_a, mname, 10);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    "char/xtkbd");
+		goto error;
+	}
+
+	chardev_srvs_init(&pl050->cds);
+	pl050->cds.ops = &pl050_chardev_ops;
+	pl050->cds.sarg = pl050;
+
+	ddf_fun_set_conn_handler(fun_a, pl050_char_conn);
+
+	rc = ddf_fun_bind(fun_a);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function 'a'. (%d)", rc);
+		ddf_fun_destroy(fun_a);
+		goto error;
+	}
+
+	ddf_msg(LVL_DEBUG, "Device added.");
+	return EOK;
+error:
+	if (pl050 != NULL)
+		free(pl050->name);
+	return rc;
+}
+
+static int pl050_fun_online(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "pl050_fun_online()");
+	return ddf_fun_online(fun);
+}
+
+static int pl050_fun_offline(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "pl050_fun_offline()");
+	return ddf_fun_offline(fun);
+}
+
+int main(int argc, char *argv[])
+{
+	int rc;
+
+	printf(NAME ": HelenOS pl050 serial device driver\n");
+	rc = ddf_log_init(NAME);
+	if (rc != EOK) {
+		printf(NAME ": Error connecting logging service.");
+		return 1;
+	}
+
+	return ddf_driver_main(&pl050_driver);
+}
+
Index: uspace/drv/char/pl050/pl050.ma
===================================================================
--- uspace/drv/char/pl050/pl050.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/char/pl050/pl050.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+10 arm/pl050
Index: uspace/drv/char/pl050/pl050_hw.h
===================================================================
--- uspace/drv/char/pl050/pl050_hw.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/char/pl050/pl050_hw.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2009 Vineeth Pillai
+ * Copyright (c) 2014 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 pl050
+ * @{
+ */
+/** @file ARM PrimeCell PS2 Keyboard/Mouse Interface (PL050) registers
+ */
+
+#ifndef PL050_HW_H
+#define PL050_HW_H
+
+#include <sys/types.h>
+
+typedef struct {
+	/** Control register */
+	uint8_t cr;
+	/** Padding */
+	uint8_t pad1[3];
+	/** Status register */
+	uint8_t stat;
+	/** Padding */
+	uint8_t pad5[3];
+	/** Received data */
+	uint8_t data;
+	/** Padding */
+	uint8_t pad9[3];
+	/** Clock divisor */
+	uint8_t clkdiv;
+	/** Padding */
+	uint8_t pad13[3];
+	/** Interrupt status register */
+	uint8_t ir;
+	/** Padding */
+	uint8_t pad17[3];
+} kmi_regs_t;
+
+typedef enum {
+	/** 0 = PS2 mode, 1 = No line control bit mode */
+	kmi_cr_type = 5,
+	/** Enable receiver interrupt */
+	kmi_cr_rxintr = 4,
+	/** Enable transmitter interrupt */
+	kmi_cr_txintr = 3,
+	/** Enable PrimeCell KMI */
+	kmi_cr_enable = 2,
+	/** Force KMI data LOW */
+	kmi_cr_forcedata = 1,
+	/** Force KMI clock LOW */
+	kmi_cr_forceclock = 0
+} kmi_cr_bits_t;
+
+typedef enum {
+	kmi_stat_txempty = 6,
+	kmi_stat_txbusy = 5,
+	kmi_stat_rxfull = 4,
+	kmi_stat_rxbusy = 3,
+	kmi_stat_rxparity = 2,
+	kmi_stat_clkin = 1,
+	kmi_stat_datain = 0
+} kmi_stat_bits_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/drv/char/ps2mouse/Makefile
===================================================================
--- uspace/drv/char/ps2mouse/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/char/ps2mouse/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -33,5 +33,4 @@
 
 SOURCES = \
-	chardev.c \
 	main.c \
 	ps2mouse.c
Index: pace/drv/char/ps2mouse/chardev.c
===================================================================
--- uspace/drv/char/ps2mouse/chardev.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <errno.h>
-#include <mem.h>
-#include <ipc/dev_iface.h>
-#include <ddf/log.h>
-
-#include "chardev.h"
-
-// TODO make this shared
-enum {
-	IPC_CHAR_READ = DEV_FIRST_CUSTOM_METHOD,
-	IPC_CHAR_WRITE,
-};
-
-ssize_t chardev_read(async_exch_t *exch, void *data, size_t size)
-{
-	if (!exch)
-		return EBADMEM;
-	if (size > 4 * sizeof(sysarg_t))
-		return ELIMIT;
-
-	sysarg_t message[4] = { 0 };
-	const ssize_t ret = async_req_1_4(exch, IPC_CHAR_READ, size,
-	    &message[0], &message[1], &message[2], &message[3]);
-	if (ret > 0 && (size_t)ret <= size)
-		memcpy(data, message, size);
-	return ret;
-}
-
-ssize_t chardev_write(async_exch_t *exch, const void *data, size_t size)
-{
-	if (!exch)
-		return EBADMEM;
-	if (size > 3 * sizeof(sysarg_t))
-		return ELIMIT;
-
-	sysarg_t message[3] = { 0 };
-	memcpy(message, data, size);
-	return async_req_4_0(exch, IPC_CHAR_WRITE, size,
-	    message[0], message[1], message[2]);
-}
Index: pace/drv/char/ps2mouse/chardev.h
===================================================================
--- uspace/drv/char/ps2mouse/chardev.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvmouse
- * @{
- */
-/** @file
- * @brief ps/2 mouse driver.
- */
-
-#ifndef _CHARDEV_H_
-#define _CHARDEV_H_
-
-#include <libarch/types.h>
-#include <async.h>
-
-ssize_t chardev_read(async_exch_t *, void *, size_t);
-ssize_t chardev_write(async_exch_t *, const void *, size_t);
-
-#endif
-/**
- * @}
- */
Index: uspace/drv/char/ps2mouse/ps2mouse.c
===================================================================
--- uspace/drv/char/ps2mouse/ps2mouse.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/char/ps2mouse/ps2mouse.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,4 +37,5 @@
 #include <ddf/log.h>
 #include <io/keycode.h>
+#include <io/chardev.h>
 #include <io/console.h>
 #include <ipc/mouseev.h>
@@ -42,5 +43,4 @@
 
 #include "ps2mouse.h"
-#include "chardev.h"
 
 #define PS2_MOUSE_GET_DEVICE_ID   0xf2
Index: uspace/drv/char/xtkbd/Makefile
===================================================================
--- uspace/drv/char/xtkbd/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/char/xtkbd/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -33,5 +33,4 @@
 
 SOURCES = \
-	chardev.c \
 	main.c \
 	xtkbd.c
Index: pace/drv/char/xtkbd/chardev.c
===================================================================
--- uspace/drv/char/xtkbd/chardev.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <errno.h>
-#include <mem.h>
-#include <ipc/dev_iface.h>
-#include <ddf/log.h>
-
-#include "chardev.h"
-
-// TODO make this shared
-enum {
-	IPC_CHAR_READ = DEV_FIRST_CUSTOM_METHOD,
-	IPC_CHAR_WRITE,
-};
-
-ssize_t chardev_read(async_exch_t *exch, void *data, size_t size)
-{
-	if (!exch)
-		return EBADMEM;
-	if (size > 4 * sizeof(sysarg_t))
-		return ELIMIT;
-
-	sysarg_t message[4] = { 0 };
-	const ssize_t ret = async_req_1_4(exch, IPC_CHAR_READ, size,
-	    &message[0], &message[1], &message[2], &message[3]);
-	if (ret > 0 && (size_t)ret <= size)
-		memcpy(data, message, size);
-	return ret;
-}
-
-ssize_t chardev_write(async_exch_t *exch, const void *data, size_t size)
-{
-	if (!exch)
-		return EBADMEM;
-	if (size > 3 * sizeof(sysarg_t))
-		return ELIMIT;
-
-	sysarg_t message[3] = { 0 };
-	memcpy(message, data, size);
-	return async_req_4_0(exch, IPC_CHAR_WRITE, size,
-	    message[0], message[1], message[2]);
-}
Index: pace/drv/char/xtkbd/chardev.h
===================================================================
--- uspace/drv/char/xtkbd/chardev.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvkbd
- * @{
- */
-/** @file
- * @brief ps/2 mouse driver.
- */
-
-#ifndef _CHARDEV_H_
-#define _CHARDEV_H_
-
-#include <libarch/types.h>
-#include <async.h>
-
-ssize_t chardev_read(async_exch_t *, void *, size_t);
-ssize_t chardev_write(async_exch_t *, const void *, size_t);
-
-#endif
-/**
- * @}
- */
Index: uspace/drv/char/xtkbd/xtkbd.c
===================================================================
--- uspace/drv/char/xtkbd/xtkbd.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/char/xtkbd/xtkbd.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,9 +36,9 @@
 #include <ddf/log.h>
 #include <io/keycode.h>
+#include <io/chardev.h>
 #include <io/console.h>
 #include <ipc/kbdev.h>
 #include <abi/ipc/methods.h>
 
-#include "chardev.h"
 #include "xtkbd.h"
 
@@ -159,5 +159,5 @@
 static const int scanmap_e0[] = {
 	[0x38] = KC_RALT,
-	[0x1d] = KC_RSHIFT,
+	[0x1d] = KC_RCTRL,
 
 	[0x37] = KC_PRTSCR,
@@ -199,5 +199,5 @@
  * @param dev DDF device structure.
  *
- * Connects to parent, creates mouse function, starts polling fibril.
+ * Connects to parent, creates keyboard function, starts polling fibril.
  */
 int xt_kbd_init(xt_kbd_t *kbd, ddf_dev_t *dev)
@@ -207,9 +207,12 @@
 	kbd->client_sess = NULL;
 	kbd->parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
-	if (!kbd->parent_sess)
-		return ENOMEM;
+	if (!kbd->parent_sess) {
+		ddf_msg(LVL_ERROR, "Failed creating parent session.");
+		return EIO;
+	}
 
 	kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
 	if (!kbd->kbd_fun) {
+		ddf_msg(LVL_ERROR, "Failed creating function 'kbd'.");
 		return ENOMEM;
 	}
@@ -218,10 +221,13 @@
 	int ret = ddf_fun_bind(kbd->kbd_fun);
 	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function 'kbd'.");
 		ddf_fun_destroy(kbd->kbd_fun);
-		return ENOMEM;
+		return EEXIST;
 	}
 
 	ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
 	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding function 'kbd' to category "
+		    "'keyboard'.");
 		ddf_fun_unbind(kbd->kbd_fun);
 		ddf_fun_destroy(kbd->kbd_fun);
@@ -231,8 +237,10 @@
 	kbd->polling_fibril = fibril_create(polling, kbd);
 	if (!kbd->polling_fibril) {
+		ddf_msg(LVL_ERROR, "Failed creating polling fibril.");
 		ddf_fun_unbind(kbd->kbd_fun);
 		ddf_fun_destroy(kbd->kbd_fun);
 		return ENOMEM;
 	}
+
 	fibril_add_ready(kbd->polling_fibril);
 	return EOK;
@@ -241,5 +249,5 @@
 /** Get data and parse scancodes.
  * @param arg Pointer to xt_kbd_t structure.
- * @return Never.
+ * @return EIO on error.
  */
 int polling(void *arg)
@@ -259,4 +267,6 @@
 		uint8_t code = 0;
 		ssize_t size = chardev_read(parent_exch, &code, 1);
+		if (size != 1)
+			return EIO;
 
 		/** Ignore AT command reply */
@@ -269,12 +279,9 @@
 			map_size = sizeof(scanmap_e0) / sizeof(int);
 			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+
 			// TODO handle print screen
 		}
-
-		/* Invalid read. */
-		if (size != 1) {
-			continue;
-		}
-
 
 		/* Bit 7 indicates press/release */
Index: pace/drv/infrastructure/root/Makefile
===================================================================
--- uspace/drv/infrastructure/root/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,37 +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.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
-BINARY = root
-
-SOURCES = \
-	root.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/drv/infrastructure/root/root.c
===================================================================
--- uspace/drv/infrastructure/root/root.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,248 +1,0 @@
-/*
- * Copyright (c) 2010 Lenka Trochtova
- * Copyright (c) 2010 Vojtech Horky
- * Copyright (c) 2011 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.
- */
-
-/**
- * @defgroup root Root device driver.
- * @brief HelenOS root device driver.
- * @{
- */
-
-/** @file
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <fibril_synch.h>
-#include <stdlib.h>
-#include <str.h>
-#include <str_error.h>
-#include <ctype.h>
-#include <macros.h>
-#include <inttypes.h>
-#include <sysinfo.h>
-
-#include <ddf/driver.h>
-#include <ddf/log.h>
-
-#define NAME "root"
-
-#define PLATFORM_FUN_NAME "hw"
-#define PLATFORM_FUN_MATCH_ID_FMT "platform/%s"
-#define PLATFORM_FUN_MATCH_SCORE 100
-
-#define VIRTUAL_FUN_NAME "virt"
-#define VIRTUAL_FUN_MATCH_ID "rootvirt"
-#define VIRTUAL_FUN_MATCH_SCORE 100
-
-static int root_dev_add(ddf_dev_t *dev);
-static int root_fun_online(ddf_fun_t *fun);
-static int root_fun_offline(ddf_fun_t *fun);
-
-/** The root device driver's standard operations. */
-static driver_ops_t root_ops = {
-	.dev_add = &root_dev_add,
-	.fun_online = &root_fun_online,
-	.fun_offline = &root_fun_offline
-};
-
-/** The root device driver structure. */
-static driver_t root_driver = {
-	.name = NAME,
-	.driver_ops = &root_ops
-};
-
-/** Create the function which represents the root of virtual device tree.
- *
- * @param dev	Device
- * @return	EOK on success or negative error code
- */
-static int add_virtual_root_fun(ddf_dev_t *dev)
-{
-	const char *name = VIRTUAL_FUN_NAME;
-	ddf_fun_t *fun;
-	int rc;
-
-	ddf_msg(LVL_DEBUG, "Adding new function for virtual devices. "
-	    "Function node is `%s' (%d %s)", name,
-	    VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID);
-
-	fun = ddf_fun_create(dev, fun_inner, name);
-	if (fun == NULL) {
-		ddf_msg(LVL_ERROR, "Failed creating function %s", name);
-		return ENOMEM;
-	}
-
-	rc = ddf_fun_add_match_id(fun, VIRTUAL_FUN_MATCH_ID,
-	    VIRTUAL_FUN_MATCH_SCORE);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
-		    name);
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-
-	rc = ddf_fun_bind(fun);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
-		    str_error(rc));
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-
-	return EOK;
-}
-
-/** Create the function which represents the root of HW device tree.
- *
- * @param dev	Device
- * @return	EOK on success or negative error code
- */
-static int add_platform_fun(ddf_dev_t *dev)
-{
-	char *match_id;
-	char *platform;
-	size_t platform_size;
-
-	const char *name = PLATFORM_FUN_NAME;
-	ddf_fun_t *fun;
-	int rc;
-
-	/* Get platform name from sysinfo. */
-	platform = sysinfo_get_data("platform", &platform_size);
-	if (platform == NULL) {
-		ddf_msg(LVL_ERROR, "Failed to obtain platform name.");
-		return ENOENT;
-	}
-
-	/* Null-terminate string. */
-	platform = realloc(platform, platform_size + 1);
-	if (platform == NULL) {
-		ddf_msg(LVL_ERROR, "Memory allocation failed.");
-		return ENOMEM;
-	}
-
-	platform[platform_size] = '\0';
-
-	/* Construct match ID. */
-	if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
-		ddf_msg(LVL_ERROR, "Memory allocation failed.");
-		free(platform);
-		return ENOMEM;
-	}
-
-	free(platform);
-
-	/* Add function. */
-	ddf_msg(LVL_DEBUG, "Adding platform function. Function node is `%s' "
-	    " (%d %s)", PLATFORM_FUN_NAME, PLATFORM_FUN_MATCH_SCORE,
-	    match_id);
-
-	fun = ddf_fun_create(dev, fun_inner, name);
-	if (fun == NULL) {
-		ddf_msg(LVL_ERROR, "Error creating function %s", name);
-		free(match_id);
-		return ENOMEM;
-	}
-
-	rc = ddf_fun_add_match_id(fun, match_id, PLATFORM_FUN_MATCH_SCORE);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
-		    name);
-		free(match_id);
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-
-	free(match_id);
-
-	rc = ddf_fun_bind(fun);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
-		    str_error(rc));
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-
-	return EOK;
-}
-
-/** Get the root device.
- *
- * @param dev		The device which is root of the whole device tree (both
- *			of HW and pseudo devices).
- */
-static int root_dev_add(ddf_dev_t *dev)
-{
-	ddf_msg(LVL_DEBUG, "root_dev_add, device handle=%" PRIun,
-	    ddf_dev_get_handle(dev));
-
-	/*
-	 * Register virtual devices root.
-	 * We warn on error occurrence because virtual devices shall not be
-	 * vital for the system.
-	 */
-	int res = add_virtual_root_fun(dev);
-	if (res != EOK)
-		ddf_msg(LVL_WARN, "Failed to add virtual child.");
-
-	/* Register root device's children. */
-	res = add_platform_fun(dev);
-	if (EOK != res)
-		ddf_msg(LVL_ERROR, "Failed adding child device for platform.");
-
-	return res;
-}
-
-static int root_fun_online(ddf_fun_t *fun)
-{
-	ddf_msg(LVL_DEBUG, "root_fun_online()");
-	return ddf_fun_online(fun);
-}
-
-static int root_fun_offline(ddf_fun_t *fun)
-{
-	ddf_msg(LVL_DEBUG, "root_fun_offline()");
-	return ddf_fun_offline(fun);
-}
-
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS root device driver\n");
-
-	ddf_log_init(NAME);
-	return ddf_driver_main(&root_driver);
-}
-
-/**
- * @}
- */
-
Index: pace/drv/infrastructure/root/root.ma
===================================================================
--- uspace/drv/infrastructure/root/root.ma	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 root
Index: pace/drv/infrastructure/rootamdm37x/Makefile
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,38 +1,0 @@
-#
-# Copyright (c) 2012 Jan Vesely
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
-BINARY = rootamdm37x
-
-SOURCES = \
-	amdm37x.c \
-	rootamdm37x.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/drv/infrastructure/rootamdm37x/amdm37x.c
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/amdm37x.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,404 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @defgroup root_amdm37x TI AM/DM37x platform driver.
- * @brief HelenOS TI AM/DM37x platform driver.
- * @{
- */
-
-/** @file
- */
-
-#include "amdm37x.h"
-
-#include <assert.h>
-#include <ddi.h>
-#include <ddf/log.h>
-#include <errno.h>
-#include <stdio.h>
-
-static void log(const volatile void *place, uint32_t val, volatile void* base, size_t size, void *data, bool write)
-{
-	printf("PIO %s: %p(%p) %#"PRIx32"\n", write ? "WRITE" : "READ",
-	    (place - base) + data, place, val);
-}
-
-
-int amdm37x_init(amdm37x_t *device, bool trace)
-{
-	assert(device);
-	int ret = EOK;
-
-	ret = pio_enable((void*)USBHOST_CM_BASE_ADDRESS, USBHOST_CM_SIZE,
-	    (void**)&device->cm.usbhost);
-	if (ret != EOK)
-		return ret;
-
-	ret = pio_enable((void*)CORE_CM_BASE_ADDRESS, CORE_CM_SIZE,
-	    (void**)&device->cm.core);
-	if (ret != EOK)
-		return ret;
-
-	ret = pio_enable((void*)CLOCK_CONTROL_CM_BASE_ADDRESS,
-		    CLOCK_CONTROL_CM_SIZE, (void**)&device->cm.clocks);
-	if (ret != EOK)
-		return ret;
-
-	ret = pio_enable((void*)MPU_CM_BASE_ADDRESS,
-		    MPU_CM_SIZE, (void**)&device->cm.mpu);
-	if (ret != EOK)
-		return ret;
-
-	ret = pio_enable((void*)IVA2_CM_BASE_ADDRESS,
-		    IVA2_CM_SIZE, (void**)&device->cm.iva2);
-	if (ret != EOK)
-		return ret;
-
-	ret = pio_enable((void*)CLOCK_CONTROL_PRM_BASE_ADDRESS,
-	    CLOCK_CONTROL_PRM_SIZE, (void**)&device->prm.clocks);
-	if (ret != EOK)
-		return ret;
-
-	ret = pio_enable((void*)GLOBAL_REG_PRM_BASE_ADDRESS,
-	    GLOBAL_REG_PRM_SIZE, (void**)&device->prm.global);
-	if (ret != EOK)
-		return ret;
-
-	ret = pio_enable((void*)AMDM37x_USBTLL_BASE_ADDRESS,
-	    AMDM37x_USBTLL_SIZE, (void**)&device->tll);
-	if (ret != EOK)
-		return ret;
-
-	ret = pio_enable((void*)AMDM37x_UHH_BASE_ADDRESS,
-	    AMDM37x_UHH_SIZE, (void**)&device->uhh);
-	if (ret != EOK)
-		return ret;
-
-	if (trace) {
-		pio_trace_enable(device->tll, AMDM37x_USBTLL_SIZE, log, (void*)AMDM37x_USBTLL_BASE_ADDRESS);
-		pio_trace_enable(device->cm.clocks, CLOCK_CONTROL_CM_SIZE, log, (void*)CLOCK_CONTROL_CM_BASE_ADDRESS);
-		pio_trace_enable(device->cm.core, CORE_CM_SIZE, log, (void*)CORE_CM_BASE_ADDRESS);
-		pio_trace_enable(device->cm.mpu, MPU_CM_SIZE, log, (void*)MPU_CM_BASE_ADDRESS);
-		pio_trace_enable(device->cm.iva2, IVA2_CM_SIZE, log, (void*)IVA2_CM_BASE_ADDRESS);
-		pio_trace_enable(device->cm.usbhost, USBHOST_CM_SIZE, log, (void*)USBHOST_CM_BASE_ADDRESS);
-		pio_trace_enable(device->uhh, AMDM37x_UHH_SIZE, log, (void*)AMDM37x_UHH_BASE_ADDRESS);
-		pio_trace_enable(device->prm.clocks, CLOCK_CONTROL_PRM_SIZE, log, (void*)CLOCK_CONTROL_PRM_BASE_ADDRESS);
-		pio_trace_enable(device->prm.global, GLOBAL_REG_PRM_SIZE, log, (void*)GLOBAL_REG_PRM_BASE_ADDRESS);
-	}
-	return EOK;
-}
-
-
-/** Set DPLLs 1,2,3,4,5 to ON (locked) and autoidle.
- * @param device Register map.
- *
- * The idea is to get all DPLLs running and make hw control their power mode,
- * based on the module requirements (module ICLKs and FCLKs).
- */
-void amdm37x_setup_dpll_on_autoidle(amdm37x_t *device)
-{
-	assert(device);
-	/* Get SYS_CLK value, it is used as reference clock by all DPLLs,
-	 * NFI who sets this or why it is set to specific value. */
-	const unsigned osc_clk = pio_read_32(&device->prm.clocks->clksel)
-	    & CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_MASK;
-	const unsigned clk_reg = pio_read_32(&device->prm.global->clksrc_ctrl);
-	const unsigned base_freq = sys_clk_freq_kHz(osc_clk)
-	    / GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_GET(clk_reg);
-	ddf_msg(LVL_NOTE, "Base frequency: %d.%dMhz",
-	    base_freq / 1000, base_freq % 1000);
-
-
-	/* DPLL1 provides MPU(CPU) clock.
-	 * It uses SYS_CLK as reference clock and core clock (DPLL3) as
-	 * high frequency bypass (MPU then runs on L3 interconnect freq).
-	 * It should be setup by fw or u-boot.*/
-	mpu_cm_regs_t *mpu = device->cm.mpu;
-
-	/* Current MPU frequency. */
-	if (pio_read_32(&mpu->clkstst) & MPU_CM_CLKSTST_CLKACTIVITY_MPU_ACTIVE_FLAG) {
-		if (pio_read_32(&mpu->idlest_pll) & MPU_CM_IDLEST_PLL_ST_MPU_CLK_LOCKED_FLAG) {
-			/* DPLL active and locked */
-			const uint32_t reg = pio_read_32(&mpu->clksel1_pll);
-			const unsigned multiplier =
-			    (reg & MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_MASK)
-				>> MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_SHIFT;
-			const unsigned divisor =
-			    (reg & MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_MASK)
-				>> MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_SHIFT;
-			const unsigned divisor2 =
-			    (pio_read_32(&mpu->clksel2_pll)
-			        & MPU_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV_MASK);
-			if (multiplier && divisor && divisor2) {
-				/** See AMDM37x TRM p. 300 for the formula */
-				const unsigned freq =
-				    ((base_freq * multiplier) / (divisor + 1))
-				    / divisor2;
-				ddf_msg(LVL_NOTE, "MPU running at %d.%d MHz",
-				    freq / 1000, freq % 1000);
-			} else {
-				ddf_msg(LVL_WARN, "Frequency divisor and/or "
-				    "multiplier value invalid: %d %d %d",
-				    multiplier, divisor, divisor2);
-			}
-		} else {
-			/* DPLL in LP bypass mode */
-			const unsigned divisor =
-			    MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_VAL(
-			        pio_read_32(&mpu->clksel1_pll));
-			ddf_msg(LVL_NOTE, "MPU DPLL in bypass mode, running at"
-			    " CORE CLK / %d MHz", divisor);
-		}
-	} else {
-		ddf_msg(LVL_WARN, "MPU clock domain is not active, we should not be running...");
-	}
-	// TODO: Enable this (automatic MPU downclocking):
-#if 0
-	/* Enable low power bypass mode, this will take effect the next lock or
-	 * relock sequence. */
-	//TODO: We might need to force re-lock after enabling this
-	pio_set_32(&mpu->clken_pll, MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG, 5);
-	/* Enable automatic relocking */
-	pio_change_32(&mpu->autoidle_pll, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK, 5);
-#endif
-
-	/* DPLL2 provides IVA(video acceleration) clock.
-	 * It uses SYS_CLK as reference clokc and core clock (DPLL3) as
-	 * high frequency bypass (IVA runs on L3 freq).
-	 */
-	// TODO: We can probably turn this off entirely. IVA is left unused.
-	/* Enable low power bypass mode, this will take effect the next lock or
-	 * relock sequence. */
-	//TODO: We might need to force re-lock after enabling this
-	pio_set_32(&device->cm.iva2->clken_pll, MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG, 5);
-	/* Enable automatic relocking */
-	pio_change_32(&device->cm.iva2->autoidle_pll, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK, 5);
-
-	/* DPLL3 provides tons of clocks:
-	 * CORE_CLK, COREX2_CLK, DSS_TV_CLK, 12M_CLK, 48M_CLK, 96M_CLK, L3_ICLK,
-	 * and L4_ICLK. It uses SYS_CLK as reference clock and low frequency
-	 * bypass. It should be setup by fw or u-boot as it controls critical
-	 * interconnects.
-	 */
-	if (pio_read_32(&device->cm.clocks->idlest_ckgen) & CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CORE_CLK_FLAG) {
-		/* DPLL active and locked */
-		const uint32_t reg =
-		    pio_read_32(&device->cm.clocks->clksel1_pll);
-		const unsigned multiplier =
-		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_GET(reg);
-		const unsigned divisor =
-		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_GET(reg);
-		const unsigned divisor2 =
-		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_GET(reg);
-		if (multiplier && divisor && divisor2) {
-			/** See AMDM37x TRM p. 300 for the formula */
-			const unsigned freq =
-			    ((base_freq * multiplier) / (divisor + 1)) / divisor2;
-			ddf_msg(LVL_NOTE, "CORE CLK running at %d.%d MHz",
-			    freq / 1000, freq % 1000);
-			const unsigned l3_div =
-			    pio_read_32(&device->cm.core->clksel)
-			    & CORE_CM_CLKSEL_CLKSEL_L3_MASK;
-			if (l3_div == CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED1 ||
-			    l3_div == CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED2) {
-				ddf_msg(LVL_NOTE, "L3 interface at %d.%d MHz",
-				    (freq / l3_div) / 1000,
-				    (freq / l3_div) % 1000);
-			} else {
-				ddf_msg(LVL_WARN,"L3 interface clock divisor is"
-				    " invalid: %d", l3_div);
-			}
-		} else {
-			ddf_msg(LVL_WARN, "DPLL3 frequency divisor and/or "
-			    "multiplier value invalid: %d %d %d",
-			    multiplier, divisor, divisor2);
-		}
-	} else {
-		ddf_msg(LVL_WARN, "CORE CLK in bypass mode, fruunig at SYS_CLK"
-		   " frreq of %d.%d MHz", base_freq / 1000, base_freq % 1000);
-	}
-
-	/* Set DPLL3 to automatic to save power */
-	pio_change_32(&device->cm.clocks->autoidle_pll,
-	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC,
-	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_MASK, 5);
-
-	/* DPLL4 provides peripheral domain clocks:
-	 * CAM_MCLK, EMU_PER_ALWON_CLK, DSS1_ALWON_FCLK, and 96M_ALWON_FCLK.
-	 * It uses SYS_CLK as reference clock and low frequency bypass.
-	 * 96M clock is used by McBSP[1,5], MMC[1,2,3], I2C[1,2,3], so
-	 * we can probably turn this off entirely (DSS is still non-functional).
-	 */
-	/* Set DPLL4 to automatic to save power */
-	pio_change_32(&device->cm.clocks->autoidle_pll,
-	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_AUTOMATIC,
-	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_MASK, 5);
-
-	/* DPLL5 provide peripheral domain clocks: 120M_FCLK.
-	 * It uses SYS_CLK as reference clock and low frequency bypass.
-	 * 120M clock is used by HS USB and USB TLL.
-	 */
-	// TODO setup DPLL5
-	if ((pio_read_32(&device->cm.clocks->clken2_pll)
-	        & CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK)
-	    != CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK) {
-		/* Compute divisors and multiplier
-		 * See AMDM37x TRM p. 300 for the formula */
-		// TODO: base_freq does not have to be rounded to Mhz
-		// (that's why I used KHz as unit).
-		const unsigned mult = 120;
-		const unsigned div = (base_freq / 1000) - 1;
-		const unsigned div2 = 1;
-		if ( ((base_freq % 1000) != 0) || (div > 127)) {
-			ddf_msg(LVL_ERROR, "Rounding error, or divisor to big "
-			    "freq: %d, div: %d", base_freq, div);
-			return;
-		};
-		assert(div <= 127);
-
-		/* Set multiplier */
-		pio_change_32(&device->cm.clocks->clksel4_pll,
-		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_CREATE(mult),
-		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_MASK, 10);
-
-		/* Set DPLL divisor */
-		pio_change_32(&device->cm.clocks->clksel4_pll,
-		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_CREATE(div),
-		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_MASK, 10);
-
-		/* Set output clock divisor */
-		pio_change_32(&device->cm.clocks->clksel5_pll,
-		    CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_CREATE(div2),
-		    CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_MASK, 10);
-
-		/* Start DPLL5 */
-		pio_change_32(&device->cm.clocks->clken2_pll,
-		    CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK,
-		    CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK, 10);
-
-	}
-	/* Set DPLL5 to automatic to save power */
-	pio_change_32(&device->cm.clocks->autoidle2_pll,
-	    CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_AUTOMATIC,
-	    CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_MASK, 5);
-}
-
-/** Enable/disable function and interface clocks for USBTLL and USBHOST.
- * @param device Register map.
- * @param on True to switch clocks on.
- */
-void amdm37x_usb_clocks_set(amdm37x_t *device, bool enabled)
-{
-	if (enabled) {
-		/* Enable interface and function clock for USB TLL */
-		pio_set_32(&device->cm.core->fclken3,
-		    CORE_CM_FCLKEN3_EN_USBTLL_FLAG, 5);
-		pio_set_32(&device->cm.core->iclken3,
-		    CORE_CM_ICLKEN3_EN_USBTLL_FLAG, 5);
-
-		/* Enable interface and function clock for USB hosts */
-		pio_set_32(&device->cm.usbhost->fclken,
-		    USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG |
-		    USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG, 5);
-		pio_set_32(&device->cm.usbhost->iclken,
-		    USBHOST_CM_ICLKEN_EN_USBHOST, 5);
-#if 0
-		printf("DPLL5 (and everything else) should be on: %"
-		    PRIx32" %"PRIx32".\n",
-		    pio_read_32(&device->cm.clocks->idlest_ckgen),
-		    pio_read_32(&device->cm.clocks->idlest2_ckgen));
-#endif
-	} else {
-		/* Disable interface and function clock for USB hosts */
-		pio_clear_32(&device->cm.usbhost->iclken,
-		    USBHOST_CM_ICLKEN_EN_USBHOST, 5);
-		pio_clear_32(&device->cm.usbhost->fclken,
-		    USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG |
-		    USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG, 5);
-
-		/* Disable interface and function clock for USB TLL */
-		pio_clear_32(&device->cm.core->iclken3,
-		    CORE_CM_ICLKEN3_EN_USBTLL_FLAG, 5);
-		pio_clear_32(&device->cm.core->fclken3,
-		    CORE_CM_FCLKEN3_EN_USBTLL_FLAG, 5);
-	}
-}
-
-/** Initialize USB TLL port connections.
- *
- * Different modes are on page 3312 of the Manual Figure 22-34.
- * Select mode than can operate in FS/LS.
- */
-int amdm37x_usb_tll_init(amdm37x_t *device)
-{
-	/* Check access */
-	if (pio_read_32(&device->cm.core->idlest3) & CORE_CM_IDLEST3_ST_USBTLL_FLAG) {
-		ddf_msg(LVL_ERROR, "USB TLL is not accessible");
-		return EIO;
-	}
-
-	/* Reset USB TLL */
-	pio_set_32(&device->tll->sysconfig, TLL_SYSCONFIG_SOFTRESET_FLAG, 5);
-	ddf_msg(LVL_DEBUG2, "Waiting for USB TLL reset");
-	while (!(pio_read_32(&device->tll->sysstatus) & TLL_SYSSTATUS_RESET_DONE_FLAG));
-	ddf_msg(LVL_DEBUG, "USB TLL Reset done.");
-
-	/* Setup idle mode (smart idle) */
-	pio_change_32(&device->tll->sysconfig,
-	    TLL_SYSCONFIG_CLOCKACTIVITY_FLAG | TLL_SYSCONFIG_AUTOIDLE_FLAG |
-	    TLL_SYSCONFIG_SIDLE_MODE_SMART, TLL_SYSCONFIG_SIDLE_MODE_MASK, 5);
-
-	/* Smart idle for UHH */
-	pio_change_32(&device->uhh->sysconfig,
-	    UHH_SYSCONFIG_CLOCKACTIVITY_FLAG | UHH_SYSCONFIG_AUTOIDLE_FLAG |
-	    UHH_SYSCONFIG_SIDLE_MODE_SMART, UHH_SYSCONFIG_SIDLE_MODE_MASK, 5);
-
-	/* Set all ports to go through TLL(UTMI)
-	 * Direct connection can only work in HS mode */
-	pio_set_32(&device->uhh->hostconfig,
-	    UHH_HOSTCONFIG_P1_ULPI_BYPASS_FLAG |
-	    UHH_HOSTCONFIG_P2_ULPI_BYPASS_FLAG |
-	    UHH_HOSTCONFIG_P3_ULPI_BYPASS_FLAG, 5);
-
-	/* What is this? */
-	pio_set_32(&device->tll->shared_conf, TLL_SHARED_CONF_FCLK_IS_ON_FLAG, 5);
-
-	for (unsigned i = 0; i < 3; ++i) {
-		/* Serial mode is the only one capable of FS/LS operation.
-		 * Select FS/LS mode, no idea what the difference is
-		 * one of bidirectional modes might be good choice
-		 * 2 = 3pin bidi phy. */
-		pio_change_32(&device->tll->channel_conf[i],
-		    TLL_CHANNEL_CONF_CHANMODE_UTMI_SERIAL_MODE |
-		    TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_PHY,
-		    TLL_CHANNEL_CONF_CHANMODE_MASK |
-		    TLL_CHANNEL_CONF_FSLSMODE_MASK, 5);
-	}
-	return EOK;
-}
Index: pace/drv/infrastructure/rootamdm37x/amdm37x.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/amdm37x.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrv
- * @{
- */
-/** @file
- * @brief AM/DM 37x device.
- */
-#ifndef AMDM37x_H
-#define AMDM37x_H
-
-#include "uhh.h"
-#include "usbtll.h"
-
-#include "cm/core.h"
-#include "cm/clock_control.h"
-#include "cm/usbhost.h"
-#include "cm/mpu.h"
-#include "cm/iva2.h"
-
-#include "prm/clock_control.h"
-#include "prm/global_reg.h"
-
-#include <stdbool.h>
-
-typedef struct {
-	uhh_regs_t *uhh;
-	tll_regs_t *tll;
-	struct {
-		mpu_cm_regs_t *mpu;
-		iva2_cm_regs_t *iva2;
-		core_cm_regs_t *core;
-		clock_control_cm_regs_t *clocks;
-		usbhost_cm_regs_t *usbhost;
-	} cm;
-	struct {
-		clock_control_prm_regs_t *clocks;
-		global_reg_prm_regs_t *global;
-	} prm;
-} amdm37x_t;
-
-int amdm37x_init(amdm37x_t *device, bool trace_io);
-int amdm37x_usb_tll_init(amdm37x_t *device);
-void amdm37x_setup_dpll_on_autoidle(amdm37x_t *device);
-void amdm37x_usb_clocks_set(amdm37x_t *device, bool enabled);
-
-#endif
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootamdm37x/cm/clock_control.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/clock_control.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,161 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvclockcontrolcm
- * @{
- */
-/** @file
- * @brief Clock Control Clock Management IO register structure.
- */
-#ifndef AMDM37x_CLOCK_CONTROL_CM_H
-#define AMDM37x_CLOCK_CONTROL_CM_H
-#include <sys/types.h>
-#include <macros.h>
-
-/* AM/DM37x TRM p.485 */
-#define CLOCK_CONTROL_CM_BASE_ADDRESS  0x48004d00
-#define CLOCK_CONTROL_CM_SIZE  8192
-
-/** Clock control register map
- *
- * Periph DPLL == DPLL4
- * Core DPLL == DPLL3
- */
-typedef struct {
-	ioport32_t clken_pll;
-#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_EMU_PERIPH_FLAG   (1 << 31)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_CAM_FLAG   (1 << 30)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_DSS1_FLAG   (1 << 29)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_TV_FLAG   (1 << 28)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_96M_FLAG   (1 << 27)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_DRIFTGUARD_FLAG   (1 << 19)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_MASK   (0x7 << 16)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_LP_STOP   (0x1 << 16)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_LOCK   (0x7 << 16)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_EMU_CORE_FLAG   (1 << 12)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LPMODE_FLAG   (1 << 10)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_DRIFTGUARD_FLAG   (1 << 3)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_MASK   (0x7)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LP_BYPASS   (0x5)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_FAST_RELOCK   (0x6)
-#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LOCK   (0x7)
-
-	ioport32_t clken2_pll;
-#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LPMODE_FLAG   (1 << 10)
-#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_DRIFTGUARD_FLAG   (1 << 3)
-#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK   (0x7)
-#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LP_STOP   (0x1)
-#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK   (0x7)
-
-	PADD32[6];
-
-	const ioport32_t idlest_ckgen;
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_EMU_PERIPH_CLK_FLAG   (1 << 13)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CAM_CLK_FLAG   (1 << 12)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_DSS1_CLK_FLAG   (1 << 11)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_TV_CLK_FLAG   (1 << 10)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_FUNC96M_CLK_FLAG   (1 << 9)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_EMU_CORE_CLK_FLAG   (1 << 8)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_54M_CLK_FLAG   (1 << 5)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_12M_CLK_FLAG   (1 << 4)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_48M_CLK_FLAG   (1 << 3)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_96M_CLK_FLAG   (1 << 2)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_PERIPH_CLK_FLAG   (1 << 1)
-#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CORE_CLK_FLAG   (1 << 0)
-
-	const ioport32_t idlest2_ckgen;
-#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_FUNC120M_CLK_FLAG   (1 << 3)
-#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_120M_CLK_FLAG   (1 << 1)
-#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_PERIPH2_CLK_FLAG   (1 << 0)
-
-	PADD32[2];
-
-	ioport32_t autoidle_pll;
-#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_MASK   (0x7 << 3)
-#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_DISABLED   (0x0 << 3)
-#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_AUTOMATIC   (0x1 << 3)
-#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_MASK   (0x7)
-#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_DISABLED   (0x0)
-#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC   (0x1)
-#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC_BYPASS   (0x5)
-
-	ioport32_t autoidle2_pll;
-#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_MASK   (0x7)
-#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_DISABLED   (0x0)
-#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_AUTOMATIC   (0x1)
-
-	PADD32[2];
-
-	ioport32_t clksel1_pll;
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_MASK   (0x1f << 27)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_CREATE(x)   (((x) & 0x1f) << 27)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_GET(x)   (((x) >> 27) & 0x1f)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_MASK   (0x7ff << 16)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_CREATE(x)   (((x) & 0x7ff) << 16)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_GET(x)   (((x) >> 16) & 0x7ff)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_MASK   (0x7f << 8)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_CREATE(x)   (((x) & 0x7f) << 8)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_GET(x)   (((x) >> 8) & 0x7f)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_96M_FLAG   (1 << 6)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_54M_FLAG   (1 << 5)
-#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_48M_FLAG   (1 << 3)
-
-	ioport32_t clksel2_pll;
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_SD_DIV_MASK   (0xff << 24)
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_SD_DIV_(x)   (((x) & 0xff) << 24)
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_MASK   (0x7 << 21)
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_500   (0x2 << 21)
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_1000   (0x4 << 21)
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_MULT_MASK   (0xfff << 8)
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_MULT(x)   (((x) & 0xfff) << 8)
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_DIV_MASK   (0x7f)
-#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_DIV(x)   ((x) & 0x7f)
-
-	ioport32_t clksel3_pll;
-#define CLOCK_CONTROL_CM_CLKSEL3_PLL_DIV_96M_MASK   (0xf)
-#define CLOCK_CONTROL_CM_CLKSEL3_PLL_DIV_96M(x)   ((x) & 0xf)
-
-	ioport32_t clksel4_pll;
-#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_MASK   (0x7ff << 8)
-#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_CREATE(x)   (((x) & 0x7ff) << 8)
-#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_GET(x)   (((x) >> 8) & 0x7ff)
-#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_MASK   (0x7f)
-#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_CREATE(x)   ((x) & 0x7f)
-#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_GET(x)   ((x) & 0x7f)
-
-	ioport32_t clksel5_pll;
-#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_MASK   (0x1f)
-#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_CREATE(x)   ((x) & 0x1f)
-#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_GET(x)   ((x) & 0x1f)
-} clock_control_cm_regs_t;
-
-#endif
-/**
- * @}
- */
-
Index: pace/drv/infrastructure/rootamdm37x/cm/core.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/core.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,188 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvcorecm
- * @{
- */
-/** @file
- * @brief CORE Clock Management IO register structure.
- */
-#ifndef AMDM37x_CORE_CM_H
-#define AMDM37x_CORE_CM_H
-#include <sys/types.h>
-#include <macros.h>
-
-/* AM/DM37x TRM p.447 */
-#define CORE_CM_BASE_ADDRESS  0x48004a00
-#define CORE_CM_SIZE  8192
-
-typedef struct {
-	ioport32_t fclken1;
-#define CORE_CM_FCLKEN1_EN_MCBSP1_FLAG  (1 << 9)
-#define CORE_CM_FCLKEN1_EN_MCBSP5_FLAG  (1 << 10)
-#define CORE_CM_FCLKEN1_EN_GPT10_FLAG  (1 << 11)
-#define CORE_CM_FCLKEN1_EN_GPT11_FLAG  (1 << 12)
-#define CORE_CM_FCLKEN1_EN_UART1_FLAG  (1 << 13)
-#define CORE_CM_FCLKEN1_EN_UART2_FLAG  (1 << 14)
-#define CORE_CM_FCLKEN1_EN_I2C1_FLAG  (1 << 15)
-#define CORE_CM_FCLKEN1_EN_I2C2_FLAG  (1 << 16)
-#define CORE_CM_FCLKEN1_EN_I2C3_FLAG  (1 << 17)
-#define CORE_CM_FCLKEN1_EN_MCSPI1_FLAG  (1 << 18)
-#define CORE_CM_FCLKEN1_EN_MCSPI2_FLAG  (1 << 19)
-#define CORE_CM_FCLKEN1_EN_MCSPI3_FLAG  (1 << 20)
-#define CORE_CM_FCLKEN1_EN_MCSPI4_FLAG  (1 << 21)
-#define CORE_CM_FCLKEN1_EN_HDQ_FLAG  (1 << 22)
-#define CORE_CM_FCLKEN1_EN_MMC1_FLAG  (1 << 24)
-#define CORE_CM_FCLKEN1_EN_MMC2_FLAG  (1 << 25)
-#define CORE_CM_FCLKEN1_EN_MMC3_FLAG  (1 << 30)
-
-	PADD32;
-	ioport32_t fclken3;
-#define CORE_CM_FCLKEN3_EN_TS_FLAG  (1 << 1)
-#define CORE_CM_FCLKEN3_EN_USBTLL_FLAG  (1 << 2)
-
-	PADD32;
-	ioport32_t iclken1;
-#define CORE_CM_ICLKEN1_EN_SDRC_FLAG  (1 << 1)
-#define CORE_CM_ICLKEN1_EN_HSOTGUSB_FLAG  (1 << 4)
-#define CORE_CM_ICLKEN1_EN_SCMCTRL_FLAG  (1 << 6)
-#define CORE_CM_ICLKEN1_EN_MAILBOXES_FLAG  (1 << 7)
-#define CORE_CM_ICLKEN1_EN_MCBSP1_FLAG  (1 << 9)
-#define CORE_CM_ICLKEN1_EN_MCBSP5_FLAG  (1 << 10)
-#define CORE_CM_ICLKEN1_EN_GPT10_FLAG  (1 << 11)
-#define CORE_CM_ICLKEN1_EN_GPT11_FLAG  (1 << 12)
-#define CORE_CM_ICLKEN1_EN_UART1_FLAG  (1 << 13)
-#define CORE_CM_ICLKEN1_EN_UART2_FLAG  (1 << 14)
-#define CORE_CM_ICLKEN1_EN_I2C1_FLAG  (1 << 15)
-#define CORE_CM_ICLKEN1_EN_I2C2_FLAG  (1 << 16)
-#define CORE_CM_ICLKEN1_EN_I2C3_FLAG  (1 << 17)
-#define CORE_CM_ICLKEN1_EN_MCSPI1_FLAG  (1 << 18)
-#define CORE_CM_ICLKEN1_EN_MCSPI2_FLAG  (1 << 19)
-#define CORE_CM_ICLKEN1_EN_MCSPI3_FLAG  (1 << 20)
-#define CORE_CM_ICLKEN1_EN_MCSPI4_FLAG  (1 << 21)
-#define CORE_CM_ICLKEN1_EN_HDQ_FLAG  (1 << 22)
-#define CORE_CM_ICLKEN1_EN_MMC1_FLAG  (1 << 24)
-#define CORE_CM_ICLKEN1_EN_MMC2_FLAG  (1 << 25)
-#define CORE_CM_ICLKEN1_EN_ICR_FLAG  (1 << 29)
-#define CORE_CM_ICLKEN1_EN_MMC3_FLAG  (1 << 30)
-
-	ioport32_t reserved1;
-	ioport32_t iclken3;
-#define CORE_CM_ICLKEN3_EN_USBTLL_FLAG  (1 << 2)
-
-	PADD32;
-	const ioport32_t idlest1;
-#define CORE_CM_IDLEST1_ST_SDRC_FLAG  (1 << 1)
-#define CORE_CM_IDLEST1_ST_SDMA_FLAG  (1 << 2)
-#define CORE_CM_IDLEST1_ST_HSOTGUSB_STBY_FLAG  (1 << 4)
-#define CORE_CM_IDLEST1_ST_HSOTGUSB_IDLE_FLAG  (1 << 5)
-#define CORE_CM_IDLEST1_ST_SCMCTRL_FLAG  (1 << 6)
-#define CORE_CM_IDLEST1_ST_MAILBOXES_FLAG  (1 << 7)
-#define CORE_CM_IDLEST1_ST_MCBSP1_FLAG  (1 << 9)
-#define CORE_CM_IDLEST1_ST_MCBSP5_FLAG  (1 << 10)
-#define CORE_CM_IDLEST1_ST_GPT10_FLAG  (1 << 11)
-#define CORE_CM_IDLEST1_ST_GPT11_FLAG  (1 << 12)
-#define CORE_CM_IDLEST1_ST_UART1_FLAG  (1 << 13)
-#define CORE_CM_IDLEST1_ST_UART2_FLAG  (1 << 14)
-#define CORE_CM_IDLEST1_ST_I2C1_FLAG  (1 << 15)
-#define CORE_CM_IDLEST1_ST_I2C2_FLAG  (1 << 16)
-#define CORE_CM_IDLEST1_ST_I2C3_FLAG  (1 << 17)
-#define CORE_CM_IDLEST1_ST_MCSPI1_FLAG  (1 << 18)
-#define CORE_CM_IDLEST1_ST_MCSPI2_FLAG  (1 << 19)
-#define CORE_CM_IDLEST1_ST_MCSPI3_FLAG  (1 << 20)
-#define CORE_CM_IDLEST1_ST_MCSPI4_FLAG  (1 << 21)
-#define CORE_CM_IDLEST1_ST_HDQ_FLAG  (1 << 22)
-#define CORE_CM_IDLEST1_ST_MMC1_FLAG  (1 << 24)
-#define CORE_CM_IDLEST1_ST_MMC2_FLAG  (1 << 25)
-#define CORE_CM_IDLEST1_ST_ICR_FLAG  (1 << 29)
-#define CORE_CM_IDLEST1_ST_MMC3_FLAG  (1 << 30)
-
-	const ioport32_t reserved2;
-	const ioport32_t idlest3;
-#define CORE_CM_IDLEST3_ST_USBTLL_FLAG  (1 << 2)
-
-	PADD32;
-	ioport32_t autoidle1;
-#define CORE_CM_AUTOIDLE1_AUTO_HSOTGUSB_FLAG  (1 << 4)
-#define CORE_CM_AUTOIDLE1_AUTO_SCMCTRL_FLAG  (1 << 6)
-#define CORE_CM_AUTOIDLE1_AUTO_MAILBOXES_FLAG  (1 << 7)
-#define CORE_CM_AUTOIDLE1_AUTO_MCBSP1_FLAG  (1 << 9)
-#define CORE_CM_AUTOIDLE1_AUTO_MCBSP5_FLAG  (1 << 10)
-#define CORE_CM_AUTOIDLE1_AUTO_GPT10_FLAG  (1 << 11)
-#define CORE_CM_AUTOIDLE1_AUTO_GPT11_FLAG  (1 << 12)
-#define CORE_CM_AUTOIDLE1_AUTO_UART1_FLAG  (1 << 13)
-#define CORE_CM_AUTOIDLE1_AUTO_UART2_FLAG  (1 << 14)
-#define CORE_CM_AUTOIDLE1_AUTO_I2C1_FLAG  (1 << 15)
-#define CORE_CM_AUTOIDLE1_AUTO_I2C2_FLAG  (1 << 16)
-#define CORE_CM_AUTOIDLE1_AUTO_I2C3_FLAG  (1 << 17)
-#define CORE_CM_AUTOIDLE1_AUTO_MCSPI1_FLAG  (1 << 18)
-#define CORE_CM_AUTOIDLE1_AUTO_MCSPI2_FLAG  (1 << 19)
-#define CORE_CM_AUTOIDLE1_AUTO_MCSPI3_FLAG  (1 << 20)
-#define CORE_CM_AUTOIDLE1_AUTO_MCSPI4_FLAG  (1 << 21)
-#define CORE_CM_AUTOIDLE1_AUTO_HDQ_FLAG  (1 << 22)
-#define CORE_CM_AUTOIDLE1_AUTO_MMC1_FLAG  (1 << 24)
-#define CORE_CM_AUTOIDLE1_AUTO_MMC2_FLAG  (1 << 25)
-#define CORE_CM_AUTOIDLE1_AUTO_ICR_FLAG  (1 << 29)
-#define CORE_CM_AUTOIDLE1_AUTO_MMC3_FLAG  (1 << 30)
-
-	ioport32_t reserved3;
-	ioport32_t autoidle3;
-#define CORE_CM_AUTOIDLE3_AUTO_USBTLL_FLAG  (1 << 2)
-
-	PADD32;
-	ioport32_t clksel;
-#define CORE_CM_CLKSEL_CLKSEL_L3_MASK  (0x3 << 0)
-#define CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED1  (0x1 << 0)
-#define CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED2  (0x2 << 0)
-#define CORE_CM_CLKSEL_CLKSEL_L4_MASK  (0x3 << 2)
-#define CORE_CM_CLKSEL_CLKSEL_L4_DIVIDED1  (0x1 << 2)
-#define CORE_CM_CLKSEL_CLKSEL_L4_DIVIDED2  (0x2 << 2)
-#define CORE_CM_CLKSEL_CLKSEL_96M_MASK  (0x3 << 12)
-#define CORE_CM_CLKSEL_CLKSEL_96M_DIVIDED1  (0x1 << 12)
-#define CORE_CM_CLKSEL_CLKSEL_96M_DIVIDED2  (0x2 << 12)
-#define CORE_CM_CLKSEL_CLKSEL_GPT10_FLAG (1 << 6)
-#define CORE_CM_CLKSEL_CLKSEL_GPT11_FLAG (1 << 7)
-
-	PADD32;
-	ioport32_t clkstctrl;
-#define CORE_CM_CLKCTRL_CLKCTRL_L3_MASK  (0x3 << 0)
-#define CORE_CM_CLKCTRL_CLKCTRL_L3_AUTO_EN  (0x0 << 0)
-#define CORE_CM_CLKCTRL_CLKCTRL_L3_AUTO_DIS  (0x3 << 0)
-#define CORE_CM_CLKCTRL_CLKCTRL_L4_MASK  (0x3 << 2)
-#define CORE_CM_CLKCTRL_CLKCTRL_L4_AUTO_EN  (0x0 << 2)
-#define CORE_CM_CLKCTRL_CLKCTRL_L4_AUTO_DIS  (0x3 << 2)
-
-	const ioport32_t clkstst;
-#define CORE_CM_CLKSTST_CLKACTIVITY_L3_FLAG  (1 << 0)
-#define CORE_CM_CLKSTST_CLKACTIVITY_L4_FLAG  (1 << 1)
-} core_cm_regs_t;
-
-#endif
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootamdm37x/cm/iva2.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/iva2.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,101 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvcm
- * @{
- */
-/** @file
- * @brief MPU Clock Management IO register structure.
- */
-#ifndef AMDM37x_IVA2_CM_H
-#define AMDM37x_IVA2_CM_H
-#include <sys/types.h>
-#include <macros.h>
-
-/* AM/DM37x TRM p.446 */
-#define IVA2_CM_BASE_ADDRESS  0x48004000
-#define IVA2_CM_SIZE  8192
-
-typedef struct {
-	ioport32_t fclken;
-#define IVA2_CM_FCLKEN_EN_IVA2_FLAG   (1 << 0)
-
-	ioport32_t clken_pll;
-#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_LP_MODE_FLAG   (1 << 10)
-#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_DRIFTGUARD   (1 << 3)
-#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_MASK   (0x7)
-#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LP_STOP   (0x1)
-#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LP_BYPASS   (0x5)
-#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LOCKED   (0x7)
-
-	PADD32[6];
-	const ioport32_t idlest;
-#define IVA2_CM_IDLEST_ST_IVA2_STANDBY_FLAG   (1 << 0)
-
-	const ioport32_t idlest_pll;
-#define IVA2_CM_IDLEST_PLL_ST_IVA2_CLK_LOCKED_FLAG   (1 << 0)
-
-	PADD32[3];
-	ioport32_t autoidle_pll;
-#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_MASK   (0x7)
-#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_DISABLED   (0x0)
-#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_ENABLED   (0x1)
-
-	PADD32[2];
-	ioport32_t clksel1_pll;
-#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_MASK   (0x7 << 19)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_SHIFT   (19)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_VAL(x)   ((x >> 19) & 0x7)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_1   (0x1 << 19)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_2   (0x2 << 19)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_4   (0x4 << 19)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_MULT_MASK   (0x7ff << 8)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_MULT_SHIFT   (8)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_DIV_MASK  (0x7f << 0)
-#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_DIV_SHIFT  (0)
-
-	ioport32_t clksel2_pll;
-#define IVA2_CM_CLKSEL2_PLL_IVA2_DPLL_CLKOUT_DIV_MASK   (0x1f)
-
-	ioport32_t clkstctrl;
-#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_MASK   (0x3)
-#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_DISABLED   (0x0)
-#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_START_SLEEP   (0x2)
-#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_START_WAKEUP   (0x2)
-#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_AUTOMATIC   (0x3)
-
-	const ioport32_t clkstst;
-#define IVA2_CM_CLKSTST_CLKACTIVITY_IVA2_ACTIVE_FLAG   (1 << 0)
-
-} iva2_cm_regs_t;
-
-#endif
-/**
- * @}
- */
-
Index: pace/drv/infrastructure/rootamdm37x/cm/mpu.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/mpu.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvcm
- * @{
- */
-/** @file
- * @brief MPU Clock Management IO register structure.
- */
-#ifndef AMDM37x_MPU_CM_H
-#define AMDM37x_MPU_CM_H
-#include <sys/types.h>
-#include <macros.h>
-
-/* AM/DM37x TRM p.455 */
-#define MPU_CM_BASE_ADDRESS  0x48004900
-#define MPU_CM_SIZE  8192
-
-typedef struct {
-	PADD32;
-	ioport32_t clken_pll;
-#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG   (1 << 10)
-#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_DRIFTGUARD   (1 << 3)
-#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_MASK   (0x7)
-#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_LP_BYPASS   (0x5)
-#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_LOCKED   (0x7)
-
-	PADD32[6];
-	const ioport32_t idlest;
-#define MPU_CM_IDLEST_ST_MPU_STANDBY_FLAG   (1 << 0)
-
-	const ioport32_t idlest_pll;
-#define MPU_CM_IDLEST_PLL_ST_MPU_CLK_LOCKED_FLAG   (1 << 0)
-
-	PADD32[3];
-	ioport32_t autoidle_pll;
-#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK   (0x7)
-#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_DISABLED   (0x0)
-#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED   (0x1)
-
-	PADD32[2];
-	ioport32_t clksel1_pll;
-#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_MASK   (0x7 << 19)
-#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_SHIFT   (19)
-#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_VAL(x)   ((x >> 19) & 0x7)
-#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_1   (0x1 << 19)
-#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_2   (0x2 << 19)
-#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_4   (0x4 << 19)
-#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_MASK   (0x7ff << 8)
-#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_SHIFT   (8)
-#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_MASK  (0x7f << 0)
-#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_SHIFT  (0)
-
-	ioport32_t clksel2_pll;
-#define MPU_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV_MASK   (0x1f)
-
-	ioport32_t clkstctrl;
-#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_MASK   (0x3)
-#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_DISABLED   (0x0)
-#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_START_WAKEUP   (0x2)
-#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_AUTOMATIC   (0x3)
-
-	const ioport32_t clkstst;
-#define MPU_CM_CLKSTST_CLKACTIVITY_MPU_ACTIVE_FLAG   (1 << 0)
-
-} mpu_cm_regs_t;
-
-#endif
-/**
- * @}
- */
-
Index: pace/drv/infrastructure/rootamdm37x/cm/usbhost.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/cm/usbhost.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,82 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvusbhostcm
- * @{
- */
-/** @file
- * @brief USBHOST Clock Management IO register structure.
- */
-#ifndef AMDM37x_USBHOST_CM_H
-#define AMDM37x_USBHOST_CM_H
-#include <macros.h>
-#include <sys/types.h>
-
-/* AM/DM37x TRM p.447 */
-#define USBHOST_CM_BASE_ADDRESS  0x48005400
-#define USBHOST_CM_SIZE  8192
-
-typedef struct {
-	ioport32_t fclken;
-#define USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG  (1 << 0)
-#define USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG  (1 << 1)
-
-	PADD32[3];
-	ioport32_t iclken;
-#define USBHOST_CM_ICLKEN_EN_USBHOST  (1 << 0)
-
-	PADD32[3];
-	const ioport32_t idlest;
-#define USBHOST_CM_IDLEST_ST_USBHOST_STDBY_FLAG  (1 << 0)
-#define USBHOST_CM_IDLEST_ST_USBHOST_IDLE_FLAG  (1 << 1)
-
-	PADD32[3];
-	ioport32_t autoidle;
-#define USBHOST_CM_AUTOIDLE_AUTO_USBHOST_FLAG  (1 << 0)
-
-	PADD32[4];
-	ioport32_t sleepdep;
-#define USBHOST_CM_SLEEPDEP_EN_MPU_FLAG  (1 << 1)
-#define USBHOST_CM_SLEEPDEP_EN_IVA2_FLAG  (1 << 2)
-
-	ioport32_t clkstctrl;
-#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_MASK  (0x3 << 0)
-#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_AUTO_DIS  (0x0 << 0)
-#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_SUPERVISED_SLEEP  (0x1 << 0)
-#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_SUPERVISED_WAKEUP  (0x2 << 0)
-#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_AUTO_EN  (0x3 << 0)
-
-	ioport32_t clkstst;
-#define USBHOST_CM_CLKSTCTRL_CLKSTST_CLKACTIVITY_USBHOST  (1 << 0)
-} usbhost_cm_regs_t;
-
-#endif
-/**
- * @}
- */
-
Index: pace/drv/infrastructure/rootamdm37x/prm/clock_control.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/prm/clock_control.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvprm
- * @{
- */
-/** @file
- * @brief Clock Control Clock Management IO register structure.
- */
-#ifndef AMDM37X_PRM_CLOCK_CONTROL_H
-#define AMDM37X_PRM_CLOCK_CONTROL_H
-#include <sys/types.h>
-#include <macros.h>
-
-/* AM/DM37x TRM p.536 and p.589 */
-#define CLOCK_CONTROL_PRM_BASE_ADDRESS  0x48306d00
-#define CLOCK_CONTROL_PRM_SIZE  8192
-
-/** Clock control PRM register map
- */
-typedef struct {
-	PADD32[16];
-	ioport32_t clksel;
-#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_MASK   (0x7)
-#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_12M   (0x0)
-#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_13M   (0x1)
-#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_19_2M   (0x2)
-#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_26M   (0x3)
-#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_38_4M   (0x4)
-#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_16_8M   (0x5)
-
-	PADD32[12];
-	ioport32_t clkout_ctrl;
-#define CLOCK_CONTROL_PRM_CLKOUT_CTRL_CLKOUOUT_EN_FLAG   (1 << 7)
-
-} clock_control_prm_regs_t;
-
-static inline unsigned sys_clk_freq_kHz(unsigned reg_val)
-{
-	switch(reg_val)
-	{
-	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_12M: return 12000;
-	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_13M: return 13000;
-	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_19_2M: return 19200;
-	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_26M: return 26000;
-	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_38_4M: return 38400;
-	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_16_8M: return 16800;
-	}
-	return 0;
-}
-
-
-#endif
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootamdm37x/prm/global_reg.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/prm/global_reg.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,300 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvprm
- * @{
- */
-/** @file
- * @brief Clock Control Clock Management IO register structure.
- */
-#ifndef AMDM37X_PRM_GLOBAL_REG_H
-#define AMDM37X_PRM_GLOBAL_REG_H
-#include <sys/types.h>
-#include <macros.h>
-
-/* AM/DM37x TRM p.536 and p.615 */
-#define GLOBAL_REG_PRM_BASE_ADDRESS  0x48307200
-#define GLOBAL_REG_PRM_SIZE  65536
-
-/** Global Reg PRM register map
- */
-typedef struct {
-	PADD32[8];
-	struct {
-		ioport32_t smps_sa;
-#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_MASK   (0x7f << 0)
-#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_CREATE(x)   (((x) & 0x7f) << 0)
-#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_GET(r)   (r & 0x7f)
-#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_MASK   (0x7f << 16)
-#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_CREATE(x)   (((x) & 0x7f) << 16)
-#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_GET(r)   (((r) >> 16 ) & 0x7f)
-
-		ioport32_t smps_vol_ra;
-#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_MASK   (0xff << 0)
-#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_CREATE(x)   (((x) & 0xff) << 0)
-#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_GET(r)   (r & 0xff)
-#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_MASK   (0xff << 16)
-#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_CREATE(x)   (((x) & 0xff) << 16)
-#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_GET(r)   (((r) >> 16 ) & 0xff)
-
-		ioport32_t smps_cmd_ra;
-#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_MASK   (0xff << 0)
-#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_CREATE(x)   (((x) & 0xff) << 0)
-#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_GET(r)   (r & 0xff)
-#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_MASK   (0xff << 16)
-#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_CREATE(x)   (((x) & 0xff) << 16)
-#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_GET(r)   (((r) >> 16 ) & 0xff)
-
-		ioport32_t cmd_val_0;
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_GET(r)   (((x) >> 24) & 0xff)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_GET(r)   (((x) >> 24) & 0xff)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_GET(r)   (((x) >> 24) & 0xff)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_GET(r)   (((x) >> 24) & 0xff)
-
-		ioport32_t cmd_val_1;
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_GET(r)   (((x) >> 24) & 0xff)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_GET(r)   (((x) >> 24) & 0xff)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_GET(r)   (((x) >> 24) & 0xff)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_GET(r)   (((x) >> 24) & 0xff)
-
-		ioport32_t ch_conf;
-#define GLOBAL_REG_PRM_VC_CH_CONF_CMD1_FLAG   (1 << 20)
-#define GLOBAL_REG_PRM_VC_CH_CONF_RACEN1_FLAG   (1 << 19)
-#define GLOBAL_REG_PRM_VC_CH_CONF_RAC1_FLAG   (1 << 18)
-#define GLOBAL_REG_PRM_VC_CH_CONF_RAV1_FLAG   (1 << 17)
-#define GLOBAL_REG_PRM_VC_CH_CONF_SA1_FLAG   (1 << 16)
-#define GLOBAL_REG_PRM_VC_CH_CONF_CMD0_FLAG   (1 << 4)
-#define GLOBAL_REG_PRM_VC_CH_CONF_RACEN0_FLAG   (1 << 3)
-#define GLOBAL_REG_PRM_VC_CH_CONF_RAC0_FLAG   (1 << 2)
-#define GLOBAL_REG_PRM_VC_CH_CONF_RAV0_FLAG   (1 << 1)
-#define GLOBAL_REG_PRM_VC_CH_CONF_SA0_FLAG   (1 << 0)
-
-		ioport32_t i2c_cfg;
-#define GLOBAL_REG_PRM_VC_I2C_CFG_HSMASTER_FLAG   (1 << 5)
-#define GLOBAL_REG_PRM_VC_I2C_CFG_SREN_FLAG   (1 << 4)
-#define GLOBAL_REG_PRM_VC_I2C_CFG_HSEN_FLAG   (1 << 3)
-#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_MASK   (0x3 << 0)
-#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_CREATE(x)   ((x) & 0x3)
-#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_GET(r)   ((r) & 0x3)
-
-		ioport32_t bypass_val;
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_VALID_FLAG   (1 << 24)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_MASK   (0xff << 16)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_CREATE(x)   (((x) & 0xff) << 16)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_GET(r)   (((r) >> 16) & 0xff)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_MASK   (0xff << 8)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_CREATE(x)   (((x) & 0xff) << 8)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_GET(r)   (((r) >> 8) & 0xff)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_MASK   (0x7f << 0)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_CREATE(x)   (((x) & 0x7f) << 0)
-#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_GET(r)   (((r) >> 0) & 0x7f)
-	} vc;
-
-	PADD32[4];
-	ioport32_t rstctrl;
-#define GLOBAL_REG_PRM_RSTCTRL_RST_DPLL3_FLAG   (1 << 2)
-#define GLOBAL_REG_PRM_RSTCTRL_RST_GS_FLAG   (1 << 1)
-
-	ioport32_t rsttime;
-#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_MASK   (0x1f << 8)
-#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_CREATE(x)   (((x) & 0x1f) << 8)
-#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_GET(r)   (((r) >> 8) & 0x1f)
-#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_MASK   (0xff << 0)
-#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_CREATE(x)   (((x) & 0xff) << 0)
-#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_GET(r)   (((r) >> 0) & 0xff)
-
-	ioport32_t rstst;
-#define GLOBAL_REG_PRM_RSTST_ICECRUSHER_RST_FLAG   (1 << 10)
-#define GLOBAL_REG_PRM_RSTST_ICEPICK_RST_FLAG   (1 << 9)
-#define GLOBAL_REG_PRM_RSTST_VDD2_VOLTAGE_MGR_RST_FLAG   (1 << 8)
-#define GLOBAL_REG_PRM_RSTST_VDD1_VOLTAGE_MGR_RST_FLAG   (1 << 7)
-#define GLOBAL_REG_PRM_RSTST_EXTERNAL_WARM_REST_FLAG   (1 << 6)
-#define GLOBAL_REG_PRM_RSTST_MPU_WD_RST_FLAG   (1 << 4)
-#define GLOBAL_REG_PRM_RSTST_GLOBAL_SW_RST_FLAG   (1 << 1)
-#define GLOBAL_REG_PRM_RSTST_GLOABL_COLD_RST_FLAG   (1 << 0)
-
-	PADD32;
-	ioport32_t volctrl;
-#define GLOBAL_REG_PRM_VOLCTRL_SEL_VMODE_FLAG   (1 << 4)
-#define GLOBAL_REG_PRM_VOLCTRL_SEL_OFF_FLAG   (1 << 3)
-#define GLOBAL_REG_PRM_VOLCTRL_AUTO_OFF_FLAG   (1 << 2)
-#define GLOBAL_REG_PRM_VOLCTRL_AUTO_RET_FLAG   (1 << 1)
-#define GLOBAL_REG_PRM_VOLCTRL_AUTO_SLEEP_FLAG   (1 << 0)
-
-	ioport32_t sram_pcharge;
-#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_MASK   (0xff)
-#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_CREATE(x)   ((x) & 0xff)
-#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_GET(r)   ((r) & 0xff)
-
-	PADD32[2];
-	ioport32_t clksrc_ctrl;
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_DPLL4_CLKINP_DIV_65_FLAG   (1 << 8)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_MASK   (0x3 << 6)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_1   (0x1 << 6)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_2   (0x2 << 6)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_GET(r)   (((r) >> 6) & 0x3)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_MASK   (0x3 << 3)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_ON   (0x0 << 3)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_SLEEP   (0x1 << 3)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_RET   (0x2 << 3)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_OFF   (0x3 << 3)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_GET(r)   (((r) >> 3) & 0x3)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_MASK   (0x3 << 0)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_BYPASS   (0x0 << 0)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_OSCILLATOR   (0x1 << 0)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_UNKNOWN   (0x3 << 0)
-#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_GET(r)   (((r) >> 0) & 0x3)
-
-	PADD32[3];
-	const ioport32_t obs;
-#define GLOBAL_REG_PRM_OBS_OBS_BUS_MASK   (0x3ff)
-
-	PADD32[3];
-	ioport32_t voltsetup1;
-#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_MASK   (0xff << 16)
-#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_CREATE(x)   (((x) & 0xff) << 16)
-#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_GET(r)   (((r) >> 16) & 0xff)
-#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_MASK   (0xff << 0)
-#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_CREATE(x)   (((x) & 0xff) << 0)
-#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_GET(r)   (((r) >> 0) & 0xff)
-
-	ioport32_t voltoffset;
-#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_MASK   (0xffff << 0)
-#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_CREATE(x)   (((x) & 0xffff) << 0)
-#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_GET(r)   (((r) >> 0) & 0xffff)
-
-	ioport32_t clksetup;
-#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_MASK   (0xffff << 0)
-#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_CREATE(x)   (((x) & 0xffff) << 0)
-#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_GET(r)   (((r) >> 0) & 0xffff)
-
-	ioport32_t polctrl;
-#define GLOBAL_REG_PRM_POLCTRL_OFFMODE_POL_FLAG   (1 << 3)
-#define GLOBAL_REG_PRM_POLCTRL_CLKOUT_POL_FLAG   (1 << 2)
-#define GLOBAL_REG_PRM_POLCTRL_CLKREG_POL_FLAG   (1 << 1)
-#define GLOBAL_REG_PRM_POLCTRL_EXTVOL_POL_FLAG   (1 << 0)
-
-	ioport32_t voltsetup2;
-#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_MASK   (0xffff << 0)
-#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_CREATE(x)   (((x) & 0xffff) << 0)
-#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_GET(r)   (((r) >> 0) & 0xffff)
-
-	PADD32[3];
-	struct {
-		ioport32_t config;
-#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_CREATE(x)   (((x) & 0xff) << 24)
-#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_GET(r)   (((r) >> 0xff << 24)
-#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_MASK   (0xff << 16)
-#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_CREATE(x)   (((x) & 0xff) << 16)
-#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_GET(r)   (((r) >> 0xff << 16)
-#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_MASK   (0xff << 8)
-#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_CREATE(x)   (((x) & 0xff) << 8)
-#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_GET(r)   (((r) >> 0xff << 8)
-#define GLOBAL_REG_PRM_VP_CONFIG_TIMEOUTEN_FLAG    (1 << 3)
-#define GLOBAL_REG_PRM_VP_CONFIG_INITVDD_FLAG   (1 << 2)
-#define GLOBAL_REG_PRM_VP_CONFIG_FORCEUPDATE_FLAG   (1 << 1)
-#define GLOBAL_REG_PRM_VP_CONFIG_VPENABLE_FLAG   (1 << 0)
-
-		ioport32_t vstepmin;
-#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_MASK   (0xffff << 8)
-#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_CREATE(x)   (((x)0xffff << 8)
-#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_GET(r)   (((r) >> 8) & 0xffff)
-#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_MASK   (0xff << 0)
-#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_CREATE(x)   (((x)0xff << 0)
-#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_GET(r)   (((r) >> 0) & 0xff)
-
-		ioport32_t vstepmax;
-#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_MASK   (0xffff << 8)
-#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_CREATE(x)   (((x)0xffff << 8)
-#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_GET(r)   (((r) >> 8) & 0xffff)
-#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_MASK   (0xff << 0)
-#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_CREATE(x)   (((x)0xff << 0)
-#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_GET(r)   (((r) >> 0) & 0xff)
-
-		ioport32_t vlimitto;
-#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_MASK   (0xff << 24)
-#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_CREATE(x)   (((x)0xff << 24)
-#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_GET(r)   (((r) >> 24) & 0xff)
-#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_MASK   (0xff << 16)
-#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_CREATE(x)   (((x)0xff << 16)
-#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_GET(r)   (((r) >> 16) & 0xff)
-#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_MASK   (0xffff << 0)
-#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_CREATE(x)   (((x)0xffff << 0)
-#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_GET(r)   (((r) >> 0) & 0xffff)
-
-		const ioport32_t voltage;
-#define GLOBAL_REG_PRM_VP_VOLTAGE_VPVOLTAGE_MASK   (0xff)
-#define GLOBAL_REG_PRM_VP_VOLTAGE_VPVOLTAGE_GET(r)   ((r) & 0xff)
-
-		const ioport32_t status;
-#define GLOBAL_REG_PRM_VP_STATUS_VPINIDLE_FLAG   (1 << 0)
-
-		PADD32[2];
-	} vp[2];
-
-	ioport32_t ldo_abb_setup;
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_IN_TRANSITION   (1 << 6)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_MASK   (0x3 << 3)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_BYPASS   (0x0 << 3)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_FBB   (0x2 << 3)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_OPP_CHANGE_FLAG  (1 << 2)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_MASK   (0x3 << 0)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_DEFAULT   (0x0 << 0)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_FAST   (0x1 << 0)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_NOMINAL   (0x2 << 0)
-#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_SLOW   (0x3 << 0)
-
-	ioport32_t ldo_abb_ctrl;
-#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_MASK   (0xff << 8)
-#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_CREATE(x)   (((x) & 0xff) << 8)
-#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_GET(r)   (((r) >> 8) & 0xff)
-#define GLOBAL_REG_PRM_LDO_ABB_CTRL_ACTIVE_FBB_SEL_FLAG   (1 << 2)
-#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2EN   (1 << 0)
-} global_reg_prm_regs_t;
-
-#endif
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootamdm37x/prm/usbhost.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/prm/usbhost.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,111 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvprm
- * @{
- */
-/** @file
- * @brief Clock Control Clock Management IO register structure.
- */
-#ifndef AMDM37X_PRM_CLOCK_CONTROL_H
-#define AMDM37X_PRM_CLOCK_CONTROL_H
-#include <sys/types.h>
-#include <macros.h>
-
-/* AM/DM37x TRM p.536 and p.589 */
-#define CLOCK_CONTROL_CM_BASE_ADDRESS  0x48307400
-#define CLOCK_CONTROL_CM_SIZE  8192
-
-/** Clock control PRM register map
- *
- * Periph DPLL == DPLL4
- * Core DPLL == DPLL3
- */
-typedef struct {
-	PADD32[22];
-	ioport32_t rm_rstst;
-#define USBHOST_PRM_RM_RSTST_COREDOMAINWKUP_RST_FLAG   (1 << 3)
-#define USBHOST_PRM_RM_RSTST_DOMAINWKUP_RST_FLAG   (1 << 2)
-#define USBHOST_PRM_RM_RSTST_GLOBALWARM_RST_FLAG   (1 << 1)
-#define USBHOST_PRM_RM_RSTST_GLOBALCOLD_RST_FLAG   (1 << 0)
-
-	PADD32[18];
-	ioport32_t pm_wken;
-#define USBHOST_PRM_PM_WKEN_EN_USBHOST_FLAG   (1 << 0)
-
-	ioport32_t pm_mpugrpsel;
-#define USBHOST_PRM_PM_MPUGRPSEL_GRPSEL_USBHOST_FLAG   (1 << 0)
-
-	ioport32_t pm_iva2grpsel;
-#define USBHOST_PRM_PM_IVA2GRPSEL_GRPSEL_USBHOST_FLAG   (1 << 0)
-
-	PADD32;
-	ioport32_t pm_wkst;
-#define USBHOST_PRM_PM_WKST_ST_USBHOST_FLAG   (1 << 0)
-
-	PADD32[5];
-	ioport32_t pm_wkdep;
-#define USBHOST_PRM_PM_WKDEP_EN_WKUP_FLAG   (1 << 4)
-#define USBHOST_PRM_PM_WKDEP_EN_IVA2_FLAG   (1 << 2)
-#define USBHOST_PRM_PM_WKDEP_EN_MPU_FLAG   (1 << 1)
-#define USBHOST_PRM_PM_WKDEP_EN_CORE_FLAG   (1 << 0)
-
-	PADD32[5];
-	ioport32_t pm_pwstctrl;
-#define USBHOST_PRM_PM_PWSTCTRL_MEMONSTATE_MASK   (0x3 << 16)
-#define USBHOST_PRM_PM_PWSTCTRL_MEMONSTATE_ALWAYS_ON   (0x3 << 16)
-#define USBHOST_PRM_PM_PWSTCTRL_MEMRETSTATE_FLAG   (1 << 8)
-#define USBHOST_PRM_PM_PWSTCTRL_SAVEANDRESTORE_FLAG   (1 << 4)
-#define USBHOST_PRM_PM_PWSTCTRL_LOGICRESTATE_FLAG   (1 << 2)
-#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_MASK   (0x3 << 0)
-#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_OFF   (0x0 << 0)
-#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_RETENTION   (0x1 << 0)
-#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_ON   (0x3 << 0)
-
-	const ioport32_t pm_pwstst;
-#define USBHOST_PRM_PM_PWSTST_INTRANSITION_FLAG   (1 << 20)
-#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_MASK   (0x3 << 0)
-#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_OFF   (0x0 << 0)
-#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_RETENTION  (0x1 << 0)
-#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_INACTIVE  (0x2 << 0)
-#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_ON  (0x3 << 0)
-
-	ioport32_t pm_prepwstst;
-#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_MASK   (0x3 << 0)
-#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_OFF   (0x0 << 0)
-#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_RETENTION  (0x1 << 0)
-#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_INACTIVE  (0x2 << 0)
-#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_ON  (0x3 << 0)
-
-} usbhost_prm_regs_t;
-
-#endif
-/**
- * @}
- */
-
Index: pace/drv/infrastructure/rootamdm37x/rootamdm37x.c
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,282 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @defgroup root_amdm37x TI AM/DM37x platform driver.
- * @brief HelenOS TI AM/DM37x platform driver.
- * @{
- */
-
-/** @file
- */
-
-#define DEBUG_CM 0
-
-#include <ddf/log.h>
-#include <errno.h>
-#include <ops/hw_res.h>
-#include <stdio.h>
-
-#include "amdm37x.h"
-
-#define NAME  "rootamdm37x"
-
-typedef struct {
-	const char *name;
-	match_id_t match_id;
-	hw_resource_list_t hw_resources;
-} rootamdm37x_fun_t;
-
-/* See amdm37x TRM page 3316 for these values */
-#define OHCI_BASE_ADDRESS   0x48064400
-#define OHCI_SIZE   1024
-#define EHCI_BASE_ADDRESS   0x48064800
-#define EHCI_SIZE   1024
-
-/* See amdm37x TRM page 1813 for these values */
-#define DSS_BASE_ADDRESS   0x48050000
-#define DSS_SIZE   512
-#define DISPC_BASE_ADDRESS   0x48050400
-#define DISPC_SIZE   1024
-#define VIDEO_ENC_BASE_ADDRESS   0x48050C00
-#define VIDEO_ENC_SIZE   256
-
-
-static hw_resource_t ohci_res[] = {
-	{
-		.type = MEM_RANGE,
-		.res.io_range = {
-			.address = OHCI_BASE_ADDRESS,
-			.size = OHCI_SIZE,
-			.endianness = LITTLE_ENDIAN
-		},
-	},
-	{
-		.type = INTERRUPT,
-		.res.interrupt = { .irq = 76 },
-	},
-};
-
-static hw_resource_t ehci_res[] = {
-	{
-		.type = MEM_RANGE,
-		/* See amdm37x TRM page. 3316 for these values */
-		.res.io_range = {
-			.address = EHCI_BASE_ADDRESS,
-			.size = EHCI_SIZE,
-			.endianness = LITTLE_ENDIAN
-		},
-	},
-	{
-		.type = INTERRUPT,
-		.res.interrupt = { .irq = 77 },
-	},
-};
-
-static hw_resource_t disp_res[] = {
-	{
-		.type = MEM_RANGE,
-		.res.io_range = {
-			.address = DSS_BASE_ADDRESS,
-			.size = DSS_SIZE,
-			.endianness = LITTLE_ENDIAN
-		},
-	},
-	{
-		.type = MEM_RANGE,
-		.res.io_range = {
-			.address = DISPC_BASE_ADDRESS,
-			.size = DISPC_SIZE,
-			.endianness = LITTLE_ENDIAN
-		},
-	},
-	{
-		.type = MEM_RANGE,
-		.res.io_range = {
-			.address = VIDEO_ENC_BASE_ADDRESS,
-			.size = VIDEO_ENC_SIZE,
-			.endianness = LITTLE_ENDIAN
-		},
-	},
-	{
-		.type = INTERRUPT,
-		.res.interrupt = { .irq = 25 },
-	},
-};
-
-static const rootamdm37x_fun_t amdm37x_funcs[] = {
-{
-	.name = "ohci",
-	.match_id = { .id = "usb/host=ohci", .score = 90 },
-	.hw_resources = { .resources = ohci_res, .count = ARRAY_SIZE(ohci_res) }
-},
-{
-	.name = "ehci",
-	.match_id = { .id = "usb/host=ehci", .score = 90 },
-	.hw_resources = { .resources = ehci_res, .count = ARRAY_SIZE(ehci_res) }
-},
-{
-	.name = "fb",
-	.match_id = { .id = "amdm37x&dispc", .score = 90 },
-	.hw_resources = { .resources = disp_res, .count = ARRAY_SIZE(disp_res) }
-},
-};
-
-
-static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode);
-static bool rootamdm37x_enable_interrupt(ddf_fun_t *fun);
-
-static hw_res_ops_t fun_hw_res_ops = {
-	.get_resource_list = &rootamdm37x_get_resources,
-	.enable_interrupt = &rootamdm37x_enable_interrupt,
-};
-
-static ddf_dev_ops_t rootamdm37x_fun_ops = {
-	.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops
-};
-
-static int rootamdm37x_add_fun(ddf_dev_t *dev, const rootamdm37x_fun_t *fun)
-{
-	assert(dev);
-	assert(fun);
-
-	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", fun->name);
-
-	/* Create new device function. */
-	ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, fun->name);
-	if (fnode == NULL)
-		return ENOMEM;
-	
-	/* Add match id */
-	int ret = ddf_fun_add_match_id(fnode,
-	    fun->match_id.id, fun->match_id.score);
-	if (ret != EOK) {
-		ddf_fun_destroy(fnode);
-		return ret;
-	}
-	
-	/* Alloc needed data */
-	rootamdm37x_fun_t *rf =
-	    ddf_fun_data_alloc(fnode, sizeof(rootamdm37x_fun_t));
-	if (!rf) {
-		ddf_fun_destroy(fnode);
-		return ENOMEM;
-	}
-	*rf = *fun;
-
-	/* Set provided operations to the device. */
-	ddf_fun_set_ops(fnode, &rootamdm37x_fun_ops);
-	
-	/* Register function. */
-	ret = ddf_fun_bind(fnode);
-	if (ret != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function %s.", fun->name);
-		ddf_fun_destroy(fnode);
-		return ret;
-	}
-	
-	return EOK;
-}
-
-/** Add the root device.
- *
- * @param dev Device which is root of the whole device tree
- *            (both of HW and pseudo devices).
- *
- * @return Zero on success, negative error number otherwise.
- *
- */
-static int rootamdm37x_dev_add(ddf_dev_t *dev)
-{
-	assert(dev);
-	amdm37x_t *device = ddf_dev_data_alloc(dev, sizeof(amdm37x_t));
-	if (!device)
-		return ENOMEM;
-	int ret = amdm37x_init(device, DEBUG_CM);
-	if (ret != EOK) {
-		ddf_msg(LVL_FATAL, "Failed to setup hw access!.\n");
-		return ret;
-	}
-
-	/* Set dplls to ON and automatic */
-	amdm37x_setup_dpll_on_autoidle(device);
-
-	/* Enable function and interface clocks */
-	amdm37x_usb_clocks_set(device, true);
-
-	/* Init TLL */
-	ret = amdm37x_usb_tll_init(device);
-	if (ret != EOK) {
-		ddf_msg(LVL_FATAL, "Failed to init USB TLL!.\n");
-		amdm37x_usb_clocks_set(device, false);
-		return ret;
-	}
-
-	/* Register functions */
-	for (unsigned i = 0; i < ARRAY_SIZE(amdm37x_funcs); ++i) {
-		if (rootamdm37x_add_fun(dev, &amdm37x_funcs[i]) != EOK)
-			ddf_msg(LVL_ERROR, "Failed to add %s function for "
-			    "BeagleBoard-xM platform.", amdm37x_funcs[i].name);
-	}
-	return EOK;
-}
-
-/** The root device driver's standard operations. */
-static driver_ops_t rootamdm37x_ops = {
-	.dev_add = &rootamdm37x_dev_add
-};
-
-/** The root device driver structure. */
-static driver_t rootamdm37x_driver = {
-	.name = NAME,
-	.driver_ops = &rootamdm37x_ops
-};
-
-static hw_resource_list_t * rootamdm37x_get_resources(ddf_fun_t *fnode)
-{
-	rootamdm37x_fun_t *fun = ddf_fun_data_get(fnode);
-	assert(fun != NULL);
-	return &fun->hw_resources;
-}
-
-static bool rootamdm37x_enable_interrupt(ddf_fun_t *fun)
-{
-	//TODO: Implement
-	return false;
-}
-
-int main(int argc, char *argv[])
-{
-	printf("%s: HelenOS AM/DM37x(OMAP37x) platform driver\n", NAME);
-	ddf_log_init(NAME);
-	return ddf_driver_main(&rootamdm37x_driver);
-}
-
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootamdm37x/rootamdm37x.ma
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/rootamdm37x.ma	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 platform/beagleboardxm
Index: pace/drv/infrastructure/rootamdm37x/uhh.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/uhh.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvuhh
- * @{
- */
-/** @file
- * @brief UHH IO register structure.
- */
-#ifndef AMDM37x_UHH_H
-#define AMDM37x_UHH_H
-#include <macros.h>
-#include <sys/types.h>
-
-#define AMDM37x_UHH_BASE_ADDRESS  0x48064000
-#define AMDM37x_UHH_SIZE  1024
-
-typedef struct {
-	const ioport32_t revision;
-#define UHH_REVISION_MINOR_MASK  0x0f
-#define UHH_REVISION_MAJOR_MASK  0xf0
-
-	PADD32[3];
-	ioport32_t sysconfig;
-#define UHH_SYSCONFIG_AUTOIDLE_FLAG  (1 << 0)
-#define UHH_SYSCONFIG_SOFTRESET_FLAG  (1 << 1)
-#define UHH_SYSCONFIG_ENWAKEUP_FLAG  (1 << 2)
-#define UHH_SYSCONFIG_SIDLE_MODE_MASK  (0x3 << 3)
-#define UHH_SYSCONFIG_SIDLE_MODE_FORCE  (0x0 << 3)
-#define UHH_SYSCONFIG_SIDLE_MODE_NO  (0x1 << 3)
-#define UHH_SYSCONFIG_SIDLE_MODE_SMART  (0x2 << 3)
-#define UHH_SYSCONFIG_CLOCKACTIVITY_FLAG  (1 << 8)
-#define UHH_SYSCONFIG_MIDLE_MODE_MASK  (0x3 << 12)
-#define UHH_SYSCONFIG_MIDLE_MODE_FORCE  (0x0 << 12)
-#define UHH_SYSCONFIG_MIDLE_MODE_NO  (0x1 << 12)
-#define UHH_SYSCONFIG_MIDLE_MODE_SMART  (0x2 << 12)
-
-	const ioport32_t sysstatus;
-#define UHH_SYSSTATUS_RESETDONE_FLAG  (1 << 0)
-#define UHH_SYSSTATUS_OHCI_RESETDONE_FLAG  (1 << 1)
-#define UHH_SYSSTATUS_EHCI_RESETDONE_FLAG  (1 << 2)
-
-	PADD32[10];
-	ioport32_t hostconfig;
-#define UHH_HOSTCONFIG_P1_ULPI_BYPASS_FLAG  (1 << 0)
-#define UHH_HOSTCONFIG_AUTOPPD_ON_OVERCUR_EN_FLAG  (1 << 1)
-#define UHH_HOSTCONFIG_ENA_INCR4_FLAG  (1 << 2)
-#define UHH_HOSTCONFIG_ENA_INCR8_FLAG  (1 << 3)
-#define UHH_HOSTCONFIG_ENA_INCR16_FLA  (1 << 4)
-#define UHH_HOSTCONFIG_ENA_INCR_ALIGN_FLAG  (1 << 5)
-#define UHH_HOSTCONFIG_P1_CONNECT_STATUS_FLAG  (1 << 8)
-#define UHH_HOSTCONFIG_P2_CONNECT_STATUS_FLAG  (1 << 9)
-#define UHH_HOSTCONFIG_P3_CONNECT_STATUS_FLAG  (1 << 10)
-#define UHH_HOSTCONFIG_P2_ULPI_BYPASS_FLAG  (1 << 11)
-#define UHH_HOSTCONFIG_P3_ULPI_BYPASS_FLAG  (1 << 12)
-
-	ioport32_t debug_csr;
-#define UHH_DEBUG_CSR_EHCI_FLADJ_MASK  (0x3f << 0)
-#define UHH_DEBUG_CSR_EHCI_FLADJ(x)  ((x) & 0x3f)
-#define UHH_DEBUG_CSR_EHCI_SIMULATION_MODE_FLAG  (1 << 6)
-#define UHH_DEBUG_CSR_OHCI_CNTSEL_FLAG  (1 << 7)
-#define UHH_DEBUG_CSR_OHCI_GLOBAL_SUSPEND_FLAG  (1 << 16)
-#define UHH_DEBUG_CSR_OHCI_CCS1_FLAG  (1 << 17)
-#define UHH_DEBUG_CSR_OHCI_CCS2_FLAG  (1 << 18)
-#define UHH_DEBUG_CSR_OHCI_CCS3_FLAG  (1 << 19)
-
-} uhh_regs_t;
-
-#endif
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootamdm37x/usbtll.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/usbtll.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,129 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37xdrvusbtll
- * @{
- */
-/** @file
- * @brief USBTLL IO register structure.
- */
-#ifndef AMDM37x_USBTLL_H
-#define AMDM37x_USBTLL_H
-#include <macros.h>
-#include <sys/types.h>
-
-#define AMDM37x_USBTLL_BASE_ADDRESS  0x48062000
-#define AMDM37x_USBTLL_SIZE  4096
-
-typedef struct {
-	const ioport32_t revision;
-#define TLL_REVISION_MINOR_MASK  0x0f
-#define TLL_REVISION_MAJOR_MASK  0xf0
-
-	PADD32[3];
-	ioport32_t sysconfig;
-#define TLL_SYSCONFIG_AUTOIDLE_FLAG  (1 << 0)
-#define TLL_SYSCONFIG_SOFTRESET_FLAG  (1 << 1)
-#define TLL_SYSCONFIG_ENWAKEUP_FLAG  (1 << 2)
-#define TLL_SYSCONFIG_SIDLE_MODE_MASK  (0x3 << 3)
-#define TLL_SYSCONFIG_SIDLE_MODE_FORCE  (0x0 << 3)
-#define TLL_SYSCONFIG_SIDLE_MODE_NO  (0x1 << 3)
-#define TLL_SYSCONFIG_SIDLE_MODE_SMART  (0x2 << 3)
-#define TLL_SYSCONFIG_CLOCKACTIVITY_FLAG  (1 << 8)
-
-	const ioport32_t sysstatus;
-#define TLL_SYSSTATUS_RESET_DONE_FLAG  (1 << 0)
-
-	const ioport32_t irqstatus;
-#define TLL_IRQSTATUS_FCLK_START_FLAG  (1 << 0)
-#define TLL_IRQSTATUS_FCLK_END_FLAG  (1 << 1)
-#define TLL_IRQSTATUS_ACCESS_ERROR_FLAG  (1 << 2)
-
-	ioport32_t irqenable;
-#define TLL_IRQSTATUS_FCLK_START_EN_FLAG  (1 << 0)
-#define TLL_IRQSTATUS_FCLK_END_EN_FLAG  (1 << 1)
-#define TLL_IRQSTATUS_ACCESS_ERROR_EN_FLAG  (1 << 2)
-
-	PADD32[4];
-	ioport32_t shared_conf;
-#define TLL_SHARED_CONF_FCLK_IS_ON_FLAG  (1 << 0)
-#define TLL_SHARED_CONF_FCLK_REQ_FLAG  (1 << 1)
-#define TLL_SHARED_CONF_USB_DIVRATIO_MASK  (0x7 << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO(x)  (((x) & 0x7) << 2)
-#define TLL_SHARED_CONF_USB_180D_SDR_EN_FLAG  (1 << 5)
-#define TLL_SHARED_CONF_USB_90D_DDR_EN_FLAG  (1 << 6)
-
-	PADD32[3];
-	ioport32_t channel_conf[3];
-#define TLL_CHANNEL_CONF_CHANEN_FLAG  (1 << 0)
-#define TLL_CHANNEL_CONF_CHANMODE_MASK  (0x3 << 1)
-#define TLL_CHANNEL_CONF_CHANMODE_UTMI_ULPI_MODE (0x0 << 1)
-#define TLL_CHANNEL_CONF_CHANMODE_UTMI_SERIAL_MODE (0x1 << 1)
-#define TLL_CHANNEL_CONF_CHANMODE_UTMI_TRANS_MODE (0x2 << 1)
-#define TLL_CHANNEL_CONF_CHANMODE_NO_MODE (0x3 << 1)
-#define TLL_CHANNEL_CONF_UTMIISADEV_FLAG  (1 << 3)
-#define TLL_CHANNEL_CONF_TLLATTACH_FLAG  (1 << 4)
-#define TLL_CHANNEL_CONF_TLLCONNECT_FLAG  (1 << 5)
-#define TLL_CHANNEL_CONF_TLLFULLSPEED_FLAG  (1 << 6)
-#define TLL_CHANNEL_CONF_ULPIOUTCLKMODE_FLAG  (1 << 7)
-#define TLL_CHANNEL_CONF_ULPIDDRMODE_FLAG  (1 << 8)
-#define TLL_CHANNEL_CONF_UTMIAUTOIDLE_FLAG  (1 << 9)
-#define TLL_CHANNEL_CONF_ULPIAUTOIDLE_FLAG  (1 << 10)
-#define TLL_CHANNEL_CONF_ULPINOBITSTUFF_FLAG  (1 << 11)
-#define TLL_CHANNEL_CONF_CHRGVBUS_FLAG  (1 << 15)
-#define TLL_CHANNEL_CONF_DRVVBUS_FLAG  (1 << 16)
-#define TLL_CHANNEL_CONF_TESTEN_FLAG  (1 << 17)
-#define TLL_CHANNEL_CONF_TESTTXEN_FLAG  (1 << 18)
-#define TLL_CHANNEL_CONF_TESTTXDAT_FLAG  (1 << 19)
-#define TLL_CHANNEL_CONF_TESTTXSE0_FLAG  (1 << 20)
-#define TLL_CHANNEL_CONF_FSLSMODE_MASK   (0xf << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_PHY_TX_DATSE0   (0x0 << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_PHY_TX_DPDM   (0x1 << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_PHY   (0x2 << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_4PIN_BIDI_PHY   (0x3 << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_TLL_TX_DATSE0  (0x4 << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_TLL_TX_DPDM  (0x5 << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_TLL  (0x6 << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_4PIN_BIDI_TLL  (0x7 << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_2PIN_BIDI_TLL_DATSE0  (0xa << 24)
-#define TLL_CHANNEL_CONF_FSLSMODE_2PIN_BIDI_TLL_DPDM  (0xb << 24)
-
-#define TLL_CHANNEL_CONF_FSLSLINESTATE_MASK  (0x3 << 28)
-#define TLL_CHANNEL_CONF_FSLSLINESTATE_SE0  (0x0 << 28)
-#define TLL_CHANNEL_CONF_FSLSLINESTATE_FS_J  (0x1 << 28)
-#define TLL_CHANNEL_CONF_FSLSLINESTATE_FS_K  (0x2 << 28)
-#define TLL_CHANNEL_CONF_FSLSLINESTATE_SE1  (0x3 << 28)
-
-	/* The rest are 8bit ULPI registers */
-} tll_regs_t;
-
-#endif
-/**
- * @}
- */
-
Index: pace/drv/infrastructure/rootleon3/Makefile
===================================================================
--- uspace/drv/infrastructure/rootleon3/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#
-# Copyright (c) 2012 Jan Vesely
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
-BINARY = rootleon3
-
-SOURCES = \
-	rootleon3.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/drv/infrastructure/rootleon3/rootleon3.c
===================================================================
--- uspace/drv/infrastructure/rootleon3/rootleon3.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,195 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * Copyright (c) 2013 Jakub Klama
- * 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.
- */
-
-/**
- * @defgroup root_leon3 SPARC LEON3 platform driver.
- * @brief HelenOS SPARC LEON3 platform driver.
- * @{
- */
-/** @file
- */
-
-#include <ddf/log.h>
-#include <errno.h>
-#include <ops/hw_res.h>
-#include <stdio.h>
-#include "rootleon3.h"
-
-#define NAME  "rootleon3"
-
-typedef struct {
-	const char *name;
-	match_id_t match_id;
-	hw_resource_list_t hw_resources;
-} rootleon3_fun_t;
-
-static hw_resource_t amba_res[] = {
-	{
-		.type = MEM_RANGE,
-		.res.mem_range = {
-			.address = AMBAPP_MASTER_AREA,
-			.size = AMBAPP_MASTER_SIZE,
-			.endianness = BIG_ENDIAN
-		}
-	},
-	{
-		.type = MEM_RANGE,
-		.res.mem_range = {
-			.address = AMBAPP_SLAVE_AREA,
-			.size = AMBAPP_SLAVE_SIZE,
-			.endianness = BIG_ENDIAN,
-		}
-	}
-};
-
-static const rootleon3_fun_t leon3_func = {
-	.name = "leon_amba",
-	.match_id = {
-		.id =  "leon_amba",
-		.score = 90 
-	},
-	.hw_resources = {
-		.count = 2,
-		.resources = amba_res
-	}
-};
-
-static hw_resource_list_t *rootleon3_get_resources(ddf_fun_t *);
-static bool rootleon3_enable_interrupt(ddf_fun_t *);
-
-static hw_res_ops_t fun_hw_res_ops = {
-	.get_resource_list = &rootleon3_get_resources,
-	.enable_interrupt = &rootleon3_enable_interrupt
-};
-
-static ddf_dev_ops_t rootleon3_fun_ops = {
-	.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops
-};
-
-static int rootleon3_add_fun(ddf_dev_t *dev, const rootleon3_fun_t *fun)
-{
-	assert(dev);
-	assert(fun);
-	
-	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", fun->name);
-	
-	/* Create new device function. */
-	ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, fun->name);
-	if (fnode == NULL)
-		return ENOMEM;
-	
-	/* Add match id */
-	int ret = ddf_fun_add_match_id(fnode, fun->match_id.id,
-	    fun->match_id.score);
-	if (ret != EOK) {
-		ddf_fun_destroy(fnode);
-		return ret;
-	}
-	
-	/* Allocate needed data */
-	rootleon3_fun_t *rf =
-	    ddf_fun_data_alloc(fnode, sizeof(rootleon3_fun_t));
-	if (!rf) {
-		ddf_fun_destroy(fnode);
-		return ENOMEM;
-	}
-	*rf = *fun;
-	
-	/* Set provided operations to the device. */
-	ddf_fun_set_ops(fnode, &rootleon3_fun_ops);
-	
-	/* Register function. */
-	ret = ddf_fun_bind(fnode);
-	if (ret != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function %s.", fun->name);
-		ddf_fun_destroy(fnode);
-		return ret;
-	}
-	
-	return EOK;
-}
-
-/** Add the root device.
- *
- * @param dev Device which is root of the whole device tree
- *            (both of HW and pseudo devices).
- *
- * @return Zero on success, negative error number otherwise.
- *
- */
-static int rootleon3_dev_add(ddf_dev_t *dev)
-{
-	assert(dev);
-	
-	/* Register functions */
-	if (rootleon3_add_fun(dev, &leon3_func) != EOK) {
-		ddf_msg(LVL_ERROR, "Failed to add %s function for "
-		    "LEON3 platform.", leon3_func.name);
-	}
-	
-	return EOK;
-}
-
-/** The root device driver's standard operations. */
-static driver_ops_t rootleon3_ops = {
-	.dev_add = &rootleon3_dev_add
-};
-
-/** The root device driver structure. */
-static driver_t rootleon3_driver = {
-	.name = NAME,
-	.driver_ops = &rootleon3_ops
-};
-
-static hw_resource_list_t *rootleon3_get_resources(ddf_fun_t *fnode)
-{
-	rootleon3_fun_t *fun = ddf_fun_data_get(fnode);
-	assert(fun != NULL);
-	
-	printf("rootleon3_get_resources() called\n");
-	
-	return &fun->hw_resources;
-}
-
-static bool rootleon3_enable_interrupt(ddf_fun_t *fun)
-{
-	// FIXME TODO
-	return false;
-}
-
-int main(int argc, char *argv[])
-{
-	printf("%s: HelenOS SPARC LEON3 platform driver\n", NAME);
-	ddf_log_init(NAME);
-	return ddf_driver_main(&rootleon3_driver);
-}
-
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootleon3/rootleon3.h
===================================================================
--- uspace/drv/infrastructure/rootleon3/rootleon3.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2013 Jakub Klama
- * 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 leon3drv
- * @{
- */
-/** @file
- * @brief LEON3 root device.
- */
-
-#ifndef ROOTLEON3_H
-#define ROOTLEON3_H
-
-#define AMBAPP_MASTER_AREA  0xfffff000
-#define AMBAPP_SLAVE_AREA   0xfffff800
-#define AMBAPP_MASTER_SIZE  0x800
-#define AMBAPP_SLAVE_SIZE   0x800
-
-#endif
-
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootleon3/rootleon3.ma
===================================================================
--- uspace/drv/infrastructure/rootleon3/rootleon3.ma	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-100 platform/leon3
Index: pace/drv/infrastructure/rootmac/Makefile
===================================================================
--- uspace/drv/infrastructure/rootmac/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,37 +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.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
-BINARY = rootmac
-
-SOURCES = \
-	rootmac.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/drv/infrastructure/rootmac/rootmac.c
===================================================================
--- uspace/drv/infrastructure/rootmac/rootmac.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,190 +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.
- */
-
-/**
- * @defgroup root_mac Mac platform driver.
- * @brief HelenOS Mac platform driver.
- * @{
- */
-
-/** @file
- */
-
-#include <ddf/driver.h>
-#include <ddf/log.h>
-#include <errno.h>
-#include <ops/hw_res.h>
-#include <stdio.h>
-
-#define NAME  "rootmac"
-
-typedef struct {
-	hw_resource_list_t hw_resources;
-} rootmac_fun_t;
-
-static hw_resource_t pci_conf_regs[] = {
-	{
-		.type = IO_RANGE,
-		.res.io_range = {
-			.address = 0xfec00000,
-			.size = 4,
-			.relative = false,
-			.endianness = LITTLE_ENDIAN
-		}
-	},
-	{
-		.type = IO_RANGE,
-		.res.io_range = {
-			.address = 0xfee00000,
-			.size = 4,
-			.relative = false,
-			.endianness = LITTLE_ENDIAN
-		}
-	}
-};
-
-static rootmac_fun_t pci_data = {
-	.hw_resources = {
-		2,
-		pci_conf_regs
-	}
-};
-
-static ddf_dev_ops_t rootmac_fun_ops;
-
-/** Obtain function soft-state from DDF function node */
-static rootmac_fun_t *rootmac_fun(ddf_fun_t *fnode)
-{
-	return ddf_fun_data_get(fnode);
-}
-
-static bool rootmac_add_fun(ddf_dev_t *dev, const char *name,
-    const char *str_match_id, rootmac_fun_t *fun_proto)
-{
-	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
-	
-	ddf_fun_t *fnode = NULL;
-	int rc;
-	
-	/* Create new device. */
-	fnode = ddf_fun_create(dev, fun_inner, name);
-	if (fnode == NULL)
-		goto failure;
-	
-	rootmac_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(rootmac_fun_t));
-	*fun = *fun_proto;
-	
-	/* Add match ID */
-	rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
-	if (rc != EOK)
-		goto failure;
-	
-	/* Set provided operations to the device. */
-	ddf_fun_set_ops(fnode, &rootmac_fun_ops);
-	
-	/* Register function. */
-	if (ddf_fun_bind(fnode) != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
-		goto failure;
-	}
-	
-	return true;
-	
-failure:
-	if (fnode != NULL)
-		ddf_fun_destroy(fnode);
-	
-	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
-	
-	return false;
-}
-
-/** Get the root device.
- *
- * @param dev Device which is root of the whole device tree
- *            (both of HW and pseudo devices).
- *
- * @return Zero on success, negative error number otherwise.
- *
- */
-static int rootmac_dev_add(ddf_dev_t *dev)
-{
-#if 0
-	/* Register functions */
-	if (!rootmac_add_fun(dev, "pci0", "intel_pci", &pci_data))
-		ddf_msg(LVL_ERROR, "Failed to add functions for Mac platform.");
-#else
-	(void)pci_data;
-	(void)rootmac_add_fun;
-#endif
-	
-	return EOK;
-}
-
-/** The root device driver's standard operations. */
-static driver_ops_t rootmac_ops = {
-	.dev_add = &rootmac_dev_add
-};
-
-/** The root device driver structure. */
-static driver_t rootmac_driver = {
-	.name = NAME,
-	.driver_ops = &rootmac_ops
-};
-
-static hw_resource_list_t *rootmac_get_resources(ddf_fun_t *fnode)
-{
-	rootmac_fun_t *fun = rootmac_fun(fnode);
-	assert(fun != NULL);
-	
-	return &fun->hw_resources;
-}
-
-static bool rootmac_enable_interrupt(ddf_fun_t *fun)
-{
-	/* TODO */
-	
-	return false;
-}
-
-static hw_res_ops_t fun_hw_res_ops = {
-   	.get_resource_list = &rootmac_get_resources,
-	.enable_interrupt = &rootmac_enable_interrupt
-};
-
-int main(int argc, char *argv[])
-{
-	printf("%s: HelenOS Mac platform driver\n", NAME);
-	ddf_log_init(NAME);
-	rootmac_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
-	return ddf_driver_main(&rootmac_driver);
-}
-
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootmac/rootmac.ma
===================================================================
--- uspace/drv/infrastructure/rootmac/rootmac.ma	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 platform/mac
Index: pace/drv/infrastructure/rootmalta/Makefile
===================================================================
--- uspace/drv/infrastructure/rootmalta/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,37 +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.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
-BINARY = rootmalta
-
-SOURCES = \
-	rootmalta.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/drv/infrastructure/rootmalta/rootmalta.c
===================================================================
--- uspace/drv/infrastructure/rootmalta/rootmalta.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,273 +1,0 @@
-/*
- * Copyright (c) 2010 Lenka Trochtova
- * Copyright (c) 2013 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @defgroup root_malta Malta board platform driver.
- * @brief HelenOS Malta board platform driver.
- * @{
- */
-
-/** @file
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <fibril_synch.h>
-#include <stdlib.h>
-#include <str.h>
-#include <ctype.h>
-#include <macros.h>
-
-#include <ddi.h>
-#include <ddf/driver.h>
-#include <ddf/log.h>
-#include <ipc/dev_iface.h>
-#include <ops/hw_res.h>
-#include <ops/pio_window.h>
-#include <byteorder.h>
-
-#define NAME "rootmalta"
-
-#define GT_BASE		UINT32_C(0x1be00000)
-#define GT_SIZE 	(2 * 1024 * 1024)
-
-#define GT_PCI_CMD	0xc00
-#define GT_PCI_CONFADDR	0xcf8
-#define GT_PCI_CONFDATA	0xcfc
-
-#define GT_PCI_CMD_MBYTESWAP	0x1
-
-#define GT_PCI_MEMBASE	UINT32_C(0x10000000)
-#define GT_PCI_MEMSIZE	UINT32_C(0x08000000)
-
-#define GT_PCI_IOBASE	UINT32_C(0x18000000)
-#define GT_PCI_IOSIZE	UINT32_C(0x00200000)
-
-typedef struct rootmalta_fun {
-	hw_resource_list_t hw_resources;
-	pio_window_t pio_window;
-} rootmalta_fun_t;
-
-static int rootmalta_dev_add(ddf_dev_t *dev);
-static void root_malta_init(void);
-
-/** The root device driver's standard operations. */
-static driver_ops_t rootmalta_ops = {
-	.dev_add = &rootmalta_dev_add
-};
-
-/** The root device driver structure. */
-static driver_t rootmalta_driver = {
-	.name = NAME,
-	.driver_ops = &rootmalta_ops
-};
-
-static hw_resource_t pci_conf_regs[] = {
-	{
-		.type = IO_RANGE,
-		.res.io_range = {
-			.address = GT_BASE + GT_PCI_CONFADDR,
-			.size = 4,
-			.relative = false,
-			.endianness = LITTLE_ENDIAN
-		}
-	},
-	{
-		.type = IO_RANGE,
-		.res.io_range = {
-			.address = GT_BASE + GT_PCI_CONFDATA,
-			.size = 4,
-			.relative = false,
-			.endianness = LITTLE_ENDIAN
-		}
-	}
-};
-
-static rootmalta_fun_t pci_data = {
-	.hw_resources = {
-		sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]),
-		pci_conf_regs
-	},
-	.pio_window = {
-		.mem = {
-			.base = GT_PCI_MEMBASE,
-			.size = GT_PCI_MEMSIZE
-		},
-		.io = {
-			.base = GT_PCI_IOBASE,
-			.size = GT_PCI_IOSIZE
-		}
-	}
-};
-
-/** Obtain function soft-state from DDF function node */
-static rootmalta_fun_t *rootmalta_fun(ddf_fun_t *fnode)
-{
-	return ddf_fun_data_get(fnode);
-}
-
-static hw_resource_list_t *rootmalta_get_resources(ddf_fun_t *fnode)
-{
-	rootmalta_fun_t *fun = rootmalta_fun(fnode);
-	
-	assert(fun != NULL);
-	return &fun->hw_resources;
-}
-
-static bool rootmalta_enable_interrupt(ddf_fun_t *fun)
-{
-	/* TODO */
-	
-	return false;
-}
-
-static pio_window_t *rootmalta_get_pio_window(ddf_fun_t *fnode)
-{
-	rootmalta_fun_t *fun = rootmalta_fun(fnode);
-
-	assert(fun != NULL);
-	return &fun->pio_window;
-}
-
-static hw_res_ops_t fun_hw_res_ops = {
-	.get_resource_list = &rootmalta_get_resources,
-	.enable_interrupt = &rootmalta_enable_interrupt,
-};
-
-static pio_window_ops_t fun_pio_window_ops = {
-	.get_pio_window = &rootmalta_get_pio_window
-};
-
-/* Initialized in root_malta_init() function. */
-static ddf_dev_ops_t rootmalta_fun_ops;
-
-static bool
-rootmalta_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
-    rootmalta_fun_t *fun_proto)
-{
-	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
-	
-	ddf_fun_t *fnode = NULL;
-	int rc;
-	
-	/* Create new device. */
-	fnode = ddf_fun_create(dev, fun_inner, name);
-	if (fnode == NULL)
-		goto failure;
-	
-	rootmalta_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(rootmalta_fun_t));
-	*fun = *fun_proto;
-	
-	/* Add match ID */
-	rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
-	if (rc != EOK)
-		goto failure;
-	
-	/* Set provided operations to the device. */
-	ddf_fun_set_ops(fnode, &rootmalta_fun_ops);
-	
-	/* Register function. */
-	if (ddf_fun_bind(fnode) != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
-		goto failure;
-	}
-	
-	return true;
-	
-failure:
-	if (fnode != NULL)
-		ddf_fun_destroy(fnode);
-	
-	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
-	
-	return false;
-}
-
-static bool rootmalta_add_functions(ddf_dev_t *dev)
-{
-	return rootmalta_add_fun(dev, "pci0", "intel_pci", &pci_data);
-}
-
-/** Get the root device.
- *
- * @param dev		The device which is root of the whole device tree (both
- *			of HW and pseudo devices).
- * @return		Zero on success, negative error number otherwise.
- */
-static int rootmalta_dev_add(ddf_dev_t *dev)
-{
-	ioport32_t *gt;
-	uint32_t val;
-	int ret;
-
-	ddf_msg(LVL_DEBUG, "rootmalta_dev_add, device handle = %d",
-	    (int)ddf_dev_get_handle(dev));
-
-	/*
- 	 * We need to disable byte swapping of the outgoing and incoming
- 	 * PCI data, because the PCI driver assumes no byte swapping behind
- 	 * the scenes and takes care of it itself.
- 	 */
-	ret = pio_enable((void *) GT_BASE, GT_SIZE, (void **) &gt);
-	if (ret != EOK)
-                return ret;
-	val = uint32_t_le2host(pio_read_32(
-	    &gt[GT_PCI_CMD / sizeof(ioport32_t)]));
-	val |= GT_PCI_CMD_MBYTESWAP;
-	pio_write_32(
-	    &gt[GT_PCI_CMD / sizeof(ioport32_t)], host2uint32_t_le(val));
-
-	
-	/* Register functions. */
-	if (!rootmalta_add_functions(dev)) {
-		ddf_msg(LVL_ERROR, "Failed to add functions for the Malta platform.");
-	}
-	
-	return EOK;
-}
-
-static void root_malta_init(void)
-{
-	ddf_log_init(NAME);
-	rootmalta_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
-	rootmalta_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops;
-}
-
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS Malta platform driver\n");
-	root_malta_init();
-	return ddf_driver_main(&rootmalta_driver);
-}
-
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootmalta/rootmalta.ma
===================================================================
--- uspace/drv/infrastructure/rootmalta/rootmalta.ma	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 platform/malta
Index: pace/drv/infrastructure/rootpc/Makefile
===================================================================
--- uspace/drv/infrastructure/rootpc/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,37 +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.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
-BINARY = rootpc
-
-SOURCES = \
-	rootpc.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/drv/infrastructure/rootpc/rootpc.c
===================================================================
--- uspace/drv/infrastructure/rootpc/rootpc.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,236 +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.
- */
-
-/**
- * @defgroup root_pc PC platform driver.
- * @brief HelenOS PC platform driver.
- * @{
- */
-
-/** @file
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <fibril_synch.h>
-#include <stdlib.h>
-#include <str.h>
-#include <ctype.h>
-#include <macros.h>
-
-#include <ddf/driver.h>
-#include <ddf/log.h>
-#include <ipc/dev_iface.h>
-#include <ops/hw_res.h>
-#include <ops/pio_window.h>
-
-#define NAME "rootpc"
-
-typedef struct rootpc_fun {
-	hw_resource_list_t hw_resources;
-	pio_window_t pio_window;
-} rootpc_fun_t;
-
-static int rootpc_dev_add(ddf_dev_t *dev);
-static void root_pc_init(void);
-
-/** The root device driver's standard operations. */
-static driver_ops_t rootpc_ops = {
-	.dev_add = &rootpc_dev_add
-};
-
-/** The root device driver structure. */
-static driver_t rootpc_driver = {
-	.name = NAME,
-	.driver_ops = &rootpc_ops
-};
-
-static hw_resource_t pci_conf_regs[] = {
-	{
-		.type = IO_RANGE,
-		.res.io_range = {
-			.address = 0xCF8,
-			.size = 4,
-			.relative = false,
-			.endianness = LITTLE_ENDIAN
-		}
-	},
-	{
-		.type = IO_RANGE,
-		.res.io_range = {
-			.address = 0xCFC,
-			.size = 4,
-			.relative = false,
-			.endianness = LITTLE_ENDIAN
-		}
-	}
-};
-
-static rootpc_fun_t pci_data = {
-	.hw_resources = {
-		sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]),
-		pci_conf_regs
-	},
-	.pio_window = {
-		.mem = {
-			.base = UINT32_C(0),
-			.size = UINT32_C(0xffffffff) /* practical maximum */
-		},
-		.io = {
-			.base = UINT32_C(0),
-			.size = UINT32_C(0x10000)
-		}
-	}
-};
-
-/** Obtain function soft-state from DDF function node */
-static rootpc_fun_t *rootpc_fun(ddf_fun_t *fnode)
-{
-	return ddf_fun_data_get(fnode);
-}
-
-static hw_resource_list_t *rootpc_get_resources(ddf_fun_t *fnode)
-{
-	rootpc_fun_t *fun = rootpc_fun(fnode);
-	
-	assert(fun != NULL);
-	return &fun->hw_resources;
-}
-
-static bool rootpc_enable_interrupt(ddf_fun_t *fun)
-{
-	/* TODO */
-	
-	return false;
-}
-
-static pio_window_t *rootpc_get_pio_window(ddf_fun_t *fnode)
-{
-	rootpc_fun_t *fun = rootpc_fun(fnode);
-	
-	assert(fun != NULL);
-	return &fun->pio_window;
-}
-
-static hw_res_ops_t fun_hw_res_ops = {
-	.get_resource_list = &rootpc_get_resources,
-	.enable_interrupt = &rootpc_enable_interrupt,
-};
-
-static pio_window_ops_t fun_pio_window_ops = {
-	.get_pio_window = &rootpc_get_pio_window
-};
-
-/* Initialized in root_pc_init() function. */
-static ddf_dev_ops_t rootpc_fun_ops;
-
-static bool
-rootpc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
-    rootpc_fun_t *fun_proto)
-{
-	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
-	
-	ddf_fun_t *fnode = NULL;
-	int rc;
-	
-	/* Create new device. */
-	fnode = ddf_fun_create(dev, fun_inner, name);
-	if (fnode == NULL)
-		goto failure;
-	
-	rootpc_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(rootpc_fun_t));
-	*fun = *fun_proto;
-	
-	/* Add match ID */
-	rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
-	if (rc != EOK)
-		goto failure;
-	
-	/* Set provided operations to the device. */
-	ddf_fun_set_ops(fnode, &rootpc_fun_ops);
-	
-	/* Register function. */
-	if (ddf_fun_bind(fnode) != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
-		goto failure;
-	}
-	
-	return true;
-	
-failure:
-	if (fnode != NULL)
-		ddf_fun_destroy(fnode);
-	
-	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
-	
-	return false;
-}
-
-static bool rootpc_add_functions(ddf_dev_t *dev)
-{
-	return rootpc_add_fun(dev, "pci0", "intel_pci", &pci_data);
-}
-
-/** Get the root device.
- *
- * @param dev		The device which is root of the whole device tree (both
- *			of HW and pseudo devices).
- * @return		Zero on success, negative error number otherwise.
- */
-static int rootpc_dev_add(ddf_dev_t *dev)
-{
-	ddf_msg(LVL_DEBUG, "rootpc_dev_add, device handle = %d",
-	    (int)ddf_dev_get_handle(dev));
-	
-	/* Register functions. */
-	if (!rootpc_add_functions(dev)) {
-		ddf_msg(LVL_ERROR, "Failed to add functions for PC platform.");
-	}
-	
-	return EOK;
-}
-
-static void root_pc_init(void)
-{
-	ddf_log_init(NAME);
-	rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
-	rootpc_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops;
-}
-
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS PC platform driver\n");
-	root_pc_init();
-	return ddf_driver_main(&rootpc_driver);
-}
-
-/**
- * @}
- */
Index: pace/drv/infrastructure/rootpc/rootpc.ma
===================================================================
--- uspace/drv/infrastructure/rootpc/rootpc.ma	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 platform/pc
Index: pace/drv/infrastructure/rootvirt/Makefile
===================================================================
--- uspace/drv/infrastructure/rootvirt/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#
-# Copyright (c) 2010 Vojtech Horky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = $(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
-BINARY = rootvirt
-
-SOURCES = \
-	rootvirt.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/drv/infrastructure/rootvirt/devices.def
===================================================================
--- uspace/drv/infrastructure/rootvirt/devices.def	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Add list of virtual devices you want to launch driver for here.
- *
- * Unless the list is empty, the last item shall be followed by a comma.
- */
-
-/* Kernel framebuffer */
-{
-    .name = "kfb",
-    .match_id = "virtual&kfb"
-},
-
-#ifdef CONFIG_TEST_DRIVERS
-
-{
-	.name = "test1",
-	.match_id = "virtual&test1"
-},
-{
-	.name = "test2alpha",
-	.match_id = "virtual&test2"
-},
-{
-	.name = "test2bravo",
-	.match_id = "virtual&test2"
-},
-{
-	.name = "null",
-	.match_id = "virtual&test1"
-},
-{
-	.name = "test3",
-	.match_id = "virtual&test3"
-},
-
-#endif
-
-#ifdef CONFIG_RUN_VIRTUAL_USB_HC
-
-/* Virtual USB host controller. */
-{
-	.name = "usbhc",
-	.match_id = "usb&hc=vhc"
-},
-
-#endif
Index: pace/drv/infrastructure/rootvirt/rootvirt.c
===================================================================
--- uspace/drv/infrastructure/rootvirt/rootvirt.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,249 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @defgroup rootvirt Root device driver for virtual devices.
- * @{
- */
-
-/** @file
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <errno.h>
-#include <str_error.h>
-#include <ddf/driver.h>
-#include <ddf/log.h>
-
-#define NAME "rootvirt"
-
-/** Virtual function entry */
-typedef struct {
-	/** Function name */
-	const char *name;
-	/** Function match ID */
-	const char *match_id;
-} virtual_function_t;
-
-/** List of existing virtual functions */
-virtual_function_t virtual_functions[] = {
-#include "devices.def"
-	/* Terminating item */
-	{
-		.name = NULL,
-		.match_id = NULL
-	}
-};
-
-static int rootvirt_dev_add(ddf_dev_t *dev);
-static int rootvirt_dev_remove(ddf_dev_t *dev);
-static int rootvirt_fun_online(ddf_fun_t *fun);
-static int rootvirt_fun_offline(ddf_fun_t *fun);
-
-static driver_ops_t rootvirt_ops = {
-	.dev_add = &rootvirt_dev_add,
-	.dev_remove = &rootvirt_dev_remove,
-	.fun_online = &rootvirt_fun_online,
-	.fun_offline = &rootvirt_fun_offline
-};
-
-static driver_t rootvirt_driver = {
-	.name = NAME,
-	.driver_ops = &rootvirt_ops
-};
-
-/* Device soft state */
-typedef struct {
-	ddf_dev_t *dev;
-	list_t functions;
-} rootvirt_t;
-
-/* Function soft state */
-typedef struct {
-	ddf_fun_t *fun;
-	link_t dev_link;
-} rootvirt_fun_t;
-
-static int instances = 0;
-
-
-/** Add function to the virtual device.
- *
- * @param vdev		The virtual device
- * @param vfun		Virtual function description
- * @return		EOK on success or negative error code.
- */
-static int rootvirt_add_fun(rootvirt_t *rootvirt, virtual_function_t *vfun)
-{
-	ddf_dev_t *vdev = rootvirt->dev;
-	ddf_fun_t *fun;
-	rootvirt_fun_t *rvfun;
-	int rc;
-
-	ddf_msg(LVL_DEBUG, "Registering function `%s' (match \"%s\")",
-	    vfun->name, vfun->match_id);
-
-	fun = ddf_fun_create(vdev, fun_inner, vfun->name);
-	if (fun == NULL) {
-		ddf_msg(LVL_ERROR, "Failed creating function %s", vfun->name);
-		return ENOMEM;
-	}
-
-	rvfun = ddf_fun_data_alloc(fun, sizeof(rootvirt_fun_t));
-	if (rvfun == NULL) {
-		ddf_msg(LVL_ERROR, "Failed allocating soft state for %s.",
-		    vfun->name);
-		ddf_fun_destroy(fun);
-		return ENOMEM;
-	}
-
-	rvfun->fun = fun;
-
-	rc = ddf_fun_add_match_id(fun, vfun->match_id, 10);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
-		    vfun->name);
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-
-	rc = ddf_fun_bind(fun);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function %s: %s",
-		    vfun->name, str_error(rc));
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-
-	list_append(&rvfun->dev_link, &rootvirt->functions);
-
-	ddf_msg(LVL_NOTE, "Registered child device `%s'", vfun->name);
-	return EOK;
-}
-
-static int rootvirt_fun_remove(rootvirt_fun_t *rvfun)
-{
-	int rc;
-	const char *name = ddf_fun_get_name(rvfun->fun);
-
-	ddf_msg(LVL_DEBUG, "rootvirt_fun_remove('%s')", name);
-	rc = ddf_fun_offline(rvfun->fun);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Error offlining function '%s'.", name);
-		return rc;
-	}
-
-	rc = ddf_fun_unbind(rvfun->fun);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", name);
-		return rc;
-	}
-
-	list_remove(&rvfun->dev_link);
-	ddf_fun_destroy(rvfun->fun);
-	return EOK;
-}
-
-
-static int rootvirt_dev_add(ddf_dev_t *dev)
-{
-	rootvirt_t *rootvirt;
-
-	/*
-	 * Allow only single instance of root virtual device.
-	 */
-	if (++instances > 1) {
-		return ELIMIT;
-	}
-
-	ddf_msg(LVL_DEBUG, "dev_add(handle=%d)", (int)ddf_dev_get_handle(dev));
-
-	rootvirt = ddf_dev_data_alloc(dev, sizeof(rootvirt_t));
-	if (rootvirt == NULL)
-		return ENOMEM;
-
-	rootvirt->dev = dev;
-	list_initialize(&rootvirt->functions);
-
-	/*
-	 * Go through all virtual functions and try to add them.
-	 * We silently ignore failures.
-	 */
-	virtual_function_t *vfun = virtual_functions;
-	while (vfun->name != NULL) {
-		(void) rootvirt_add_fun(rootvirt, vfun);
-		vfun++;
-	}
-
-	return EOK;
-}
-
-static int rootvirt_dev_remove(ddf_dev_t *dev)
-{
-	rootvirt_t *rootvirt = (rootvirt_t *)ddf_dev_data_get(dev);
-	int rc;
-
-	while (!list_empty(&rootvirt->functions)) {
-		rootvirt_fun_t *rvfun = list_get_instance(
-		    list_first(&rootvirt->functions), rootvirt_fun_t,
-			dev_link);
-
-		rc = rootvirt_fun_remove(rvfun);
-		if (rc != EOK)
-			return rc;
-	}
-
-	--instances;
-	return EOK;
-}
-
-static int rootvirt_fun_online(ddf_fun_t *fun)
-{
-	ddf_msg(LVL_DEBUG, "rootvirt_fun_online()");
-	return ddf_fun_online(fun);
-}
-
-static int rootvirt_fun_offline(ddf_fun_t *fun)
-{
-	ddf_msg(LVL_DEBUG, "rootvirt_fun_offline()");
-	return ddf_fun_offline(fun);
-}
-
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS virtual devices root driver\n");
-
-	ddf_log_init(NAME);
-	return ddf_driver_main(&rootvirt_driver);
-}
-
-/**
- * @}
- */
-
Index: pace/drv/infrastructure/rootvirt/rootvirt.ma
===================================================================
--- uspace/drv/infrastructure/rootvirt/rootvirt.ma	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 rootvirt
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/nic/e1k/e1k.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -1229,11 +1229,11 @@
 /** Handle device interrupt
  *
- * @param dev   E1000 device
  * @param iid   IPC call id
  * @param icall IPC call structure
- *
- */
-static void e1000_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid,
-    ipc_call_t *icall)
+ * @param dev   E1000 device
+ *
+ */
+static void e1000_interrupt_handler(ipc_callid_t iid, ipc_call_t *icall,
+    ddf_dev_t *dev)
 {
 	uint32_t icr = (uint32_t) IPC_GET_ARG2(*icall);
Index: uspace/drv/nic/ne2k/ne2k.c
===================================================================
--- uspace/drv/nic/ne2k/ne2k.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/nic/ne2k/ne2k.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -122,6 +122,5 @@
 };
 
-static void ne2k_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid,
-	ipc_call_t *call);
+static void ne2k_interrupt_handler(ipc_callid_t, ipc_call_t *, ddf_dev_t *);
 
 static int ne2k_register_interrupt(nic_t *nic_data)
@@ -240,9 +239,9 @@
 }
 
-void ne2k_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
+void ne2k_interrupt_handler(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev)
 {
 	nic_t *nic_data = DRIVER_DATA(dev);
 	ne2k_interrupt(nic_data, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call));
-
+	
 	async_answer_0(iid, EOK);
 }
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/nic/rtl8139/driver.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -852,10 +852,11 @@
 /** Handle device interrupt
  *
- *  @param dev    The rtl8139 device
- *  @param iid    The IPC call id
- *  @param icall  The IPC call structure
- */
-static void rtl8139_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid,
-    ipc_call_t *icall)
+ * @param iid    The IPC call id
+ * @param icall  The IPC call structure
+ * @param dev    The rtl8139 device
+ *
+ */
+static void rtl8139_interrupt_handler(ipc_callid_t iid, ipc_call_t *icall,
+    ddf_dev_t *dev)
 {
 	assert(dev);
Index: uspace/drv/nic/rtl8169/driver.c
===================================================================
--- uspace/drv/nic/rtl8169/driver.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/nic/rtl8169/driver.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -27,6 +27,4 @@
  */
 
-#define	_DDF_DATA_IMPLANT
-
 #include <assert.h>
 #include <errno.h>
@@ -76,6 +74,6 @@
 static int rtl8169_on_stopped(nic_t *nic_data);
 static void rtl8169_send_frame(nic_t *nic_data, void *data, size_t size);
-static void rtl8169_irq_handler(ddf_dev_t *dev, ipc_callid_t iid,
-    ipc_call_t *icall);
+static void rtl8169_irq_handler(ipc_callid_t iid, ipc_call_t *icall,
+    ddf_dev_t *dev);
 static inline int rtl8169_register_int_handler(nic_t *nic_data);
 static inline void rtl8169_get_hwaddr(rtl8169_t *rtl8169, nic_address_t *addr);
@@ -330,4 +328,12 @@
 }
 
+static void rtl8169_dev_cleanup(ddf_dev_t *dev)
+{
+	assert(dev);
+
+	if (ddf_dev_data_get(dev))
+		nic_unbind_and_destroy(dev);
+}
+
 static int rtl8169_dev_initialize(ddf_dev_t *dev)
 {
@@ -351,5 +357,5 @@
 failed:
 	ddf_msg(LVL_ERROR, "The device initialization failed");
-//	rtl8139_dev_cleanup(dev);
+	rtl8169_dev_cleanup(dev);
 	return ret;
 
@@ -439,5 +445,4 @@
 	nic_set_ddf_fun(nic_data, fun);
 	ddf_fun_set_ops(fun, &rtl8169_dev_ops);
-//	ddf_fun_data_implant(fun, nic_data);
 
 	rc = ddf_fun_bind(fun);
@@ -467,5 +472,5 @@
 err_pio:
 err_destroy:
-	//rtl8169_dev_cleanup(dev);
+	rtl8169_dev_cleanup(dev);
 	return rc;
 
@@ -733,12 +738,8 @@
 	/* Configure Receive Control Register */
 	uint32_t rcr = pio_read_32(rtl8169->regs + RCR);
-	rcr |= RCR_ACCEPT_ALL_PHYS | RCR_ACCEPT_PHYS_MATCH \
-	    | RCR_ACCEPT_BROADCAST | RCR_ACCEPT_ERROR \
-	    | RCR_ACCEPT_RUNT;
+	rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH;
+	rcr |= RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ERROR | RCR_ACCEPT_RUNT;
 	pio_write_32(rtl8169->regs + RCR, rcr);
 	pio_write_16(rtl8169->regs + RMS, BUFFER_SIZE);
-
-	ddf_msg(LVL_NOTE, "RCR: 0x%08x", pio_read_32(rtl8169->regs + RCR));
-
 
 	pio_write_16(rtl8169->regs + IMR, 0xffff);
@@ -793,7 +794,74 @@
 }
 
+/** Notify NIC framework about HW filtering state when promisc mode was disabled
+ *
+ *  @param nic_data     The NIC data
+ *  @param mcast_mode   Current multicast mode
+ *  @param was_promisc  Sign if the promiscuous mode was active before disabling
+ */
+inline static void rtl8169_rcx_promics_rem(nic_t *nic_data,
+    nic_multicast_mode_t mcast_mode, uint8_t was_promisc)
+{
+	assert(nic_data);
+
+	if (was_promisc != 0) {
+		if (mcast_mode == NIC_MULTICAST_LIST)
+			nic_report_hw_filtering(nic_data, 1, 0, -1);
+		else
+			nic_report_hw_filtering(nic_data, 1, 1, -1);
+	} else {
+		nic_report_hw_filtering(nic_data, 1, -1, -1);
+	}
+}
+
 static int rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
     const nic_address_t *addr, size_t addr_count)
 {
+	rtl8169_t *rtl8169 = nic_get_specific(nic_data);
+	uint32_t rcr = pio_read_32(rtl8169->regs + RCR);
+	uint8_t was_promisc = rcr & RCR_ACCEPT_ALL_PHYS;
+	nic_multicast_mode_t mcast_mode;
+
+	nic_query_multicast(nic_data, &mcast_mode, 0, NULL, NULL);
+
+	ddf_msg(LVL_DEBUG, "Unicast RX filter mode: %d", mode);
+
+
+	switch (mode) {
+	case NIC_UNICAST_BLOCKED:
+		rtl8169->rcr_ucast = 0;
+		rtl8169_rcx_promics_rem(nic_data, mcast_mode, was_promisc);
+		break;
+	case NIC_UNICAST_DEFAULT:
+		rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH;
+		rtl8169_rcx_promics_rem(nic_data, mcast_mode, was_promisc);
+		break;
+	case NIC_UNICAST_LIST:
+		rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS;
+
+		if (mcast_mode == NIC_MULTICAST_PROMISC)
+			nic_report_hw_filtering(nic_data, 0, 1, -1);
+		else
+			nic_report_hw_filtering(nic_data, 0, 0, -1);
+		break;
+	case NIC_UNICAST_PROMISC:
+		rtl8169->rcr_ucast = RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS;
+
+		if (mcast_mode == NIC_MULTICAST_PROMISC)
+			nic_report_hw_filtering(nic_data, 1, 1, -1);
+		else
+			nic_report_hw_filtering(nic_data, 1, 0, -1);
+		break;
+	default:
+		return ENOTSUP;
+	}
+
+	fibril_mutex_lock(&rtl8169->rx_lock);
+
+	rcr &= ~(RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS);
+	pio_write_32(rtl8169->regs + RCR, rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast);
+	ddf_msg(LVL_DEBUG, "new RCR value: 0x%08x", rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast);
+
+	fibril_mutex_unlock(&rtl8169->rx_lock);
 	return EOK;
 }
@@ -802,4 +870,42 @@
     const nic_address_t *addr, size_t addr_count)
 {
+	rtl8169_t *rtl8169 = nic_get_specific(nic_data);
+	uint32_t rcr = pio_read_32(rtl8169->regs + RCR);
+	uint64_t mask;
+
+	ddf_msg(LVL_DEBUG, "Multicast RX filter mode: %d", mode);
+
+	switch (mode) {
+	case NIC_MULTICAST_BLOCKED:
+		rtl8169->rcr_mcast = 0;
+		if ((rtl8169->rcr_ucast & RCR_ACCEPT_ALL_PHYS) != 0)
+			nic_report_hw_filtering(nic_data, -1, 0, -1);
+		else
+			nic_report_hw_filtering(nic_data, -1, 1, -1);
+		break;
+	case NIC_MULTICAST_LIST:
+		mask = nic_mcast_hash(addr, addr_count);
+		pio_write_32(rtl8169->regs + MAR0, (uint32_t)mask);
+		pio_write_32(rtl8169->regs + MAR0 + 4, (uint32_t)(mask >> 32));
+		rtl8169->rcr_mcast = RCR_ACCEPT_MULTICAST;
+		nic_report_hw_filtering(nic_data, -1, 0, -1);
+		break;
+	case NIC_MULTICAST_PROMISC:
+		pio_write_32(rtl8169->regs + MAR0, 0xffffffffULL);
+		pio_write_32(rtl8169->regs + MAR0 + 4, (uint32_t)(0xffffffffULL >> 32));
+		rtl8169->rcr_mcast = RCR_ACCEPT_MULTICAST;
+		nic_report_hw_filtering(nic_data, -1, 1, -1);
+		break;
+	default:
+		return ENOTSUP;
+	}
+
+	fibril_mutex_lock(&rtl8169->rx_lock);
+
+	rcr &= ~(RCR_ACCEPT_PHYS_MATCH | RCR_ACCEPT_ALL_PHYS);
+	pio_write_32(rtl8169->regs + RCR, rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast);
+	ddf_msg(LVL_DEBUG, "new RCR value: 0x%08x", rcr | rtl8169->rcr_ucast | rtl8169->rcr_mcast);
+
+	fibril_mutex_unlock(&rtl8169->rx_lock);
 	return EOK;
 }
@@ -807,4 +913,25 @@
 static int rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode)
 {
+	rtl8169_t *rtl8169 = nic_get_specific(nic_data);
+	
+	/* Configure Receive Control Register */
+	uint32_t rcr = pio_read_32(rtl8169->regs + RCR);
+
+	ddf_msg(LVL_DEBUG, "Broadcast RX filter mode: %d", mode);
+
+	switch (mode) {
+	case NIC_BROADCAST_BLOCKED:
+		rcr &= ~RCR_ACCEPT_BROADCAST;
+		break;
+	case NIC_BROADCAST_ACCEPTED:
+		rcr |= RCR_ACCEPT_BROADCAST;
+		break;
+	default:
+		return ENOTSUP;
+	}
+
+	pio_write_32(rtl8169->regs + RCR, rcr);
+	ddf_msg(LVL_DEBUG," new RCR value: 0x%08x", rcr);
+
 	return EOK;
 }
@@ -816,6 +943,7 @@
 	rtl8169_t *rtl8169 = nic_get_specific(nic_data);
 	rtl8169_descr_t *descr;
-
-	ddf_msg(LVL_NOTE, "rtl8169_transmit_done()");
+	int sent = 0;
+
+	ddf_msg(LVL_DEBUG, "rtl8169_transmit_done()");
 
 	fibril_mutex_lock(&rtl8169->tx_lock);
@@ -828,8 +956,12 @@
 		descr->control &= (~CONTROL_OWN);
 		write_barrier();
-		ddf_msg(LVL_NOTE, "TX status for descr %d: 0x%08x", tail, descr->control);
+		ddf_msg(LVL_DEBUG, "TX status for descr %d: 0x%08x", tail, descr->control);
 	
 		tail = (tail + 1) % TX_BUFFERS_COUNT;
-	}
+		sent++;
+	}
+
+	if (sent != 0)
+		nic_set_tx_busy(nic_data, 0);
 
 	rtl8169->tx_tail = tail;
@@ -849,5 +981,5 @@
 	int frame_size;
 
-	ddf_msg(LVL_NOTE, "rtl8169_receive_done()");
+	ddf_msg(LVL_DEBUG, "rtl8169_receive_done()");
 
 	fibril_mutex_lock(&rtl8169->rx_lock);
@@ -862,5 +994,5 @@
 
 		if (descr->control & RXSTATUS_RES) {
-			ddf_msg(LVL_NOTE, "error at slot %d: 0x%08x\n", tail, descr->control);
+			ddf_msg(LVL_WARN, "error at slot %d: 0x%08x\n", tail, descr->control);
 			tail = (tail + 1) % RX_BUFFERS_COUNT;
 			continue;
@@ -871,6 +1003,5 @@
 		
 		if (descr->control & CONTROL_LS) {
-
-			ddf_msg(LVL_NOTE, "received message at slot %d, control 0x%08x", tail, descr->control);
+			ddf_msg(LVL_DEBUG, "received message at slot %d, control 0x%08x", tail, descr->control);
 
 			if (fsidx != tail)
@@ -897,6 +1028,6 @@
 }
 
-static void rtl8169_irq_handler(ddf_dev_t *dev, ipc_callid_t iid,
-    ipc_call_t *icall)
+static void rtl8169_irq_handler(ipc_callid_t iid, ipc_call_t *icall,
+    ddf_dev_t *dev)
 {
 	assert(dev);
@@ -907,5 +1038,5 @@
 	rtl8169_t *rtl8169 = nic_get_specific(nic_data);
 
-	ddf_msg(LVL_NOTE, "rtl8169_irq_handler(): isr=0x%04x", isr);
+	ddf_msg(LVL_DEBUG, "rtl8169_irq_handler(): isr=0x%04x", isr);
 	pio_write_16(rtl8169->regs + IMR, 0xffff);
 
@@ -963,5 +1094,5 @@
 	fibril_mutex_lock(&rtl8169->tx_lock);
 
-	ddf_msg(LVL_NOTE, "send_frame: size: %zu, tx_head=%d tx_tail=%d",
+	ddf_msg(LVL_DEBUG, "send_frame: size: %zu, tx_head=%d tx_tail=%d",
 	    size, rtl8169->tx_head, rtl8169->tx_tail);
 
@@ -986,5 +1117,5 @@
 	prev = &rtl8169->tx_ring[(head - 1) % TX_BUFFERS_COUNT];
 
-	ddf_msg(LVL_NOTE, "current_descr=%p, prev_descr=%p", descr, prev);
+	ddf_msg(LVL_DEBUG, "current_descr=%p, prev_descr=%p", descr, prev);
 
 	descr->control = CONTROL_OWN | CONTROL_FS | CONTROL_LS;
Index: uspace/drv/nic/rtl8169/driver.h
===================================================================
--- uspace/drv/nic/rtl8169/driver.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/drv/nic/rtl8169/driver.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -86,4 +86,8 @@
 	size_t tx_used;
 
+	/** Receive Control Register masks */
+	uint32_t rcr_ucast;
+	uint32_t rcr_mcast;
+
 	/** Lock for receiver */
 	fibril_mutex_t rx_lock;
Index: uspace/drv/platform/amdm37x/Makefile
===================================================================
--- uspace/drv/platform/amdm37x/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2012 Jan Vesely
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = amdm37x
+
+SOURCES = \
+	amdm37x.c \
+	main.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/platform/amdm37x/amdm37x.c
===================================================================
--- uspace/drv/platform/amdm37x/amdm37x.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/amdm37x.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @defgroup amdm37x TI AM/DM37x platform driver.
+ * @brief HelenOS TI AM/DM37x platform driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#include "amdm37x.h"
+
+#include <assert.h>
+#include <ddi.h>
+#include <ddf/log.h>
+#include <errno.h>
+#include <stdio.h>
+
+static void log(const volatile void *place, uint32_t val, volatile void* base, size_t size, void *data, bool write)
+{
+	printf("PIO %s: %p(%p) %#"PRIx32"\n", write ? "WRITE" : "READ",
+	    (place - base) + data, place, val);
+}
+
+
+int amdm37x_init(amdm37x_t *device, bool trace)
+{
+	assert(device);
+	int ret = EOK;
+
+	ret = pio_enable((void*)USBHOST_CM_BASE_ADDRESS, USBHOST_CM_SIZE,
+	    (void**)&device->cm.usbhost);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)CORE_CM_BASE_ADDRESS, CORE_CM_SIZE,
+	    (void**)&device->cm.core);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)CLOCK_CONTROL_CM_BASE_ADDRESS,
+		    CLOCK_CONTROL_CM_SIZE, (void**)&device->cm.clocks);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)MPU_CM_BASE_ADDRESS,
+		    MPU_CM_SIZE, (void**)&device->cm.mpu);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)IVA2_CM_BASE_ADDRESS,
+		    IVA2_CM_SIZE, (void**)&device->cm.iva2);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)CLOCK_CONTROL_PRM_BASE_ADDRESS,
+	    CLOCK_CONTROL_PRM_SIZE, (void**)&device->prm.clocks);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)GLOBAL_REG_PRM_BASE_ADDRESS,
+	    GLOBAL_REG_PRM_SIZE, (void**)&device->prm.global);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)AMDM37x_USBTLL_BASE_ADDRESS,
+	    AMDM37x_USBTLL_SIZE, (void**)&device->tll);
+	if (ret != EOK)
+		return ret;
+
+	ret = pio_enable((void*)AMDM37x_UHH_BASE_ADDRESS,
+	    AMDM37x_UHH_SIZE, (void**)&device->uhh);
+	if (ret != EOK)
+		return ret;
+
+	if (trace) {
+		pio_trace_enable(device->tll, AMDM37x_USBTLL_SIZE, log, (void*)AMDM37x_USBTLL_BASE_ADDRESS);
+		pio_trace_enable(device->cm.clocks, CLOCK_CONTROL_CM_SIZE, log, (void*)CLOCK_CONTROL_CM_BASE_ADDRESS);
+		pio_trace_enable(device->cm.core, CORE_CM_SIZE, log, (void*)CORE_CM_BASE_ADDRESS);
+		pio_trace_enable(device->cm.mpu, MPU_CM_SIZE, log, (void*)MPU_CM_BASE_ADDRESS);
+		pio_trace_enable(device->cm.iva2, IVA2_CM_SIZE, log, (void*)IVA2_CM_BASE_ADDRESS);
+		pio_trace_enable(device->cm.usbhost, USBHOST_CM_SIZE, log, (void*)USBHOST_CM_BASE_ADDRESS);
+		pio_trace_enable(device->uhh, AMDM37x_UHH_SIZE, log, (void*)AMDM37x_UHH_BASE_ADDRESS);
+		pio_trace_enable(device->prm.clocks, CLOCK_CONTROL_PRM_SIZE, log, (void*)CLOCK_CONTROL_PRM_BASE_ADDRESS);
+		pio_trace_enable(device->prm.global, GLOBAL_REG_PRM_SIZE, log, (void*)GLOBAL_REG_PRM_BASE_ADDRESS);
+	}
+	return EOK;
+}
+
+
+/** Set DPLLs 1,2,3,4,5 to ON (locked) and autoidle.
+ * @param device Register map.
+ *
+ * The idea is to get all DPLLs running and make hw control their power mode,
+ * based on the module requirements (module ICLKs and FCLKs).
+ */
+void amdm37x_setup_dpll_on_autoidle(amdm37x_t *device)
+{
+	assert(device);
+	/* Get SYS_CLK value, it is used as reference clock by all DPLLs,
+	 * NFI who sets this or why it is set to specific value. */
+	const unsigned osc_clk = pio_read_32(&device->prm.clocks->clksel)
+	    & CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_MASK;
+	const unsigned clk_reg = pio_read_32(&device->prm.global->clksrc_ctrl);
+	const unsigned base_freq = sys_clk_freq_kHz(osc_clk)
+	    / GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_GET(clk_reg);
+	ddf_msg(LVL_NOTE, "Base frequency: %d.%dMhz",
+	    base_freq / 1000, base_freq % 1000);
+
+
+	/* DPLL1 provides MPU(CPU) clock.
+	 * It uses SYS_CLK as reference clock and core clock (DPLL3) as
+	 * high frequency bypass (MPU then runs on L3 interconnect freq).
+	 * It should be setup by fw or u-boot.*/
+	mpu_cm_regs_t *mpu = device->cm.mpu;
+
+	/* Current MPU frequency. */
+	if (pio_read_32(&mpu->clkstst) & MPU_CM_CLKSTST_CLKACTIVITY_MPU_ACTIVE_FLAG) {
+		if (pio_read_32(&mpu->idlest_pll) & MPU_CM_IDLEST_PLL_ST_MPU_CLK_LOCKED_FLAG) {
+			/* DPLL active and locked */
+			const uint32_t reg = pio_read_32(&mpu->clksel1_pll);
+			const unsigned multiplier =
+			    (reg & MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_MASK)
+				>> MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_SHIFT;
+			const unsigned divisor =
+			    (reg & MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_MASK)
+				>> MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_SHIFT;
+			const unsigned divisor2 =
+			    (pio_read_32(&mpu->clksel2_pll)
+			        & MPU_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV_MASK);
+			if (multiplier && divisor && divisor2) {
+				/** See AMDM37x TRM p. 300 for the formula */
+				const unsigned freq =
+				    ((base_freq * multiplier) / (divisor + 1))
+				    / divisor2;
+				ddf_msg(LVL_NOTE, "MPU running at %d.%d MHz",
+				    freq / 1000, freq % 1000);
+			} else {
+				ddf_msg(LVL_WARN, "Frequency divisor and/or "
+				    "multiplier value invalid: %d %d %d",
+				    multiplier, divisor, divisor2);
+			}
+		} else {
+			/* DPLL in LP bypass mode */
+			const unsigned divisor =
+			    MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_VAL(
+			        pio_read_32(&mpu->clksel1_pll));
+			ddf_msg(LVL_NOTE, "MPU DPLL in bypass mode, running at"
+			    " CORE CLK / %d MHz", divisor);
+		}
+	} else {
+		ddf_msg(LVL_WARN, "MPU clock domain is not active, we should not be running...");
+	}
+	// TODO: Enable this (automatic MPU downclocking):
+#if 0
+	/* Enable low power bypass mode, this will take effect the next lock or
+	 * relock sequence. */
+	//TODO: We might need to force re-lock after enabling this
+	pio_set_32(&mpu->clken_pll, MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG, 5);
+	/* Enable automatic relocking */
+	pio_change_32(&mpu->autoidle_pll, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK, 5);
+#endif
+
+	/* DPLL2 provides IVA(video acceleration) clock.
+	 * It uses SYS_CLK as reference clokc and core clock (DPLL3) as
+	 * high frequency bypass (IVA runs on L3 freq).
+	 */
+	// TODO: We can probably turn this off entirely. IVA is left unused.
+	/* Enable low power bypass mode, this will take effect the next lock or
+	 * relock sequence. */
+	//TODO: We might need to force re-lock after enabling this
+	pio_set_32(&device->cm.iva2->clken_pll, MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG, 5);
+	/* Enable automatic relocking */
+	pio_change_32(&device->cm.iva2->autoidle_pll, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED, MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK, 5);
+
+	/* DPLL3 provides tons of clocks:
+	 * CORE_CLK, COREX2_CLK, DSS_TV_CLK, 12M_CLK, 48M_CLK, 96M_CLK, L3_ICLK,
+	 * and L4_ICLK. It uses SYS_CLK as reference clock and low frequency
+	 * bypass. It should be setup by fw or u-boot as it controls critical
+	 * interconnects.
+	 */
+	if (pio_read_32(&device->cm.clocks->idlest_ckgen) & CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CORE_CLK_FLAG) {
+		/* DPLL active and locked */
+		const uint32_t reg =
+		    pio_read_32(&device->cm.clocks->clksel1_pll);
+		const unsigned multiplier =
+		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_GET(reg);
+		const unsigned divisor =
+		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_GET(reg);
+		const unsigned divisor2 =
+		    CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_GET(reg);
+		if (multiplier && divisor && divisor2) {
+			/** See AMDM37x TRM p. 300 for the formula */
+			const unsigned freq =
+			    ((base_freq * multiplier) / (divisor + 1)) / divisor2;
+			ddf_msg(LVL_NOTE, "CORE CLK running at %d.%d MHz",
+			    freq / 1000, freq % 1000);
+			const unsigned l3_div =
+			    pio_read_32(&device->cm.core->clksel)
+			    & CORE_CM_CLKSEL_CLKSEL_L3_MASK;
+			if (l3_div == CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED1 ||
+			    l3_div == CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED2) {
+				ddf_msg(LVL_NOTE, "L3 interface at %d.%d MHz",
+				    (freq / l3_div) / 1000,
+				    (freq / l3_div) % 1000);
+			} else {
+				ddf_msg(LVL_WARN,"L3 interface clock divisor is"
+				    " invalid: %d", l3_div);
+			}
+		} else {
+			ddf_msg(LVL_WARN, "DPLL3 frequency divisor and/or "
+			    "multiplier value invalid: %d %d %d",
+			    multiplier, divisor, divisor2);
+		}
+	} else {
+		ddf_msg(LVL_WARN, "CORE CLK in bypass mode, fruunig at SYS_CLK"
+		   " frreq of %d.%d MHz", base_freq / 1000, base_freq % 1000);
+	}
+
+	/* Set DPLL3 to automatic to save power */
+	pio_change_32(&device->cm.clocks->autoidle_pll,
+	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC,
+	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_MASK, 5);
+
+	/* DPLL4 provides peripheral domain clocks:
+	 * CAM_MCLK, EMU_PER_ALWON_CLK, DSS1_ALWON_FCLK, and 96M_ALWON_FCLK.
+	 * It uses SYS_CLK as reference clock and low frequency bypass.
+	 * 96M clock is used by McBSP[1,5], MMC[1,2,3], I2C[1,2,3], so
+	 * we can probably turn this off entirely (DSS is still non-functional).
+	 */
+	/* Set DPLL4 to automatic to save power */
+	pio_change_32(&device->cm.clocks->autoidle_pll,
+	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_AUTOMATIC,
+	    CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_MASK, 5);
+
+	/* DPLL5 provide peripheral domain clocks: 120M_FCLK.
+	 * It uses SYS_CLK as reference clock and low frequency bypass.
+	 * 120M clock is used by HS USB and USB TLL.
+	 */
+	// TODO setup DPLL5
+	if ((pio_read_32(&device->cm.clocks->clken2_pll)
+	        & CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK)
+	    != CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK) {
+		/* Compute divisors and multiplier
+		 * See AMDM37x TRM p. 300 for the formula */
+		// TODO: base_freq does not have to be rounded to Mhz
+		// (that's why I used KHz as unit).
+		const unsigned mult = 120;
+		const unsigned div = (base_freq / 1000) - 1;
+		const unsigned div2 = 1;
+		if ( ((base_freq % 1000) != 0) || (div > 127)) {
+			ddf_msg(LVL_ERROR, "Rounding error, or divisor to big "
+			    "freq: %d, div: %d", base_freq, div);
+			return;
+		};
+		assert(div <= 127);
+
+		/* Set multiplier */
+		pio_change_32(&device->cm.clocks->clksel4_pll,
+		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_CREATE(mult),
+		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_MASK, 10);
+
+		/* Set DPLL divisor */
+		pio_change_32(&device->cm.clocks->clksel4_pll,
+		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_CREATE(div),
+		    CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_MASK, 10);
+
+		/* Set output clock divisor */
+		pio_change_32(&device->cm.clocks->clksel5_pll,
+		    CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_CREATE(div2),
+		    CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_MASK, 10);
+
+		/* Start DPLL5 */
+		pio_change_32(&device->cm.clocks->clken2_pll,
+		    CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK,
+		    CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK, 10);
+
+	}
+	/* Set DPLL5 to automatic to save power */
+	pio_change_32(&device->cm.clocks->autoidle2_pll,
+	    CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_AUTOMATIC,
+	    CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_MASK, 5);
+}
+
+/** Enable/disable function and interface clocks for USBTLL and USBHOST.
+ * @param device Register map.
+ * @param on True to switch clocks on.
+ */
+void amdm37x_usb_clocks_set(amdm37x_t *device, bool enabled)
+{
+	if (enabled) {
+		/* Enable interface and function clock for USB TLL */
+		pio_set_32(&device->cm.core->fclken3,
+		    CORE_CM_FCLKEN3_EN_USBTLL_FLAG, 5);
+		pio_set_32(&device->cm.core->iclken3,
+		    CORE_CM_ICLKEN3_EN_USBTLL_FLAG, 5);
+
+		/* Enable interface and function clock for USB hosts */
+		pio_set_32(&device->cm.usbhost->fclken,
+		    USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG |
+		    USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG, 5);
+		pio_set_32(&device->cm.usbhost->iclken,
+		    USBHOST_CM_ICLKEN_EN_USBHOST, 5);
+#if 0
+		printf("DPLL5 (and everything else) should be on: %"
+		    PRIx32" %"PRIx32".\n",
+		    pio_read_32(&device->cm.clocks->idlest_ckgen),
+		    pio_read_32(&device->cm.clocks->idlest2_ckgen));
+#endif
+	} else {
+		/* Disable interface and function clock for USB hosts */
+		pio_clear_32(&device->cm.usbhost->iclken,
+		    USBHOST_CM_ICLKEN_EN_USBHOST, 5);
+		pio_clear_32(&device->cm.usbhost->fclken,
+		    USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG |
+		    USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG, 5);
+
+		/* Disable interface and function clock for USB TLL */
+		pio_clear_32(&device->cm.core->iclken3,
+		    CORE_CM_ICLKEN3_EN_USBTLL_FLAG, 5);
+		pio_clear_32(&device->cm.core->fclken3,
+		    CORE_CM_FCLKEN3_EN_USBTLL_FLAG, 5);
+	}
+}
+
+/** Initialize USB TLL port connections.
+ *
+ * Different modes are on page 3312 of the Manual Figure 22-34.
+ * Select mode than can operate in FS/LS.
+ */
+int amdm37x_usb_tll_init(amdm37x_t *device)
+{
+	/* Check access */
+	if (pio_read_32(&device->cm.core->idlest3) & CORE_CM_IDLEST3_ST_USBTLL_FLAG) {
+		ddf_msg(LVL_ERROR, "USB TLL is not accessible");
+		return EIO;
+	}
+
+	/* Reset USB TLL */
+	pio_set_32(&device->tll->sysconfig, TLL_SYSCONFIG_SOFTRESET_FLAG, 5);
+	ddf_msg(LVL_DEBUG2, "Waiting for USB TLL reset");
+	while (!(pio_read_32(&device->tll->sysstatus) & TLL_SYSSTATUS_RESET_DONE_FLAG));
+	ddf_msg(LVL_DEBUG, "USB TLL Reset done.");
+
+	/* Setup idle mode (smart idle) */
+	pio_change_32(&device->tll->sysconfig,
+	    TLL_SYSCONFIG_CLOCKACTIVITY_FLAG | TLL_SYSCONFIG_AUTOIDLE_FLAG |
+	    TLL_SYSCONFIG_SIDLE_MODE_SMART, TLL_SYSCONFIG_SIDLE_MODE_MASK, 5);
+
+	/* Smart idle for UHH */
+	pio_change_32(&device->uhh->sysconfig,
+	    UHH_SYSCONFIG_CLOCKACTIVITY_FLAG | UHH_SYSCONFIG_AUTOIDLE_FLAG |
+	    UHH_SYSCONFIG_SIDLE_MODE_SMART, UHH_SYSCONFIG_SIDLE_MODE_MASK, 5);
+
+	/* Set all ports to go through TLL(UTMI)
+	 * Direct connection can only work in HS mode */
+	pio_set_32(&device->uhh->hostconfig,
+	    UHH_HOSTCONFIG_P1_ULPI_BYPASS_FLAG |
+	    UHH_HOSTCONFIG_P2_ULPI_BYPASS_FLAG |
+	    UHH_HOSTCONFIG_P3_ULPI_BYPASS_FLAG, 5);
+
+	/* What is this? */
+	pio_set_32(&device->tll->shared_conf, TLL_SHARED_CONF_FCLK_IS_ON_FLAG, 5);
+
+	for (unsigned i = 0; i < 3; ++i) {
+		/* Serial mode is the only one capable of FS/LS operation.
+		 * Select FS/LS mode, no idea what the difference is
+		 * one of bidirectional modes might be good choice
+		 * 2 = 3pin bidi phy. */
+		pio_change_32(&device->tll->channel_conf[i],
+		    TLL_CHANNEL_CONF_CHANMODE_UTMI_SERIAL_MODE |
+		    TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_PHY,
+		    TLL_CHANNEL_CONF_CHANMODE_MASK |
+		    TLL_CHANNEL_CONF_FSLSMODE_MASK, 5);
+	}
+	return EOK;
+}
Index: uspace/drv/platform/amdm37x/amdm37x.h
===================================================================
--- uspace/drv/platform/amdm37x/amdm37x.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/amdm37x.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrv
+ * @{
+ */
+/** @file
+ * @brief AM/DM 37x device.
+ */
+#ifndef AMDM37x_H
+#define AMDM37x_H
+
+#include "uhh.h"
+#include "usbtll.h"
+
+#include "cm/core.h"
+#include "cm/clock_control.h"
+#include "cm/usbhost.h"
+#include "cm/mpu.h"
+#include "cm/iva2.h"
+
+#include "prm/clock_control.h"
+#include "prm/global_reg.h"
+
+#include <stdbool.h>
+
+typedef struct {
+	uhh_regs_t *uhh;
+	tll_regs_t *tll;
+	struct {
+		mpu_cm_regs_t *mpu;
+		iva2_cm_regs_t *iva2;
+		core_cm_regs_t *core;
+		clock_control_cm_regs_t *clocks;
+		usbhost_cm_regs_t *usbhost;
+	} cm;
+	struct {
+		clock_control_prm_regs_t *clocks;
+		global_reg_prm_regs_t *global;
+	} prm;
+} amdm37x_t;
+
+int amdm37x_init(amdm37x_t *device, bool trace_io);
+int amdm37x_usb_tll_init(amdm37x_t *device);
+void amdm37x_setup_dpll_on_autoidle(amdm37x_t *device);
+void amdm37x_usb_clocks_set(amdm37x_t *device, bool enabled);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/platform/amdm37x/amdm37x.ma
===================================================================
--- uspace/drv/platform/amdm37x/amdm37x.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/amdm37x.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+10 platform/beagleboardxm
Index: uspace/drv/platform/amdm37x/cm/clock_control.h
===================================================================
--- uspace/drv/platform/amdm37x/cm/clock_control.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/cm/clock_control.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvclockcontrolcm
+ * @{
+ */
+/** @file
+ * @brief Clock Control Clock Management IO register structure.
+ */
+#ifndef AMDM37x_CLOCK_CONTROL_CM_H
+#define AMDM37x_CLOCK_CONTROL_CM_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.485 */
+#define CLOCK_CONTROL_CM_BASE_ADDRESS  0x48004d00
+#define CLOCK_CONTROL_CM_SIZE  8192
+
+/** Clock control register map
+ *
+ * Periph DPLL == DPLL4
+ * Core DPLL == DPLL3
+ */
+typedef struct {
+	ioport32_t clken_pll;
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_EMU_PERIPH_FLAG   (1 << 31)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_CAM_FLAG   (1 << 30)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_DSS1_FLAG   (1 << 29)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_TV_FLAG   (1 << 28)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_96M_FLAG   (1 << 27)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_DRIFTGUARD_FLAG   (1 << 19)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_MASK   (0x7 << 16)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_LP_STOP   (0x1 << 16)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_PERIPH_DPLL_LOCK   (0x7 << 16)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_PWRDN_EMU_CORE_FLAG   (1 << 12)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LPMODE_FLAG   (1 << 10)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_DRIFTGUARD_FLAG   (1 << 3)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_MASK   (0x7)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LP_BYPASS   (0x5)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_FAST_RELOCK   (0x6)
+#define CLOCK_CONTROL_CM_CLKEN_PLL_EN_CORE_DPLL_LOCK   (0x7)
+
+	ioport32_t clken2_pll;
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LPMODE_FLAG   (1 << 10)
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_DRIFTGUARD_FLAG   (1 << 3)
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_MASK   (0x7)
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LP_STOP   (0x1)
+#define CLOCK_CONTROL_CM_CLKEN2_PLL_EN_PERIPH2_DPLL_LOCK   (0x7)
+
+	PADD32[6];
+
+	const ioport32_t idlest_ckgen;
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_EMU_PERIPH_CLK_FLAG   (1 << 13)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CAM_CLK_FLAG   (1 << 12)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_DSS1_CLK_FLAG   (1 << 11)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_TV_CLK_FLAG   (1 << 10)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_FUNC96M_CLK_FLAG   (1 << 9)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_EMU_CORE_CLK_FLAG   (1 << 8)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_54M_CLK_FLAG   (1 << 5)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_12M_CLK_FLAG   (1 << 4)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_48M_CLK_FLAG   (1 << 3)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_96M_CLK_FLAG   (1 << 2)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_PERIPH_CLK_FLAG   (1 << 1)
+#define CLOCK_CONTROL_CM_IDLEST_CKGEN_ST_CORE_CLK_FLAG   (1 << 0)
+
+	const ioport32_t idlest2_ckgen;
+#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_FUNC120M_CLK_FLAG   (1 << 3)
+#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_120M_CLK_FLAG   (1 << 1)
+#define CLOCK_CONTROL_CM_IDLEST2_CKGEN_ST_PERIPH2_CLK_FLAG   (1 << 0)
+
+	PADD32[2];
+
+	ioport32_t autoidle_pll;
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_MASK   (0x7 << 3)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_DISABLED   (0x0 << 3)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_PERIPH_DPLL_AUTOMATIC   (0x1 << 3)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_MASK   (0x7)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_DISABLED   (0x0)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC   (0x1)
+#define CLOCK_CONTROL_CM_AUTOIDLE_PLL_AUTO_CORE_DPLL_AUTOMATIC_BYPASS   (0x5)
+
+	ioport32_t autoidle2_pll;
+#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_MASK   (0x7)
+#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_DISABLED   (0x0)
+#define CLOCK_CONTROL_CM_AUTOIDLE2_PLL_AUTO_PERIPH2_DPLL_AUTOMATIC   (0x1)
+
+	PADD32[2];
+
+	ioport32_t clksel1_pll;
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_MASK   (0x1f << 27)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_CREATE(x)   (((x) & 0x1f) << 27)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_CLKOUT_DIV_GET(x)   (((x) >> 27) & 0x1f)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_MASK   (0x7ff << 16)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_CREATE(x)   (((x) & 0x7ff) << 16)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_MULT_GET(x)   (((x) >> 16) & 0x7ff)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_MASK   (0x7f << 8)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_CREATE(x)   (((x) & 0x7f) << 8)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_CORE_DPLL_DIV_GET(x)   (((x) >> 8) & 0x7f)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_96M_FLAG   (1 << 6)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_54M_FLAG   (1 << 5)
+#define CLOCK_CONTROL_CM_CLKSEL1_PLL_SOURCE_48M_FLAG   (1 << 3)
+
+	ioport32_t clksel2_pll;
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_SD_DIV_MASK   (0xff << 24)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_SD_DIV_(x)   (((x) & 0xff) << 24)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_MASK   (0x7 << 21)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_500   (0x2 << 21)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_DCO_SEL_1000   (0x4 << 21)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_MULT_MASK   (0xfff << 8)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_MULT(x)   (((x) & 0xfff) << 8)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_DIV_MASK   (0x7f)
+#define CLOCK_CONTROL_CM_CLKSEL2_PLL_PERIPH_DPLL_DIV(x)   ((x) & 0x7f)
+
+	ioport32_t clksel3_pll;
+#define CLOCK_CONTROL_CM_CLKSEL3_PLL_DIV_96M_MASK   (0xf)
+#define CLOCK_CONTROL_CM_CLKSEL3_PLL_DIV_96M(x)   ((x) & 0xf)
+
+	ioport32_t clksel4_pll;
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_MASK   (0x7ff << 8)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_CREATE(x)   (((x) & 0x7ff) << 8)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_MULT_GET(x)   (((x) >> 8) & 0x7ff)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_MASK   (0x7f)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_CREATE(x)   ((x) & 0x7f)
+#define CLOCK_CONTROL_CM_CLKSEL4_PLL_PERIPH2_DPLL_DIV_GET(x)   ((x) & 0x7f)
+
+	ioport32_t clksel5_pll;
+#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_MASK   (0x1f)
+#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_CREATE(x)   ((x) & 0x1f)
+#define CLOCK_CONTROL_CM_CLKSEL5_PLL_DIV120M_GET(x)   ((x) & 0x1f)
+} clock_control_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/platform/amdm37x/cm/core.h
===================================================================
--- uspace/drv/platform/amdm37x/cm/core.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/cm/core.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvcorecm
+ * @{
+ */
+/** @file
+ * @brief CORE Clock Management IO register structure.
+ */
+#ifndef AMDM37x_CORE_CM_H
+#define AMDM37x_CORE_CM_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.447 */
+#define CORE_CM_BASE_ADDRESS  0x48004a00
+#define CORE_CM_SIZE  8192
+
+typedef struct {
+	ioport32_t fclken1;
+#define CORE_CM_FCLKEN1_EN_MCBSP1_FLAG  (1 << 9)
+#define CORE_CM_FCLKEN1_EN_MCBSP5_FLAG  (1 << 10)
+#define CORE_CM_FCLKEN1_EN_GPT10_FLAG  (1 << 11)
+#define CORE_CM_FCLKEN1_EN_GPT11_FLAG  (1 << 12)
+#define CORE_CM_FCLKEN1_EN_UART1_FLAG  (1 << 13)
+#define CORE_CM_FCLKEN1_EN_UART2_FLAG  (1 << 14)
+#define CORE_CM_FCLKEN1_EN_I2C1_FLAG  (1 << 15)
+#define CORE_CM_FCLKEN1_EN_I2C2_FLAG  (1 << 16)
+#define CORE_CM_FCLKEN1_EN_I2C3_FLAG  (1 << 17)
+#define CORE_CM_FCLKEN1_EN_MCSPI1_FLAG  (1 << 18)
+#define CORE_CM_FCLKEN1_EN_MCSPI2_FLAG  (1 << 19)
+#define CORE_CM_FCLKEN1_EN_MCSPI3_FLAG  (1 << 20)
+#define CORE_CM_FCLKEN1_EN_MCSPI4_FLAG  (1 << 21)
+#define CORE_CM_FCLKEN1_EN_HDQ_FLAG  (1 << 22)
+#define CORE_CM_FCLKEN1_EN_MMC1_FLAG  (1 << 24)
+#define CORE_CM_FCLKEN1_EN_MMC2_FLAG  (1 << 25)
+#define CORE_CM_FCLKEN1_EN_MMC3_FLAG  (1 << 30)
+
+	PADD32;
+	ioport32_t fclken3;
+#define CORE_CM_FCLKEN3_EN_TS_FLAG  (1 << 1)
+#define CORE_CM_FCLKEN3_EN_USBTLL_FLAG  (1 << 2)
+
+	PADD32;
+	ioport32_t iclken1;
+#define CORE_CM_ICLKEN1_EN_SDRC_FLAG  (1 << 1)
+#define CORE_CM_ICLKEN1_EN_HSOTGUSB_FLAG  (1 << 4)
+#define CORE_CM_ICLKEN1_EN_SCMCTRL_FLAG  (1 << 6)
+#define CORE_CM_ICLKEN1_EN_MAILBOXES_FLAG  (1 << 7)
+#define CORE_CM_ICLKEN1_EN_MCBSP1_FLAG  (1 << 9)
+#define CORE_CM_ICLKEN1_EN_MCBSP5_FLAG  (1 << 10)
+#define CORE_CM_ICLKEN1_EN_GPT10_FLAG  (1 << 11)
+#define CORE_CM_ICLKEN1_EN_GPT11_FLAG  (1 << 12)
+#define CORE_CM_ICLKEN1_EN_UART1_FLAG  (1 << 13)
+#define CORE_CM_ICLKEN1_EN_UART2_FLAG  (1 << 14)
+#define CORE_CM_ICLKEN1_EN_I2C1_FLAG  (1 << 15)
+#define CORE_CM_ICLKEN1_EN_I2C2_FLAG  (1 << 16)
+#define CORE_CM_ICLKEN1_EN_I2C3_FLAG  (1 << 17)
+#define CORE_CM_ICLKEN1_EN_MCSPI1_FLAG  (1 << 18)
+#define CORE_CM_ICLKEN1_EN_MCSPI2_FLAG  (1 << 19)
+#define CORE_CM_ICLKEN1_EN_MCSPI3_FLAG  (1 << 20)
+#define CORE_CM_ICLKEN1_EN_MCSPI4_FLAG  (1 << 21)
+#define CORE_CM_ICLKEN1_EN_HDQ_FLAG  (1 << 22)
+#define CORE_CM_ICLKEN1_EN_MMC1_FLAG  (1 << 24)
+#define CORE_CM_ICLKEN1_EN_MMC2_FLAG  (1 << 25)
+#define CORE_CM_ICLKEN1_EN_ICR_FLAG  (1 << 29)
+#define CORE_CM_ICLKEN1_EN_MMC3_FLAG  (1 << 30)
+
+	ioport32_t reserved1;
+	ioport32_t iclken3;
+#define CORE_CM_ICLKEN3_EN_USBTLL_FLAG  (1 << 2)
+
+	PADD32;
+	const ioport32_t idlest1;
+#define CORE_CM_IDLEST1_ST_SDRC_FLAG  (1 << 1)
+#define CORE_CM_IDLEST1_ST_SDMA_FLAG  (1 << 2)
+#define CORE_CM_IDLEST1_ST_HSOTGUSB_STBY_FLAG  (1 << 4)
+#define CORE_CM_IDLEST1_ST_HSOTGUSB_IDLE_FLAG  (1 << 5)
+#define CORE_CM_IDLEST1_ST_SCMCTRL_FLAG  (1 << 6)
+#define CORE_CM_IDLEST1_ST_MAILBOXES_FLAG  (1 << 7)
+#define CORE_CM_IDLEST1_ST_MCBSP1_FLAG  (1 << 9)
+#define CORE_CM_IDLEST1_ST_MCBSP5_FLAG  (1 << 10)
+#define CORE_CM_IDLEST1_ST_GPT10_FLAG  (1 << 11)
+#define CORE_CM_IDLEST1_ST_GPT11_FLAG  (1 << 12)
+#define CORE_CM_IDLEST1_ST_UART1_FLAG  (1 << 13)
+#define CORE_CM_IDLEST1_ST_UART2_FLAG  (1 << 14)
+#define CORE_CM_IDLEST1_ST_I2C1_FLAG  (1 << 15)
+#define CORE_CM_IDLEST1_ST_I2C2_FLAG  (1 << 16)
+#define CORE_CM_IDLEST1_ST_I2C3_FLAG  (1 << 17)
+#define CORE_CM_IDLEST1_ST_MCSPI1_FLAG  (1 << 18)
+#define CORE_CM_IDLEST1_ST_MCSPI2_FLAG  (1 << 19)
+#define CORE_CM_IDLEST1_ST_MCSPI3_FLAG  (1 << 20)
+#define CORE_CM_IDLEST1_ST_MCSPI4_FLAG  (1 << 21)
+#define CORE_CM_IDLEST1_ST_HDQ_FLAG  (1 << 22)
+#define CORE_CM_IDLEST1_ST_MMC1_FLAG  (1 << 24)
+#define CORE_CM_IDLEST1_ST_MMC2_FLAG  (1 << 25)
+#define CORE_CM_IDLEST1_ST_ICR_FLAG  (1 << 29)
+#define CORE_CM_IDLEST1_ST_MMC3_FLAG  (1 << 30)
+
+	const ioport32_t reserved2;
+	const ioport32_t idlest3;
+#define CORE_CM_IDLEST3_ST_USBTLL_FLAG  (1 << 2)
+
+	PADD32;
+	ioport32_t autoidle1;
+#define CORE_CM_AUTOIDLE1_AUTO_HSOTGUSB_FLAG  (1 << 4)
+#define CORE_CM_AUTOIDLE1_AUTO_SCMCTRL_FLAG  (1 << 6)
+#define CORE_CM_AUTOIDLE1_AUTO_MAILBOXES_FLAG  (1 << 7)
+#define CORE_CM_AUTOIDLE1_AUTO_MCBSP1_FLAG  (1 << 9)
+#define CORE_CM_AUTOIDLE1_AUTO_MCBSP5_FLAG  (1 << 10)
+#define CORE_CM_AUTOIDLE1_AUTO_GPT10_FLAG  (1 << 11)
+#define CORE_CM_AUTOIDLE1_AUTO_GPT11_FLAG  (1 << 12)
+#define CORE_CM_AUTOIDLE1_AUTO_UART1_FLAG  (1 << 13)
+#define CORE_CM_AUTOIDLE1_AUTO_UART2_FLAG  (1 << 14)
+#define CORE_CM_AUTOIDLE1_AUTO_I2C1_FLAG  (1 << 15)
+#define CORE_CM_AUTOIDLE1_AUTO_I2C2_FLAG  (1 << 16)
+#define CORE_CM_AUTOIDLE1_AUTO_I2C3_FLAG  (1 << 17)
+#define CORE_CM_AUTOIDLE1_AUTO_MCSPI1_FLAG  (1 << 18)
+#define CORE_CM_AUTOIDLE1_AUTO_MCSPI2_FLAG  (1 << 19)
+#define CORE_CM_AUTOIDLE1_AUTO_MCSPI3_FLAG  (1 << 20)
+#define CORE_CM_AUTOIDLE1_AUTO_MCSPI4_FLAG  (1 << 21)
+#define CORE_CM_AUTOIDLE1_AUTO_HDQ_FLAG  (1 << 22)
+#define CORE_CM_AUTOIDLE1_AUTO_MMC1_FLAG  (1 << 24)
+#define CORE_CM_AUTOIDLE1_AUTO_MMC2_FLAG  (1 << 25)
+#define CORE_CM_AUTOIDLE1_AUTO_ICR_FLAG  (1 << 29)
+#define CORE_CM_AUTOIDLE1_AUTO_MMC3_FLAG  (1 << 30)
+
+	ioport32_t reserved3;
+	ioport32_t autoidle3;
+#define CORE_CM_AUTOIDLE3_AUTO_USBTLL_FLAG  (1 << 2)
+
+	PADD32;
+	ioport32_t clksel;
+#define CORE_CM_CLKSEL_CLKSEL_L3_MASK  (0x3 << 0)
+#define CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED1  (0x1 << 0)
+#define CORE_CM_CLKSEL_CLKSEL_L3_DIVIDED2  (0x2 << 0)
+#define CORE_CM_CLKSEL_CLKSEL_L4_MASK  (0x3 << 2)
+#define CORE_CM_CLKSEL_CLKSEL_L4_DIVIDED1  (0x1 << 2)
+#define CORE_CM_CLKSEL_CLKSEL_L4_DIVIDED2  (0x2 << 2)
+#define CORE_CM_CLKSEL_CLKSEL_96M_MASK  (0x3 << 12)
+#define CORE_CM_CLKSEL_CLKSEL_96M_DIVIDED1  (0x1 << 12)
+#define CORE_CM_CLKSEL_CLKSEL_96M_DIVIDED2  (0x2 << 12)
+#define CORE_CM_CLKSEL_CLKSEL_GPT10_FLAG (1 << 6)
+#define CORE_CM_CLKSEL_CLKSEL_GPT11_FLAG (1 << 7)
+
+	PADD32;
+	ioport32_t clkstctrl;
+#define CORE_CM_CLKCTRL_CLKCTRL_L3_MASK  (0x3 << 0)
+#define CORE_CM_CLKCTRL_CLKCTRL_L3_AUTO_EN  (0x0 << 0)
+#define CORE_CM_CLKCTRL_CLKCTRL_L3_AUTO_DIS  (0x3 << 0)
+#define CORE_CM_CLKCTRL_CLKCTRL_L4_MASK  (0x3 << 2)
+#define CORE_CM_CLKCTRL_CLKCTRL_L4_AUTO_EN  (0x0 << 2)
+#define CORE_CM_CLKCTRL_CLKCTRL_L4_AUTO_DIS  (0x3 << 2)
+
+	const ioport32_t clkstst;
+#define CORE_CM_CLKSTST_CLKACTIVITY_L3_FLAG  (1 << 0)
+#define CORE_CM_CLKSTST_CLKACTIVITY_L4_FLAG  (1 << 1)
+} core_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/platform/amdm37x/cm/iva2.h
===================================================================
--- uspace/drv/platform/amdm37x/cm/iva2.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/cm/iva2.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvcm
+ * @{
+ */
+/** @file
+ * @brief MPU Clock Management IO register structure.
+ */
+#ifndef AMDM37x_IVA2_CM_H
+#define AMDM37x_IVA2_CM_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.446 */
+#define IVA2_CM_BASE_ADDRESS  0x48004000
+#define IVA2_CM_SIZE  8192
+
+typedef struct {
+	ioport32_t fclken;
+#define IVA2_CM_FCLKEN_EN_IVA2_FLAG   (1 << 0)
+
+	ioport32_t clken_pll;
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_LP_MODE_FLAG   (1 << 10)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_DRIFTGUARD   (1 << 3)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_MASK   (0x7)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LP_STOP   (0x1)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LP_BYPASS   (0x5)
+#define IVA2_CM_CLKEN_PLL_EN_IVA2_DPLL_EN_IVA2_DPLL_LOCKED   (0x7)
+
+	PADD32[6];
+	const ioport32_t idlest;
+#define IVA2_CM_IDLEST_ST_IVA2_STANDBY_FLAG   (1 << 0)
+
+	const ioport32_t idlest_pll;
+#define IVA2_CM_IDLEST_PLL_ST_IVA2_CLK_LOCKED_FLAG   (1 << 0)
+
+	PADD32[3];
+	ioport32_t autoidle_pll;
+#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_MASK   (0x7)
+#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_DISABLED   (0x0)
+#define IVA2_CM_AUTOIDLE_PLL_AUTO_IVA2_DPLL_ENABLED   (0x1)
+
+	PADD32[2];
+	ioport32_t clksel1_pll;
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_MASK   (0x7 << 19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_SHIFT   (19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_VAL(x)   ((x >> 19) & 0x7)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_1   (0x1 << 19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_2   (0x2 << 19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_CLK_SRC_CORE_DIV_4   (0x4 << 19)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_MULT_MASK   (0x7ff << 8)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_MULT_SHIFT   (8)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_DIV_MASK  (0x7f << 0)
+#define IVA2_CM_CLKSEL1_PLL_IVA2_DPLL_DIV_SHIFT  (0)
+
+	ioport32_t clksel2_pll;
+#define IVA2_CM_CLKSEL2_PLL_IVA2_DPLL_CLKOUT_DIV_MASK   (0x1f)
+
+	ioport32_t clkstctrl;
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_MASK   (0x3)
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_DISABLED   (0x0)
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_START_SLEEP   (0x2)
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_START_WAKEUP   (0x2)
+#define IVA2_CM_CLKSCTRL_CLKTRCTRL_IVA2_AUTOMATIC   (0x3)
+
+	const ioport32_t clkstst;
+#define IVA2_CM_CLKSTST_CLKACTIVITY_IVA2_ACTIVE_FLAG   (1 << 0)
+
+} iva2_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/platform/amdm37x/cm/mpu.h
===================================================================
--- uspace/drv/platform/amdm37x/cm/mpu.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/cm/mpu.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvcm
+ * @{
+ */
+/** @file
+ * @brief MPU Clock Management IO register structure.
+ */
+#ifndef AMDM37x_MPU_CM_H
+#define AMDM37x_MPU_CM_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.455 */
+#define MPU_CM_BASE_ADDRESS  0x48004900
+#define MPU_CM_SIZE  8192
+
+typedef struct {
+	PADD32;
+	ioport32_t clken_pll;
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_LP_MODE_FLAG   (1 << 10)
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_DRIFTGUARD   (1 << 3)
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_MASK   (0x7)
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_LP_BYPASS   (0x5)
+#define MPU_CM_CLKEN_PLL_EN_MPU_DPLL_EN_MPU_DPLL_LOCKED   (0x7)
+
+	PADD32[6];
+	const ioport32_t idlest;
+#define MPU_CM_IDLEST_ST_MPU_STANDBY_FLAG   (1 << 0)
+
+	const ioport32_t idlest_pll;
+#define MPU_CM_IDLEST_PLL_ST_MPU_CLK_LOCKED_FLAG   (1 << 0)
+
+	PADD32[3];
+	ioport32_t autoidle_pll;
+#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_MASK   (0x7)
+#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_DISABLED   (0x0)
+#define MPU_CM_AUTOIDLE_PLL_AUTO_MPU_DPLL_ENABLED   (0x1)
+
+	PADD32[2];
+	ioport32_t clksel1_pll;
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_MASK   (0x7 << 19)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_SHIFT   (19)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_VAL(x)   ((x >> 19) & 0x7)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_1   (0x1 << 19)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_2   (0x2 << 19)
+#define MPU_CM_CLKSEL1_PLL_MPU_CLK_SRC_CORE_DIV_4   (0x4 << 19)
+#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_MASK   (0x7ff << 8)
+#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_MULT_SHIFT   (8)
+#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_MASK  (0x7f << 0)
+#define MPU_CM_CLKSEL1_PLL_MPU_DPLL_DIV_SHIFT  (0)
+
+	ioport32_t clksel2_pll;
+#define MPU_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV_MASK   (0x1f)
+
+	ioport32_t clkstctrl;
+#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_MASK   (0x3)
+#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_DISABLED   (0x0)
+#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_START_WAKEUP   (0x2)
+#define MPU_CM_CLKSCTRL_CLKTRCTRL_MPU_AUTOMATIC   (0x3)
+
+	const ioport32_t clkstst;
+#define MPU_CM_CLKSTST_CLKACTIVITY_MPU_ACTIVE_FLAG   (1 << 0)
+
+} mpu_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/platform/amdm37x/cm/usbhost.h
===================================================================
--- uspace/drv/platform/amdm37x/cm/usbhost.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/cm/usbhost.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvusbhostcm
+ * @{
+ */
+/** @file
+ * @brief USBHOST Clock Management IO register structure.
+ */
+#ifndef AMDM37x_USBHOST_CM_H
+#define AMDM37x_USBHOST_CM_H
+#include <macros.h>
+#include <sys/types.h>
+
+/* AM/DM37x TRM p.447 */
+#define USBHOST_CM_BASE_ADDRESS  0x48005400
+#define USBHOST_CM_SIZE  8192
+
+typedef struct {
+	ioport32_t fclken;
+#define USBHOST_CM_FCLKEN_EN_USBHOST1_FLAG  (1 << 0)
+#define USBHOST_CM_FCLKEN_EN_USBHOST2_FLAG  (1 << 1)
+
+	PADD32[3];
+	ioport32_t iclken;
+#define USBHOST_CM_ICLKEN_EN_USBHOST  (1 << 0)
+
+	PADD32[3];
+	const ioport32_t idlest;
+#define USBHOST_CM_IDLEST_ST_USBHOST_STDBY_FLAG  (1 << 0)
+#define USBHOST_CM_IDLEST_ST_USBHOST_IDLE_FLAG  (1 << 1)
+
+	PADD32[3];
+	ioport32_t autoidle;
+#define USBHOST_CM_AUTOIDLE_AUTO_USBHOST_FLAG  (1 << 0)
+
+	PADD32[4];
+	ioport32_t sleepdep;
+#define USBHOST_CM_SLEEPDEP_EN_MPU_FLAG  (1 << 1)
+#define USBHOST_CM_SLEEPDEP_EN_IVA2_FLAG  (1 << 2)
+
+	ioport32_t clkstctrl;
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_MASK  (0x3 << 0)
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_AUTO_DIS  (0x0 << 0)
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_SUPERVISED_SLEEP  (0x1 << 0)
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_SUPERVISED_WAKEUP  (0x2 << 0)
+#define USBHOST_CM_CLKSTCTRL_CLKSTCTRL_USBHOST_AUTO_EN  (0x3 << 0)
+
+	ioport32_t clkstst;
+#define USBHOST_CM_CLKSTCTRL_CLKSTST_CLKACTIVITY_USBHOST  (1 << 0)
+} usbhost_cm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/platform/amdm37x/main.c
===================================================================
--- uspace/drv/platform/amdm37x/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @defgroup amdm37x TI AM/DM37x platform driver.
+ * @brief HelenOS TI AM/DM37x platform driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#define DEBUG_CM 0
+
+#include <ddf/log.h>
+#include <errno.h>
+#include <ops/hw_res.h>
+#include <stdio.h>
+
+#include "amdm37x.h"
+
+#define NAME  "amdm37x"
+
+typedef struct {
+	const char *name;
+	match_id_t match_id;
+	hw_resource_list_t hw_resources;
+} amdm37x_fun_t;
+
+/* See amdm37x TRM page 3316 for these values */
+#define OHCI_BASE_ADDRESS   0x48064400
+#define OHCI_SIZE   1024
+#define EHCI_BASE_ADDRESS   0x48064800
+#define EHCI_SIZE   1024
+
+/* See amdm37x TRM page 1813 for these values */
+#define DSS_BASE_ADDRESS   0x48050000
+#define DSS_SIZE   512
+#define DISPC_BASE_ADDRESS   0x48050400
+#define DISPC_SIZE   1024
+#define VIDEO_ENC_BASE_ADDRESS   0x48050C00
+#define VIDEO_ENC_SIZE   256
+
+
+static hw_resource_t ohci_res[] = {
+	{
+		.type = MEM_RANGE,
+		.res.io_range = {
+			.address = OHCI_BASE_ADDRESS,
+			.size = OHCI_SIZE,
+			.endianness = LITTLE_ENDIAN
+		},
+	},
+	{
+		.type = INTERRUPT,
+		.res.interrupt = { .irq = 76 },
+	},
+};
+
+static hw_resource_t ehci_res[] = {
+	{
+		.type = MEM_RANGE,
+		/* See amdm37x TRM page. 3316 for these values */
+		.res.io_range = {
+			.address = EHCI_BASE_ADDRESS,
+			.size = EHCI_SIZE,
+			.endianness = LITTLE_ENDIAN
+		},
+	},
+	{
+		.type = INTERRUPT,
+		.res.interrupt = { .irq = 77 },
+	},
+};
+
+static hw_resource_t disp_res[] = {
+	{
+		.type = MEM_RANGE,
+		.res.io_range = {
+			.address = DSS_BASE_ADDRESS,
+			.size = DSS_SIZE,
+			.endianness = LITTLE_ENDIAN
+		},
+	},
+	{
+		.type = MEM_RANGE,
+		.res.io_range = {
+			.address = DISPC_BASE_ADDRESS,
+			.size = DISPC_SIZE,
+			.endianness = LITTLE_ENDIAN
+		},
+	},
+	{
+		.type = MEM_RANGE,
+		.res.io_range = {
+			.address = VIDEO_ENC_BASE_ADDRESS,
+			.size = VIDEO_ENC_SIZE,
+			.endianness = LITTLE_ENDIAN
+		},
+	},
+	{
+		.type = INTERRUPT,
+		.res.interrupt = { .irq = 25 },
+	},
+};
+
+static const amdm37x_fun_t amdm37x_funcs[] = {
+{
+	.name = "ohci",
+	.match_id = { .id = "usb/host=ohci", .score = 90 },
+	.hw_resources = { .resources = ohci_res, .count = ARRAY_SIZE(ohci_res) }
+},
+{
+	.name = "ehci",
+	.match_id = { .id = "usb/host=ehci", .score = 90 },
+	.hw_resources = { .resources = ehci_res, .count = ARRAY_SIZE(ehci_res) }
+},
+{
+	.name = "fb",
+	.match_id = { .id = "amdm37x&dispc", .score = 90 },
+	.hw_resources = { .resources = disp_res, .count = ARRAY_SIZE(disp_res) }
+},
+};
+
+
+static hw_resource_list_t *amdm37x_get_resources(ddf_fun_t *fnode);
+static bool amdm37x_enable_interrupt(ddf_fun_t *fun);
+
+static hw_res_ops_t fun_hw_res_ops = {
+	.get_resource_list = &amdm37x_get_resources,
+	.enable_interrupt = &amdm37x_enable_interrupt,
+};
+
+static ddf_dev_ops_t amdm37x_fun_ops = {
+	.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops
+};
+
+static int amdm37x_add_fun(ddf_dev_t *dev, const amdm37x_fun_t *fun)
+{
+	assert(dev);
+	assert(fun);
+
+	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", fun->name);
+
+	/* Create new device function. */
+	ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, fun->name);
+	if (fnode == NULL)
+		return ENOMEM;
+	
+	/* Add match id */
+	int ret = ddf_fun_add_match_id(fnode,
+	    fun->match_id.id, fun->match_id.score);
+	if (ret != EOK) {
+		ddf_fun_destroy(fnode);
+		return ret;
+	}
+	
+	/* Alloc needed data */
+	amdm37x_fun_t *rf =
+	    ddf_fun_data_alloc(fnode, sizeof(amdm37x_fun_t));
+	if (!rf) {
+		ddf_fun_destroy(fnode);
+		return ENOMEM;
+	}
+	*rf = *fun;
+
+	/* Set provided operations to the device. */
+	ddf_fun_set_ops(fnode, &amdm37x_fun_ops);
+	
+	/* Register function. */
+	ret = ddf_fun_bind(fnode);
+	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", fun->name);
+		ddf_fun_destroy(fnode);
+		return ret;
+	}
+	
+	return EOK;
+}
+
+/** Add the root device.
+ *
+ * @param dev Device which is root of the whole device tree
+ *            (both of HW and pseudo devices).
+ *
+ * @return Zero on success, negative error number otherwise.
+ *
+ */
+static int amdm37x_dev_add(ddf_dev_t *dev)
+{
+	assert(dev);
+	amdm37x_t *device = ddf_dev_data_alloc(dev, sizeof(amdm37x_t));
+	if (!device)
+		return ENOMEM;
+	int ret = amdm37x_init(device, DEBUG_CM);
+	if (ret != EOK) {
+		ddf_msg(LVL_FATAL, "Failed to setup hw access!.\n");
+		return ret;
+	}
+
+	/* Set dplls to ON and automatic */
+	amdm37x_setup_dpll_on_autoidle(device);
+
+	/* Enable function and interface clocks */
+	amdm37x_usb_clocks_set(device, true);
+
+	/* Init TLL */
+	ret = amdm37x_usb_tll_init(device);
+	if (ret != EOK) {
+		ddf_msg(LVL_FATAL, "Failed to init USB TLL!.\n");
+		amdm37x_usb_clocks_set(device, false);
+		return ret;
+	}
+
+	/* Register functions */
+	for (unsigned i = 0; i < ARRAY_SIZE(amdm37x_funcs); ++i) {
+		if (amdm37x_add_fun(dev, &amdm37x_funcs[i]) != EOK)
+			ddf_msg(LVL_ERROR, "Failed to add %s function for "
+			    "BeagleBoard-xM platform.", amdm37x_funcs[i].name);
+	}
+	return EOK;
+}
+
+/** The root device driver's standard operations. */
+static driver_ops_t amdm37x_ops = {
+	.dev_add = &amdm37x_dev_add
+};
+
+/** The root device driver structure. */
+static driver_t amdm37x_driver = {
+	.name = NAME,
+	.driver_ops = &amdm37x_ops
+};
+
+static hw_resource_list_t * amdm37x_get_resources(ddf_fun_t *fnode)
+{
+	amdm37x_fun_t *fun = ddf_fun_data_get(fnode);
+	assert(fun != NULL);
+	return &fun->hw_resources;
+}
+
+static bool amdm37x_enable_interrupt(ddf_fun_t *fun)
+{
+	//TODO: Implement
+	return false;
+}
+
+int main(int argc, char *argv[])
+{
+	printf("%s: HelenOS AM/DM37x(OMAP37x) platform driver\n", NAME);
+	ddf_log_init(NAME);
+	return ddf_driver_main(&amdm37x_driver);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/platform/amdm37x/prm/clock_control.h
===================================================================
--- uspace/drv/platform/amdm37x/prm/clock_control.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/prm/clock_control.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvprm
+ * @{
+ */
+/** @file
+ * @brief Clock Control Clock Management IO register structure.
+ */
+#ifndef AMDM37X_PRM_CLOCK_CONTROL_H
+#define AMDM37X_PRM_CLOCK_CONTROL_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.536 and p.589 */
+#define CLOCK_CONTROL_PRM_BASE_ADDRESS  0x48306d00
+#define CLOCK_CONTROL_PRM_SIZE  8192
+
+/** Clock control PRM register map
+ */
+typedef struct {
+	PADD32[16];
+	ioport32_t clksel;
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_MASK   (0x7)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_12M   (0x0)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_13M   (0x1)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_19_2M   (0x2)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_26M   (0x3)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_38_4M   (0x4)
+#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_16_8M   (0x5)
+
+	PADD32[12];
+	ioport32_t clkout_ctrl;
+#define CLOCK_CONTROL_PRM_CLKOUT_CTRL_CLKOUOUT_EN_FLAG   (1 << 7)
+
+} clock_control_prm_regs_t;
+
+static inline unsigned sys_clk_freq_kHz(unsigned reg_val)
+{
+	switch(reg_val)
+	{
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_12M: return 12000;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_13M: return 13000;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_19_2M: return 19200;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_26M: return 26000;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_38_4M: return 38400;
+	case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_16_8M: return 16800;
+	}
+	return 0;
+}
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/platform/amdm37x/prm/global_reg.h
===================================================================
--- uspace/drv/platform/amdm37x/prm/global_reg.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/prm/global_reg.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvprm
+ * @{
+ */
+/** @file
+ * @brief Clock Control Clock Management IO register structure.
+ */
+#ifndef AMDM37X_PRM_GLOBAL_REG_H
+#define AMDM37X_PRM_GLOBAL_REG_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.536 and p.615 */
+#define GLOBAL_REG_PRM_BASE_ADDRESS  0x48307200
+#define GLOBAL_REG_PRM_SIZE  65536
+
+/** Global Reg PRM register map
+ */
+typedef struct {
+	PADD32[8];
+	struct {
+		ioport32_t smps_sa;
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_MASK   (0x7f << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_CREATE(x)   (((x) & 0x7f) << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA0_GET(r)   (r & 0x7f)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_MASK   (0x7f << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_CREATE(x)   (((x) & 0x7f) << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_SA_SA1_GET(r)   (((r) >> 16 ) & 0x7f)
+
+		ioport32_t smps_vol_ra;
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_CREATE(x)   (((x) & 0xff) << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA0_GET(r)   (r & 0xff)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_VOL_RA_VOLRA1_GET(r)   (((r) >> 16 ) & 0xff)
+
+		ioport32_t smps_cmd_ra;
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_CREATE(x)   (((x) & 0xff) << 0)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA0_GET(r)   (r & 0xff)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VC_SMPS_CMD_RA_CMDRA1_GET(r)   (((r) >> 16 ) & 0xff)
+
+		ioport32_t cmd_val_0;
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ON_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_ONLP_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_RET_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_0_OFF_GET(r)   (((x) >> 24) & 0xff)
+
+		ioport32_t cmd_val_1;
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ON_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_ONLP_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_RET_GET(r)   (((x) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VC_CMD_VAL_1_OFF_GET(r)   (((x) >> 24) & 0xff)
+
+		ioport32_t ch_conf;
+#define GLOBAL_REG_PRM_VC_CH_CONF_CMD1_FLAG   (1 << 20)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RACEN1_FLAG   (1 << 19)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RAC1_FLAG   (1 << 18)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RAV1_FLAG   (1 << 17)
+#define GLOBAL_REG_PRM_VC_CH_CONF_SA1_FLAG   (1 << 16)
+#define GLOBAL_REG_PRM_VC_CH_CONF_CMD0_FLAG   (1 << 4)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RACEN0_FLAG   (1 << 3)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RAC0_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_VC_CH_CONF_RAV0_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_VC_CH_CONF_SA0_FLAG   (1 << 0)
+
+		ioport32_t i2c_cfg;
+#define GLOBAL_REG_PRM_VC_I2C_CFG_HSMASTER_FLAG   (1 << 5)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_SREN_FLAG   (1 << 4)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_HSEN_FLAG   (1 << 3)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_MASK   (0x3 << 0)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_CREATE(x)   ((x) & 0x3)
+#define GLOBAL_REG_PRM_VC_I2C_CFG_MCODE_GET(r)   ((r) & 0x3)
+
+		ioport32_t bypass_val;
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_VALID_FLAG   (1 << 24)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_DATA_GET(r)   (((r) >> 16) & 0xff)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_MASK   (0xff << 8)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_CREATE(x)   (((x) & 0xff) << 8)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_REGADDR_GET(r)   (((r) >> 8) & 0xff)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_MASK   (0x7f << 0)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_CREATE(x)   (((x) & 0x7f) << 0)
+#define GLOBAL_REG_PRM_VC_BYPASS_VAL_SLAVEADDR_GET(r)   (((r) >> 0) & 0x7f)
+	} vc;
+
+	PADD32[4];
+	ioport32_t rstctrl;
+#define GLOBAL_REG_PRM_RSTCTRL_RST_DPLL3_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_RSTCTRL_RST_GS_FLAG   (1 << 1)
+
+	ioport32_t rsttime;
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_MASK   (0x1f << 8)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_CREATE(x)   (((x) & 0x1f) << 8)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME2_GET(r)   (((r) >> 8) & 0x1f)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_CREATE(x)   (((x) & 0xff) << 0)
+#define GLOBAL_REG_PRM_RSTTIME_RSTTIME1_GET(r)   (((r) >> 0) & 0xff)
+
+	ioport32_t rstst;
+#define GLOBAL_REG_PRM_RSTST_ICECRUSHER_RST_FLAG   (1 << 10)
+#define GLOBAL_REG_PRM_RSTST_ICEPICK_RST_FLAG   (1 << 9)
+#define GLOBAL_REG_PRM_RSTST_VDD2_VOLTAGE_MGR_RST_FLAG   (1 << 8)
+#define GLOBAL_REG_PRM_RSTST_VDD1_VOLTAGE_MGR_RST_FLAG   (1 << 7)
+#define GLOBAL_REG_PRM_RSTST_EXTERNAL_WARM_REST_FLAG   (1 << 6)
+#define GLOBAL_REG_PRM_RSTST_MPU_WD_RST_FLAG   (1 << 4)
+#define GLOBAL_REG_PRM_RSTST_GLOBAL_SW_RST_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_RSTST_GLOABL_COLD_RST_FLAG   (1 << 0)
+
+	PADD32;
+	ioport32_t volctrl;
+#define GLOBAL_REG_PRM_VOLCTRL_SEL_VMODE_FLAG   (1 << 4)
+#define GLOBAL_REG_PRM_VOLCTRL_SEL_OFF_FLAG   (1 << 3)
+#define GLOBAL_REG_PRM_VOLCTRL_AUTO_OFF_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_VOLCTRL_AUTO_RET_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_VOLCTRL_AUTO_SLEEP_FLAG   (1 << 0)
+
+	ioport32_t sram_pcharge;
+#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_MASK   (0xff)
+#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_CREATE(x)   ((x) & 0xff)
+#define GLOBAL_REG_PRM_SRAM_PCHARGE_PCHARGE_TIME_GET(r)   ((r) & 0xff)
+
+	PADD32[2];
+	ioport32_t clksrc_ctrl;
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_DPLL4_CLKINP_DIV_65_FLAG   (1 << 8)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_MASK   (0x3 << 6)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_1   (0x1 << 6)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_2   (0x2 << 6)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKDIV_GET(r)   (((r) >> 6) & 0x3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_MASK   (0x3 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_ON   (0x0 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_SLEEP   (0x1 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_RET   (0x2 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_OFF   (0x3 << 3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_AUTOEXTCLKMODE_GET(r)   (((r) >> 3) & 0x3)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_MASK   (0x3 << 0)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_BYPASS   (0x0 << 0)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_OSCILLATOR   (0x1 << 0)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_UNKNOWN   (0x3 << 0)
+#define GLOBAL_REG_PRM_CLKSRC_CTRL_SYSCLKSEL_GET(r)   (((r) >> 0) & 0x3)
+
+	PADD32[3];
+	const ioport32_t obs;
+#define GLOBAL_REG_PRM_OBS_OBS_BUS_MASK   (0x3ff)
+
+	PADD32[3];
+	ioport32_t voltsetup1;
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME2_GET(r)   (((r) >> 16) & 0xff)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_CREATE(x)   (((x) & 0xff) << 0)
+#define GLOBAL_REG_PRM_VOLTSETUP1_SETUPTIME1_GET(r)   (((r) >> 0) & 0xff)
+
+	ioport32_t voltoffset;
+#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_MASK   (0xffff << 0)
+#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_CREATE(x)   (((x) & 0xffff) << 0)
+#define GLOBAL_REG_PRM_VOLTOFFSET_OFFSET_TIME_GET(r)   (((r) >> 0) & 0xffff)
+
+	ioport32_t clksetup;
+#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_MASK   (0xffff << 0)
+#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_CREATE(x)   (((x) & 0xffff) << 0)
+#define GLOBAL_REG_PRM_CLKSETUP_SETUP_TIME_GET(r)   (((r) >> 0) & 0xffff)
+
+	ioport32_t polctrl;
+#define GLOBAL_REG_PRM_POLCTRL_OFFMODE_POL_FLAG   (1 << 3)
+#define GLOBAL_REG_PRM_POLCTRL_CLKOUT_POL_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_POLCTRL_CLKREG_POL_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_POLCTRL_EXTVOL_POL_FLAG   (1 << 0)
+
+	ioport32_t voltsetup2;
+#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_MASK   (0xffff << 0)
+#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_CREATE(x)   (((x) & 0xffff) << 0)
+#define GLOBAL_REG_PRM_VOLTSETUP2_OFFMODESETUPTIME_GET(r)   (((r) >> 0) & 0xffff)
+
+	PADD32[3];
+	struct {
+		ioport32_t config;
+#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_CREATE(x)   (((x) & 0xff) << 24)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERROROFFSET_GET(r)   (((r) >> 0xff << 24)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_CREATE(x)   (((x) & 0xff) << 16)
+#define GLOBAL_REG_PRM_VP_CONFIG_ERRORGAIN_GET(r)   (((r) >> 0xff << 16)
+#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_MASK   (0xff << 8)
+#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_CREATE(x)   (((x) & 0xff) << 8)
+#define GLOBAL_REG_PRM_VP_CONFIG_INITVOLTAGE_GET(r)   (((r) >> 0xff << 8)
+#define GLOBAL_REG_PRM_VP_CONFIG_TIMEOUTEN_FLAG    (1 << 3)
+#define GLOBAL_REG_PRM_VP_CONFIG_INITVDD_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_VP_CONFIG_FORCEUPDATE_FLAG   (1 << 1)
+#define GLOBAL_REG_PRM_VP_CONFIG_VPENABLE_FLAG   (1 << 0)
+
+		ioport32_t vstepmin;
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_MASK   (0xffff << 8)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_CREATE(x)   (((x)0xffff << 8)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_SMPSWAITTIMEMIN_GET(r)   (((r) >> 8) & 0xffff)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_CREATE(x)   (((x)0xff << 0)
+#define GLOBAL_REG_PRM_VP_VSTEPMIN_VSTEPMIN_GET(r)   (((r) >> 0) & 0xff)
+
+		ioport32_t vstepmax;
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_MASK   (0xffff << 8)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_CREATE(x)   (((x)0xffff << 8)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_SMPSWAITTIMEMIN_GET(r)   (((r) >> 8) & 0xffff)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_MASK   (0xff << 0)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_CREATE(x)   (((x)0xff << 0)
+#define GLOBAL_REG_PRM_VP_VSTEPMAX_VSTEPMIN_GET(r)   (((r) >> 0) & 0xff)
+
+		ioport32_t vlimitto;
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_MASK   (0xff << 24)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_CREATE(x)   (((x)0xff << 24)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMAX_GET(r)   (((r) >> 24) & 0xff)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_MASK   (0xff << 16)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_CREATE(x)   (((x)0xff << 16)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_VDDMIN_GET(r)   (((r) >> 16) & 0xff)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_MASK   (0xffff << 0)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_CREATE(x)   (((x)0xffff << 0)
+#define GLOBAL_REG_PRM_VP_VLIMITTO_TIMEOUT_GET(r)   (((r) >> 0) & 0xffff)
+
+		const ioport32_t voltage;
+#define GLOBAL_REG_PRM_VP_VOLTAGE_VPVOLTAGE_MASK   (0xff)
+#define GLOBAL_REG_PRM_VP_VOLTAGE_VPVOLTAGE_GET(r)   ((r) & 0xff)
+
+		const ioport32_t status;
+#define GLOBAL_REG_PRM_VP_STATUS_VPINIDLE_FLAG   (1 << 0)
+
+		PADD32[2];
+	} vp[2];
+
+	ioport32_t ldo_abb_setup;
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_IN_TRANSITION   (1 << 6)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_MASK   (0x3 << 3)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_BYPASS   (0x0 << 3)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_STATUS_FBB   (0x2 << 3)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_SR2_OPP_CHANGE_FLAG  (1 << 2)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_MASK   (0x3 << 0)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_DEFAULT   (0x0 << 0)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_FAST   (0x1 << 0)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_NOMINAL   (0x2 << 0)
+#define GLOBAL_REG_PRM_LDO_ABB_SETUP_OPP_SEL_SLOW   (0x3 << 0)
+
+	ioport32_t ldo_abb_ctrl;
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_MASK   (0xff << 8)
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_CREATE(x)   (((x) & 0xff) << 8)
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2_WTCNT_VALUE_GET(r)   (((r) >> 8) & 0xff)
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_ACTIVE_FBB_SEL_FLAG   (1 << 2)
+#define GLOBAL_REG_PRM_LDO_ABB_CTRL_SR2EN   (1 << 0)
+} global_reg_prm_regs_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/platform/amdm37x/prm/usbhost.h
===================================================================
--- uspace/drv/platform/amdm37x/prm/usbhost.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/prm/usbhost.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvprm
+ * @{
+ */
+/** @file
+ * @brief Clock Control Clock Management IO register structure.
+ */
+#ifndef AMDM37X_PRM_CLOCK_CONTROL_H
+#define AMDM37X_PRM_CLOCK_CONTROL_H
+#include <sys/types.h>
+#include <macros.h>
+
+/* AM/DM37x TRM p.536 and p.589 */
+#define CLOCK_CONTROL_CM_BASE_ADDRESS  0x48307400
+#define CLOCK_CONTROL_CM_SIZE  8192
+
+/** Clock control PRM register map
+ *
+ * Periph DPLL == DPLL4
+ * Core DPLL == DPLL3
+ */
+typedef struct {
+	PADD32[22];
+	ioport32_t rm_rstst;
+#define USBHOST_PRM_RM_RSTST_COREDOMAINWKUP_RST_FLAG   (1 << 3)
+#define USBHOST_PRM_RM_RSTST_DOMAINWKUP_RST_FLAG   (1 << 2)
+#define USBHOST_PRM_RM_RSTST_GLOBALWARM_RST_FLAG   (1 << 1)
+#define USBHOST_PRM_RM_RSTST_GLOBALCOLD_RST_FLAG   (1 << 0)
+
+	PADD32[18];
+	ioport32_t pm_wken;
+#define USBHOST_PRM_PM_WKEN_EN_USBHOST_FLAG   (1 << 0)
+
+	ioport32_t pm_mpugrpsel;
+#define USBHOST_PRM_PM_MPUGRPSEL_GRPSEL_USBHOST_FLAG   (1 << 0)
+
+	ioport32_t pm_iva2grpsel;
+#define USBHOST_PRM_PM_IVA2GRPSEL_GRPSEL_USBHOST_FLAG   (1 << 0)
+
+	PADD32;
+	ioport32_t pm_wkst;
+#define USBHOST_PRM_PM_WKST_ST_USBHOST_FLAG   (1 << 0)
+
+	PADD32[5];
+	ioport32_t pm_wkdep;
+#define USBHOST_PRM_PM_WKDEP_EN_WKUP_FLAG   (1 << 4)
+#define USBHOST_PRM_PM_WKDEP_EN_IVA2_FLAG   (1 << 2)
+#define USBHOST_PRM_PM_WKDEP_EN_MPU_FLAG   (1 << 1)
+#define USBHOST_PRM_PM_WKDEP_EN_CORE_FLAG   (1 << 0)
+
+	PADD32[5];
+	ioport32_t pm_pwstctrl;
+#define USBHOST_PRM_PM_PWSTCTRL_MEMONSTATE_MASK   (0x3 << 16)
+#define USBHOST_PRM_PM_PWSTCTRL_MEMONSTATE_ALWAYS_ON   (0x3 << 16)
+#define USBHOST_PRM_PM_PWSTCTRL_MEMRETSTATE_FLAG   (1 << 8)
+#define USBHOST_PRM_PM_PWSTCTRL_SAVEANDRESTORE_FLAG   (1 << 4)
+#define USBHOST_PRM_PM_PWSTCTRL_LOGICRESTATE_FLAG   (1 << 2)
+#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_MASK   (0x3 << 0)
+#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_OFF   (0x0 << 0)
+#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_RETENTION   (0x1 << 0)
+#define USBHOST_PRM_PM_PWSTCTRL_POWERSTATE_ON   (0x3 << 0)
+
+	const ioport32_t pm_pwstst;
+#define USBHOST_PRM_PM_PWSTST_INTRANSITION_FLAG   (1 << 20)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_MASK   (0x3 << 0)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_OFF   (0x0 << 0)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_RETENTION  (0x1 << 0)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_INACTIVE  (0x2 << 0)
+#define USBHOST_PRM_PM_PWSTST_POWERSTATEST_ON  (0x3 << 0)
+
+	ioport32_t pm_prepwstst;
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_MASK   (0x3 << 0)
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_OFF   (0x0 << 0)
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_RETENTION  (0x1 << 0)
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_INACTIVE  (0x2 << 0)
+#define USBHOST_PRM_PM_PREPWSTST_LASTPOWERSTATEENTERED_ON  (0x3 << 0)
+
+} usbhost_prm_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/platform/amdm37x/uhh.h
===================================================================
--- uspace/drv/platform/amdm37x/uhh.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/uhh.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvuhh
+ * @{
+ */
+/** @file
+ * @brief UHH IO register structure.
+ */
+#ifndef AMDM37x_UHH_H
+#define AMDM37x_UHH_H
+#include <macros.h>
+#include <sys/types.h>
+
+#define AMDM37x_UHH_BASE_ADDRESS  0x48064000
+#define AMDM37x_UHH_SIZE  1024
+
+typedef struct {
+	const ioport32_t revision;
+#define UHH_REVISION_MINOR_MASK  0x0f
+#define UHH_REVISION_MAJOR_MASK  0xf0
+
+	PADD32[3];
+	ioport32_t sysconfig;
+#define UHH_SYSCONFIG_AUTOIDLE_FLAG  (1 << 0)
+#define UHH_SYSCONFIG_SOFTRESET_FLAG  (1 << 1)
+#define UHH_SYSCONFIG_ENWAKEUP_FLAG  (1 << 2)
+#define UHH_SYSCONFIG_SIDLE_MODE_MASK  (0x3 << 3)
+#define UHH_SYSCONFIG_SIDLE_MODE_FORCE  (0x0 << 3)
+#define UHH_SYSCONFIG_SIDLE_MODE_NO  (0x1 << 3)
+#define UHH_SYSCONFIG_SIDLE_MODE_SMART  (0x2 << 3)
+#define UHH_SYSCONFIG_CLOCKACTIVITY_FLAG  (1 << 8)
+#define UHH_SYSCONFIG_MIDLE_MODE_MASK  (0x3 << 12)
+#define UHH_SYSCONFIG_MIDLE_MODE_FORCE  (0x0 << 12)
+#define UHH_SYSCONFIG_MIDLE_MODE_NO  (0x1 << 12)
+#define UHH_SYSCONFIG_MIDLE_MODE_SMART  (0x2 << 12)
+
+	const ioport32_t sysstatus;
+#define UHH_SYSSTATUS_RESETDONE_FLAG  (1 << 0)
+#define UHH_SYSSTATUS_OHCI_RESETDONE_FLAG  (1 << 1)
+#define UHH_SYSSTATUS_EHCI_RESETDONE_FLAG  (1 << 2)
+
+	PADD32[10];
+	ioport32_t hostconfig;
+#define UHH_HOSTCONFIG_P1_ULPI_BYPASS_FLAG  (1 << 0)
+#define UHH_HOSTCONFIG_AUTOPPD_ON_OVERCUR_EN_FLAG  (1 << 1)
+#define UHH_HOSTCONFIG_ENA_INCR4_FLAG  (1 << 2)
+#define UHH_HOSTCONFIG_ENA_INCR8_FLAG  (1 << 3)
+#define UHH_HOSTCONFIG_ENA_INCR16_FLA  (1 << 4)
+#define UHH_HOSTCONFIG_ENA_INCR_ALIGN_FLAG  (1 << 5)
+#define UHH_HOSTCONFIG_P1_CONNECT_STATUS_FLAG  (1 << 8)
+#define UHH_HOSTCONFIG_P2_CONNECT_STATUS_FLAG  (1 << 9)
+#define UHH_HOSTCONFIG_P3_CONNECT_STATUS_FLAG  (1 << 10)
+#define UHH_HOSTCONFIG_P2_ULPI_BYPASS_FLAG  (1 << 11)
+#define UHH_HOSTCONFIG_P3_ULPI_BYPASS_FLAG  (1 << 12)
+
+	ioport32_t debug_csr;
+#define UHH_DEBUG_CSR_EHCI_FLADJ_MASK  (0x3f << 0)
+#define UHH_DEBUG_CSR_EHCI_FLADJ(x)  ((x) & 0x3f)
+#define UHH_DEBUG_CSR_EHCI_SIMULATION_MODE_FLAG  (1 << 6)
+#define UHH_DEBUG_CSR_OHCI_CNTSEL_FLAG  (1 << 7)
+#define UHH_DEBUG_CSR_OHCI_GLOBAL_SUSPEND_FLAG  (1 << 16)
+#define UHH_DEBUG_CSR_OHCI_CCS1_FLAG  (1 << 17)
+#define UHH_DEBUG_CSR_OHCI_CCS2_FLAG  (1 << 18)
+#define UHH_DEBUG_CSR_OHCI_CCS3_FLAG  (1 << 19)
+
+} uhh_regs_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/platform/amdm37x/usbtll.h
===================================================================
--- uspace/drv/platform/amdm37x/usbtll.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/amdm37x/usbtll.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amdm37xdrvusbtll
+ * @{
+ */
+/** @file
+ * @brief USBTLL IO register structure.
+ */
+#ifndef AMDM37x_USBTLL_H
+#define AMDM37x_USBTLL_H
+#include <macros.h>
+#include <sys/types.h>
+
+#define AMDM37x_USBTLL_BASE_ADDRESS  0x48062000
+#define AMDM37x_USBTLL_SIZE  4096
+
+typedef struct {
+	const ioport32_t revision;
+#define TLL_REVISION_MINOR_MASK  0x0f
+#define TLL_REVISION_MAJOR_MASK  0xf0
+
+	PADD32[3];
+	ioport32_t sysconfig;
+#define TLL_SYSCONFIG_AUTOIDLE_FLAG  (1 << 0)
+#define TLL_SYSCONFIG_SOFTRESET_FLAG  (1 << 1)
+#define TLL_SYSCONFIG_ENWAKEUP_FLAG  (1 << 2)
+#define TLL_SYSCONFIG_SIDLE_MODE_MASK  (0x3 << 3)
+#define TLL_SYSCONFIG_SIDLE_MODE_FORCE  (0x0 << 3)
+#define TLL_SYSCONFIG_SIDLE_MODE_NO  (0x1 << 3)
+#define TLL_SYSCONFIG_SIDLE_MODE_SMART  (0x2 << 3)
+#define TLL_SYSCONFIG_CLOCKACTIVITY_FLAG  (1 << 8)
+
+	const ioport32_t sysstatus;
+#define TLL_SYSSTATUS_RESET_DONE_FLAG  (1 << 0)
+
+	const ioport32_t irqstatus;
+#define TLL_IRQSTATUS_FCLK_START_FLAG  (1 << 0)
+#define TLL_IRQSTATUS_FCLK_END_FLAG  (1 << 1)
+#define TLL_IRQSTATUS_ACCESS_ERROR_FLAG  (1 << 2)
+
+	ioport32_t irqenable;
+#define TLL_IRQSTATUS_FCLK_START_EN_FLAG  (1 << 0)
+#define TLL_IRQSTATUS_FCLK_END_EN_FLAG  (1 << 1)
+#define TLL_IRQSTATUS_ACCESS_ERROR_EN_FLAG  (1 << 2)
+
+	PADD32[4];
+	ioport32_t shared_conf;
+#define TLL_SHARED_CONF_FCLK_IS_ON_FLAG  (1 << 0)
+#define TLL_SHARED_CONF_FCLK_REQ_FLAG  (1 << 1)
+#define TLL_SHARED_CONF_USB_DIVRATIO_MASK  (0x7 << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO(x)  (((x) & 0x7) << 2)
+#define TLL_SHARED_CONF_USB_180D_SDR_EN_FLAG  (1 << 5)
+#define TLL_SHARED_CONF_USB_90D_DDR_EN_FLAG  (1 << 6)
+
+	PADD32[3];
+	ioport32_t channel_conf[3];
+#define TLL_CHANNEL_CONF_CHANEN_FLAG  (1 << 0)
+#define TLL_CHANNEL_CONF_CHANMODE_MASK  (0x3 << 1)
+#define TLL_CHANNEL_CONF_CHANMODE_UTMI_ULPI_MODE (0x0 << 1)
+#define TLL_CHANNEL_CONF_CHANMODE_UTMI_SERIAL_MODE (0x1 << 1)
+#define TLL_CHANNEL_CONF_CHANMODE_UTMI_TRANS_MODE (0x2 << 1)
+#define TLL_CHANNEL_CONF_CHANMODE_NO_MODE (0x3 << 1)
+#define TLL_CHANNEL_CONF_UTMIISADEV_FLAG  (1 << 3)
+#define TLL_CHANNEL_CONF_TLLATTACH_FLAG  (1 << 4)
+#define TLL_CHANNEL_CONF_TLLCONNECT_FLAG  (1 << 5)
+#define TLL_CHANNEL_CONF_TLLFULLSPEED_FLAG  (1 << 6)
+#define TLL_CHANNEL_CONF_ULPIOUTCLKMODE_FLAG  (1 << 7)
+#define TLL_CHANNEL_CONF_ULPIDDRMODE_FLAG  (1 << 8)
+#define TLL_CHANNEL_CONF_UTMIAUTOIDLE_FLAG  (1 << 9)
+#define TLL_CHANNEL_CONF_ULPIAUTOIDLE_FLAG  (1 << 10)
+#define TLL_CHANNEL_CONF_ULPINOBITSTUFF_FLAG  (1 << 11)
+#define TLL_CHANNEL_CONF_CHRGVBUS_FLAG  (1 << 15)
+#define TLL_CHANNEL_CONF_DRVVBUS_FLAG  (1 << 16)
+#define TLL_CHANNEL_CONF_TESTEN_FLAG  (1 << 17)
+#define TLL_CHANNEL_CONF_TESTTXEN_FLAG  (1 << 18)
+#define TLL_CHANNEL_CONF_TESTTXDAT_FLAG  (1 << 19)
+#define TLL_CHANNEL_CONF_TESTTXSE0_FLAG  (1 << 20)
+#define TLL_CHANNEL_CONF_FSLSMODE_MASK   (0xf << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_PHY_TX_DATSE0   (0x0 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_PHY_TX_DPDM   (0x1 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_PHY   (0x2 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_4PIN_BIDI_PHY   (0x3 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_TLL_TX_DATSE0  (0x4 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_6PIN_UNI_TLL_TX_DPDM  (0x5 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_3PIN_BIDI_TLL  (0x6 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_4PIN_BIDI_TLL  (0x7 << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_2PIN_BIDI_TLL_DATSE0  (0xa << 24)
+#define TLL_CHANNEL_CONF_FSLSMODE_2PIN_BIDI_TLL_DPDM  (0xb << 24)
+
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_MASK  (0x3 << 28)
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_SE0  (0x0 << 28)
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_FS_J  (0x1 << 28)
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_FS_K  (0x2 << 28)
+#define TLL_CHANNEL_CONF_FSLSLINESTATE_SE1  (0x3 << 28)
+
+	/* The rest are 8bit ULPI registers */
+} tll_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/platform/icp/Makefile
===================================================================
--- uspace/drv/platform/icp/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/icp/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2014 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = icp
+
+SOURCES = \
+	icp.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/platform/icp/icp.c
===================================================================
--- uspace/drv/platform/icp/icp.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/icp/icp.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+/**
+ * @defgroup icp IntegratorCP platform driver.
+ * @brief HelenOS IntegratorCP platform driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <ddf/driver.h>
+#include <ddf/log.h>
+#include <ops/hw_res.h>
+#include <ops/pio_window.h>
+
+#define NAME "icp"
+
+enum {
+	icp_kbd_base = 0x18000000,
+	icp_kbd_irq = 3,
+	icp_mouse_base = 0x19000000,
+	icp_mouse_irq = 4
+};
+
+typedef struct icp_fun {
+	hw_resource_list_t hw_resources;
+} icp_fun_t;
+
+static int icp_dev_add(ddf_dev_t *dev);
+
+static driver_ops_t icp_ops = {
+	.dev_add = &icp_dev_add
+};
+
+static driver_t icp_driver = {
+	.name = NAME,
+	.driver_ops = &icp_ops
+};
+
+static hw_resource_t icp_kbd_res[] = {
+	{
+		.type = MEM_RANGE,
+		.res.mem_range = {
+			.address = icp_kbd_base,
+			.size = 9,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	},
+	{
+		.type = INTERRUPT,
+		.res.interrupt = {
+			.irq = icp_kbd_irq
+		}
+	}
+};
+
+static hw_resource_t icp_mouse_res[] = {
+	{
+		.type = MEM_RANGE,
+		.res.mem_range = {
+			.address = icp_mouse_base,
+			.size = 9,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	},
+	{
+		.type = INTERRUPT,
+		.res.interrupt = {
+			.irq = icp_mouse_irq
+		}
+	}
+};
+
+static pio_window_t icp_pio_window = {
+	.mem = {
+		.base = 0,
+		.size = -1
+	}
+};
+
+static icp_fun_t icp_kbd_fun_proto = {
+	.hw_resources = {
+		sizeof(icp_kbd_res) / sizeof(icp_kbd_res[0]),
+		icp_kbd_res
+	},
+};
+
+static icp_fun_t icp_mouse_fun_proto = {
+	.hw_resources = {
+		sizeof(icp_mouse_res) / sizeof(icp_mouse_res[0]),
+		icp_mouse_res
+	},
+};
+
+/** Obtain function soft-state from DDF function node */
+static icp_fun_t *icp_fun(ddf_fun_t *fnode)
+{
+	return ddf_fun_data_get(fnode);
+}
+
+static hw_resource_list_t *icp_get_resources(ddf_fun_t *fnode)
+{
+	icp_fun_t *fun = icp_fun(fnode);
+
+	assert(fun != NULL);
+	return &fun->hw_resources;
+}
+
+static bool icp_enable_interrupt(ddf_fun_t *fun)
+{
+	/* TODO */
+	return false;
+}
+
+static pio_window_t *icp_get_pio_window(ddf_fun_t *fnode)
+{
+	return &icp_pio_window;
+}
+
+static hw_res_ops_t icp_hw_res_ops = {
+	.get_resource_list = &icp_get_resources,
+	.enable_interrupt = &icp_enable_interrupt,
+};
+
+static pio_window_ops_t icp_pio_window_ops = {
+	.get_pio_window = &icp_get_pio_window
+};
+
+static ddf_dev_ops_t icp_fun_ops = {
+	.interfaces = {
+		[HW_RES_DEV_IFACE] = &icp_hw_res_ops,
+		[PIO_WINDOW_DEV_IFACE] = &icp_pio_window_ops
+	}
+};
+
+static int icp_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
+    icp_fun_t *fun_proto)
+{
+	ddf_msg(LVL_NOTE, "Adding function '%s'.", name);
+
+	ddf_fun_t *fnode = NULL;
+	int rc;
+
+	/* Create new device. */
+	fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL) {
+		ddf_msg(LVL_ERROR, "Error creating function '%s'", name);
+		rc = ENOMEM;
+		goto error;
+	}
+
+	icp_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(icp_fun_t));
+	*fun = *fun_proto;
+
+	/* Add match ID */
+	rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Error adding match ID");
+		goto error;
+	}
+
+	/* Set provided operations to the device. */
+	ddf_fun_set_ops(fnode, &icp_fun_ops);
+
+	/* Register function. */
+	if (ddf_fun_bind(fnode) != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
+		goto error;
+	}
+
+	return EOK;
+
+error:
+	if (fnode != NULL)
+		ddf_fun_destroy(fnode);
+
+	return rc;
+}
+
+static int icp_add_functions(ddf_dev_t *dev)
+{
+	int rc;
+
+	rc = icp_add_fun(dev, "kbd", "arm/pl050", &icp_kbd_fun_proto);
+	if (rc != EOK)
+		return rc;
+
+	rc = icp_add_fun(dev, "mouse", "arm/pl050", &icp_mouse_fun_proto);
+	if (rc != EOK)
+		return rc;
+
+	return EOK;
+}
+
+/** Add device. */
+static int icp_dev_add(ddf_dev_t *dev)
+{
+	ddf_msg(LVL_NOTE, "icp_dev_add, device handle = %d",
+	    (int)ddf_dev_get_handle(dev));
+
+	/* Register functions. */
+	if (icp_add_functions(dev)) {
+		ddf_msg(LVL_ERROR, "Failed to add functions for ICP platform.");
+	}
+
+	return EOK;
+}
+
+int main(int argc, char *argv[])
+{
+	int rc;
+
+	printf(NAME ": HelenOS IntegratorCP platform driver\n");
+
+	rc = ddf_log_init(NAME);
+	if (rc != EOK) {
+		printf(NAME ": Failed initializing logging service");
+		return 1;
+	}
+
+	return ddf_driver_main(&icp_driver);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/platform/icp/icp.ma
===================================================================
--- uspace/drv/platform/icp/icp.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/icp/icp.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+10 platform/integratorcp
Index: uspace/drv/platform/leon3/Makefile
===================================================================
--- uspace/drv/platform/leon3/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/leon3/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2012 Jan Vesely
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = leon3
+
+SOURCES = \
+	leon3.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/platform/leon3/leon3.c
===================================================================
--- uspace/drv/platform/leon3/leon3.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/leon3/leon3.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2012 Jan Vesely
+ * Copyright (c) 2013 Jakub Klama
+ * 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.
+ */
+
+/**
+ * @defgroup leon3 SPARC LEON3 platform driver.
+ * @brief HelenOS SPARC LEON3 platform driver.
+ * @{
+ */
+/** @file
+ */
+
+#include <ddf/log.h>
+#include <errno.h>
+#include <ops/hw_res.h>
+#include <stdio.h>
+#include "leon3.h"
+
+#define NAME  "leon3"
+
+typedef struct {
+	const char *name;
+	match_id_t match_id;
+	hw_resource_list_t hw_resources;
+} leon3_fun_t;
+
+static hw_resource_t amba_res[] = {
+	{
+		.type = MEM_RANGE,
+		.res.mem_range = {
+			.address = AMBAPP_MASTER_AREA,
+			.size = AMBAPP_MASTER_SIZE,
+			.endianness = BIG_ENDIAN
+		}
+	},
+	{
+		.type = MEM_RANGE,
+		.res.mem_range = {
+			.address = AMBAPP_SLAVE_AREA,
+			.size = AMBAPP_SLAVE_SIZE,
+			.endianness = BIG_ENDIAN,
+		}
+	}
+};
+
+static const leon3_fun_t leon3_func = {
+	.name = "leon_amba",
+	.match_id = {
+		.id =  "leon_amba",
+		.score = 90 
+	},
+	.hw_resources = {
+		.count = 2,
+		.resources = amba_res
+	}
+};
+
+static hw_resource_list_t *leon3_get_resources(ddf_fun_t *);
+static bool leon3_enable_interrupt(ddf_fun_t *);
+
+static hw_res_ops_t fun_hw_res_ops = {
+	.get_resource_list = &leon3_get_resources,
+	.enable_interrupt = &leon3_enable_interrupt
+};
+
+static ddf_dev_ops_t leon3_fun_ops = {
+	.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops
+};
+
+static int leon3_add_fun(ddf_dev_t *dev, const leon3_fun_t *fun)
+{
+	assert(dev);
+	assert(fun);
+	
+	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", fun->name);
+	
+	/* Create new device function. */
+	ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, fun->name);
+	if (fnode == NULL)
+		return ENOMEM;
+	
+	/* Add match id */
+	int ret = ddf_fun_add_match_id(fnode, fun->match_id.id,
+	    fun->match_id.score);
+	if (ret != EOK) {
+		ddf_fun_destroy(fnode);
+		return ret;
+	}
+	
+	/* Allocate needed data */
+	leon3_fun_t *rf =
+	    ddf_fun_data_alloc(fnode, sizeof(leon3_fun_t));
+	if (!rf) {
+		ddf_fun_destroy(fnode);
+		return ENOMEM;
+	}
+	*rf = *fun;
+	
+	/* Set provided operations to the device. */
+	ddf_fun_set_ops(fnode, &leon3_fun_ops);
+	
+	/* Register function. */
+	ret = ddf_fun_bind(fnode);
+	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", fun->name);
+		ddf_fun_destroy(fnode);
+		return ret;
+	}
+	
+	return EOK;
+}
+
+/** Add the root device.
+ *
+ * @param dev Device which is root of the whole device tree
+ *            (both of HW and pseudo devices).
+ *
+ * @return Zero on success, negative error number otherwise.
+ *
+ */
+static int leon3_dev_add(ddf_dev_t *dev)
+{
+	assert(dev);
+	
+	/* Register functions */
+	if (leon3_add_fun(dev, &leon3_func) != EOK) {
+		ddf_msg(LVL_ERROR, "Failed to add %s function for "
+		    "LEON3 platform.", leon3_func.name);
+	}
+	
+	return EOK;
+}
+
+/** The root device driver's standard operations. */
+static driver_ops_t leon3_ops = {
+	.dev_add = &leon3_dev_add
+};
+
+/** The root device driver structure. */
+static driver_t leon3_driver = {
+	.name = NAME,
+	.driver_ops = &leon3_ops
+};
+
+static hw_resource_list_t *leon3_get_resources(ddf_fun_t *fnode)
+{
+	leon3_fun_t *fun = ddf_fun_data_get(fnode);
+	assert(fun != NULL);
+	
+	printf("leon3_get_resources() called\n");
+	
+	return &fun->hw_resources;
+}
+
+static bool leon3_enable_interrupt(ddf_fun_t *fun)
+{
+	// FIXME TODO
+	return false;
+}
+
+int main(int argc, char *argv[])
+{
+	printf("%s: HelenOS SPARC LEON3 platform driver\n", NAME);
+	ddf_log_init(NAME);
+	return ddf_driver_main(&leon3_driver);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/platform/leon3/leon3.h
===================================================================
--- uspace/drv/platform/leon3/leon3.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/leon3/leon3.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 leon3drv
+ * @{
+ */
+/** @file
+ * @brief LEON3 root device.
+ */
+
+#ifndef LEON3_H
+#define LEON3_H
+
+#define AMBAPP_MASTER_AREA  0xfffff000
+#define AMBAPP_SLAVE_AREA   0xfffff800
+#define AMBAPP_MASTER_SIZE  0x800
+#define AMBAPP_SLAVE_SIZE   0x800
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/drv/platform/leon3/leon3.ma
===================================================================
--- uspace/drv/platform/leon3/leon3.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/leon3/leon3.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+100 platform/leon3
Index: uspace/drv/platform/mac/Makefile
===================================================================
--- uspace/drv/platform/mac/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/mac/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = mac
+
+SOURCES = \
+	mac.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/platform/mac/mac.c
===================================================================
--- uspace/drv/platform/mac/mac.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/mac/mac.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,190 @@
+/*
+ * 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.
+ */
+
+/**
+ * @defgroup mac Mac platform driver.
+ * @brief HelenOS Mac platform driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <ddf/driver.h>
+#include <ddf/log.h>
+#include <errno.h>
+#include <ops/hw_res.h>
+#include <stdio.h>
+
+#define NAME  "mac"
+
+typedef struct {
+	hw_resource_list_t hw_resources;
+} mac_fun_t;
+
+static hw_resource_t pci_conf_regs[] = {
+	{
+		.type = IO_RANGE,
+		.res.io_range = {
+			.address = 0xfec00000,
+			.size = 4,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	},
+	{
+		.type = IO_RANGE,
+		.res.io_range = {
+			.address = 0xfee00000,
+			.size = 4,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	}
+};
+
+static mac_fun_t pci_data = {
+	.hw_resources = {
+		2,
+		pci_conf_regs
+	}
+};
+
+static ddf_dev_ops_t mac_fun_ops;
+
+/** Obtain function soft-state from DDF function node */
+static mac_fun_t *mac_fun(ddf_fun_t *fnode)
+{
+	return ddf_fun_data_get(fnode);
+}
+
+static bool mac_add_fun(ddf_dev_t *dev, const char *name,
+    const char *str_match_id, mac_fun_t *fun_proto)
+{
+	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
+	
+	ddf_fun_t *fnode = NULL;
+	int rc;
+	
+	/* Create new device. */
+	fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL)
+		goto failure;
+	
+	mac_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(mac_fun_t));
+	*fun = *fun_proto;
+	
+	/* Add match ID */
+	rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
+	if (rc != EOK)
+		goto failure;
+	
+	/* Set provided operations to the device. */
+	ddf_fun_set_ops(fnode, &mac_fun_ops);
+	
+	/* Register function. */
+	if (ddf_fun_bind(fnode) != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
+		goto failure;
+	}
+	
+	return true;
+	
+failure:
+	if (fnode != NULL)
+		ddf_fun_destroy(fnode);
+	
+	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
+	
+	return false;
+}
+
+/** Get the root device.
+ *
+ * @param dev Device which is root of the whole device tree
+ *            (both of HW and pseudo devices).
+ *
+ * @return Zero on success, negative error number otherwise.
+ *
+ */
+static int mac_dev_add(ddf_dev_t *dev)
+{
+#if 0
+	/* Register functions */
+	if (!mac_add_fun(dev, "pci0", "intel_pci", &pci_data))
+		ddf_msg(LVL_ERROR, "Failed to add functions for Mac platform.");
+#else
+	(void)pci_data;
+	(void)mac_add_fun;
+#endif
+	
+	return EOK;
+}
+
+/** The root device driver's standard operations. */
+static driver_ops_t mac_ops = {
+	.dev_add = &mac_dev_add
+};
+
+/** The root device driver structure. */
+static driver_t mac_driver = {
+	.name = NAME,
+	.driver_ops = &mac_ops
+};
+
+static hw_resource_list_t *mac_get_resources(ddf_fun_t *fnode)
+{
+	mac_fun_t *fun = mac_fun(fnode);
+	assert(fun != NULL);
+	
+	return &fun->hw_resources;
+}
+
+static bool mac_enable_interrupt(ddf_fun_t *fun)
+{
+	/* TODO */
+	
+	return false;
+}
+
+static hw_res_ops_t fun_hw_res_ops = {
+   	.get_resource_list = &mac_get_resources,
+	.enable_interrupt = &mac_enable_interrupt
+};
+
+int main(int argc, char *argv[])
+{
+	printf("%s: HelenOS Mac platform driver\n", NAME);
+	ddf_log_init(NAME);
+	mac_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
+	return ddf_driver_main(&mac_driver);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/platform/mac/mac.ma
===================================================================
--- uspace/drv/platform/mac/mac.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/mac/mac.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+10 platform/mac
Index: uspace/drv/platform/malta/Makefile
===================================================================
--- uspace/drv/platform/malta/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/malta/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = malta
+
+SOURCES = \
+	malta.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/platform/malta/malta.c
===================================================================
--- uspace/drv/platform/malta/malta.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/malta/malta.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2013 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @defgroup malta Malta board platform driver.
+ * @brief HelenOS Malta board platform driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <fibril_synch.h>
+#include <stdlib.h>
+#include <str.h>
+#include <ctype.h>
+#include <macros.h>
+
+#include <ddi.h>
+#include <ddf/driver.h>
+#include <ddf/log.h>
+#include <ipc/dev_iface.h>
+#include <ops/hw_res.h>
+#include <ops/pio_window.h>
+#include <byteorder.h>
+
+#define NAME "malta"
+
+#define GT_BASE		UINT32_C(0x1be00000)
+#define GT_SIZE 	(2 * 1024 * 1024)
+
+#define GT_PCI_CMD	0xc00
+#define GT_PCI_CONFADDR	0xcf8
+#define GT_PCI_CONFDATA	0xcfc
+
+#define GT_PCI_CMD_MBYTESWAP	0x1
+
+#define GT_PCI_MEMBASE	UINT32_C(0x10000000)
+#define GT_PCI_MEMSIZE	UINT32_C(0x08000000)
+
+#define GT_PCI_IOBASE	UINT32_C(0x18000000)
+#define GT_PCI_IOSIZE	UINT32_C(0x00200000)
+
+typedef struct malta_fun {
+	hw_resource_list_t hw_resources;
+	pio_window_t pio_window;
+} malta_fun_t;
+
+static int malta_dev_add(ddf_dev_t *dev);
+static void malta_init(void);
+
+/** The root device driver's standard operations. */
+static driver_ops_t malta_ops = {
+	.dev_add = &malta_dev_add
+};
+
+/** The root device driver structure. */
+static driver_t malta_driver = {
+	.name = NAME,
+	.driver_ops = &malta_ops
+};
+
+static hw_resource_t pci_conf_regs[] = {
+	{
+		.type = IO_RANGE,
+		.res.io_range = {
+			.address = GT_BASE + GT_PCI_CONFADDR,
+			.size = 4,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	},
+	{
+		.type = IO_RANGE,
+		.res.io_range = {
+			.address = GT_BASE + GT_PCI_CONFDATA,
+			.size = 4,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	}
+};
+
+static malta_fun_t pci_data = {
+	.hw_resources = {
+		sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]),
+		pci_conf_regs
+	},
+	.pio_window = {
+		.mem = {
+			.base = GT_PCI_MEMBASE,
+			.size = GT_PCI_MEMSIZE
+		},
+		.io = {
+			.base = GT_PCI_IOBASE,
+			.size = GT_PCI_IOSIZE
+		}
+	}
+};
+
+/** Obtain function soft-state from DDF function node */
+static malta_fun_t *malta_fun(ddf_fun_t *fnode)
+{
+	return ddf_fun_data_get(fnode);
+}
+
+static hw_resource_list_t *malta_get_resources(ddf_fun_t *fnode)
+{
+	malta_fun_t *fun = malta_fun(fnode);
+	
+	assert(fun != NULL);
+	return &fun->hw_resources;
+}
+
+static bool malta_enable_interrupt(ddf_fun_t *fun)
+{
+	/* TODO */
+	
+	return false;
+}
+
+static pio_window_t *malta_get_pio_window(ddf_fun_t *fnode)
+{
+	malta_fun_t *fun = malta_fun(fnode);
+
+	assert(fun != NULL);
+	return &fun->pio_window;
+}
+
+static hw_res_ops_t fun_hw_res_ops = {
+	.get_resource_list = &malta_get_resources,
+	.enable_interrupt = &malta_enable_interrupt,
+};
+
+static pio_window_ops_t fun_pio_window_ops = {
+	.get_pio_window = &malta_get_pio_window
+};
+
+/* Initialized in malta_init() function. */
+static ddf_dev_ops_t malta_fun_ops;
+
+static bool
+malta_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
+    malta_fun_t *fun_proto)
+{
+	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
+	
+	ddf_fun_t *fnode = NULL;
+	int rc;
+	
+	/* Create new device. */
+	fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL)
+		goto failure;
+	
+	malta_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(malta_fun_t));
+	*fun = *fun_proto;
+	
+	/* Add match ID */
+	rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
+	if (rc != EOK)
+		goto failure;
+	
+	/* Set provided operations to the device. */
+	ddf_fun_set_ops(fnode, &malta_fun_ops);
+	
+	/* Register function. */
+	if (ddf_fun_bind(fnode) != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
+		goto failure;
+	}
+	
+	return true;
+	
+failure:
+	if (fnode != NULL)
+		ddf_fun_destroy(fnode);
+	
+	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
+	
+	return false;
+}
+
+static bool malta_add_functions(ddf_dev_t *dev)
+{
+	return malta_add_fun(dev, "pci0", "intel_pci", &pci_data);
+}
+
+/** Get the root device.
+ *
+ * @param dev		The device which is root of the whole device tree (both
+ *			of HW and pseudo devices).
+ * @return		Zero on success, negative error number otherwise.
+ */
+static int malta_dev_add(ddf_dev_t *dev)
+{
+	ioport32_t *gt;
+	uint32_t val;
+	int ret;
+
+	ddf_msg(LVL_DEBUG, "malta_dev_add, device handle = %d",
+	    (int)ddf_dev_get_handle(dev));
+
+	/*
+ 	 * We need to disable byte swapping of the outgoing and incoming
+ 	 * PCI data, because the PCI driver assumes no byte swapping behind
+ 	 * the scenes and takes care of it itself.
+ 	 */
+	ret = pio_enable((void *) GT_BASE, GT_SIZE, (void **) &gt);
+	if (ret != EOK)
+                return ret;
+	val = uint32_t_le2host(pio_read_32(
+	    &gt[GT_PCI_CMD / sizeof(ioport32_t)]));
+	val |= GT_PCI_CMD_MBYTESWAP;
+	pio_write_32(
+	    &gt[GT_PCI_CMD / sizeof(ioport32_t)], host2uint32_t_le(val));
+
+	
+	/* Register functions. */
+	if (!malta_add_functions(dev)) {
+		ddf_msg(LVL_ERROR, "Failed to add functions for the Malta platform.");
+	}
+	
+	return EOK;
+}
+
+static void malta_init(void)
+{
+	ddf_log_init(NAME);
+	malta_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
+	malta_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops;
+}
+
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS Malta platform driver\n");
+	malta_init();
+	return ddf_driver_main(&malta_driver);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/platform/malta/malta.ma
===================================================================
--- uspace/drv/platform/malta/malta.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/malta/malta.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+10 platform/malta
Index: uspace/drv/platform/pc/Makefile
===================================================================
--- uspace/drv/platform/pc/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/pc/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = pc
+
+SOURCES = \
+	pc.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/platform/pc/pc.c
===================================================================
--- uspace/drv/platform/pc/pc.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/pc/pc.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,236 @@
+/*
+ * 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.
+ */
+
+/**
+ * @defgroup pc PC platform driver.
+ * @brief HelenOS PC platform driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <fibril_synch.h>
+#include <stdlib.h>
+#include <str.h>
+#include <ctype.h>
+#include <macros.h>
+
+#include <ddf/driver.h>
+#include <ddf/log.h>
+#include <ipc/dev_iface.h>
+#include <ops/hw_res.h>
+#include <ops/pio_window.h>
+
+#define NAME "pc"
+
+typedef struct pc_fun {
+	hw_resource_list_t hw_resources;
+	pio_window_t pio_window;
+} pc_fun_t;
+
+static int pc_dev_add(ddf_dev_t *dev);
+static void pc_init(void);
+
+/** The root device driver's standard operations. */
+static driver_ops_t pc_ops = {
+	.dev_add = &pc_dev_add
+};
+
+/** The root device driver structure. */
+static driver_t pc_driver = {
+	.name = NAME,
+	.driver_ops = &pc_ops
+};
+
+static hw_resource_t pci_conf_regs[] = {
+	{
+		.type = IO_RANGE,
+		.res.io_range = {
+			.address = 0xCF8,
+			.size = 4,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	},
+	{
+		.type = IO_RANGE,
+		.res.io_range = {
+			.address = 0xCFC,
+			.size = 4,
+			.relative = false,
+			.endianness = LITTLE_ENDIAN
+		}
+	}
+};
+
+static pc_fun_t pci_data = {
+	.hw_resources = {
+		sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]),
+		pci_conf_regs
+	},
+	.pio_window = {
+		.mem = {
+			.base = UINT32_C(0),
+			.size = UINT32_C(0xffffffff) /* practical maximum */
+		},
+		.io = {
+			.base = UINT32_C(0),
+			.size = UINT32_C(0x10000)
+		}
+	}
+};
+
+/** Obtain function soft-state from DDF function node */
+static pc_fun_t *pc_fun(ddf_fun_t *fnode)
+{
+	return ddf_fun_data_get(fnode);
+}
+
+static hw_resource_list_t *pc_get_resources(ddf_fun_t *fnode)
+{
+	pc_fun_t *fun = pc_fun(fnode);
+	
+	assert(fun != NULL);
+	return &fun->hw_resources;
+}
+
+static bool pc_enable_interrupt(ddf_fun_t *fun)
+{
+	/* TODO */
+	
+	return false;
+}
+
+static pio_window_t *pc_get_pio_window(ddf_fun_t *fnode)
+{
+	pc_fun_t *fun = pc_fun(fnode);
+	
+	assert(fun != NULL);
+	return &fun->pio_window;
+}
+
+static hw_res_ops_t fun_hw_res_ops = {
+	.get_resource_list = &pc_get_resources,
+	.enable_interrupt = &pc_enable_interrupt,
+};
+
+static pio_window_ops_t fun_pio_window_ops = {
+	.get_pio_window = &pc_get_pio_window
+};
+
+/* Initialized in pc_init() function. */
+static ddf_dev_ops_t pc_fun_ops;
+
+static bool
+pc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
+    pc_fun_t *fun_proto)
+{
+	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
+	
+	ddf_fun_t *fnode = NULL;
+	int rc;
+	
+	/* Create new device. */
+	fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL)
+		goto failure;
+	
+	pc_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(pc_fun_t));
+	*fun = *fun_proto;
+	
+	/* Add match ID */
+	rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
+	if (rc != EOK)
+		goto failure;
+	
+	/* Set provided operations to the device. */
+	ddf_fun_set_ops(fnode, &pc_fun_ops);
+	
+	/* Register function. */
+	if (ddf_fun_bind(fnode) != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
+		goto failure;
+	}
+	
+	return true;
+	
+failure:
+	if (fnode != NULL)
+		ddf_fun_destroy(fnode);
+	
+	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
+	
+	return false;
+}
+
+static bool pc_add_functions(ddf_dev_t *dev)
+{
+	return pc_add_fun(dev, "pci0", "intel_pci", &pci_data);
+}
+
+/** Get the root device.
+ *
+ * @param dev		The device which is root of the whole device tree (both
+ *			of HW and pseudo devices).
+ * @return		Zero on success, negative error number otherwise.
+ */
+static int pc_dev_add(ddf_dev_t *dev)
+{
+	ddf_msg(LVL_DEBUG, "pc_dev_add, device handle = %d",
+	    (int)ddf_dev_get_handle(dev));
+	
+	/* Register functions. */
+	if (!pc_add_functions(dev)) {
+		ddf_msg(LVL_ERROR, "Failed to add functions for PC platform.");
+	}
+	
+	return EOK;
+}
+
+static void pc_init(void)
+{
+	ddf_log_init(NAME);
+	pc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
+	pc_fun_ops.interfaces[PIO_WINDOW_DEV_IFACE] = &fun_pio_window_ops;
+}
+
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS PC platform driver\n");
+	pc_init();
+	return ddf_driver_main(&pc_driver);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/platform/pc/pc.ma
===================================================================
--- uspace/drv/platform/pc/pc.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/platform/pc/pc.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+10 platform/pc
Index: uspace/drv/root/root/Makefile
===================================================================
--- uspace/drv/root/root/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/root/root/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = root
+
+SOURCES = \
+	root.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/root/root/root.c
===================================================================
--- uspace/drv/root/root/root.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/root/root/root.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2010 Vojtech Horky
+ * Copyright (c) 2011 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.
+ */
+
+/**
+ * @defgroup root Root device driver.
+ * @brief HelenOS root device driver.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <fibril_synch.h>
+#include <stdlib.h>
+#include <str.h>
+#include <str_error.h>
+#include <ctype.h>
+#include <macros.h>
+#include <inttypes.h>
+#include <sysinfo.h>
+
+#include <ddf/driver.h>
+#include <ddf/log.h>
+
+#define NAME "root"
+
+#define PLATFORM_FUN_NAME "hw"
+#define PLATFORM_FUN_MATCH_ID_FMT "platform/%s"
+#define PLATFORM_FUN_MATCH_SCORE 100
+
+#define VIRTUAL_FUN_NAME "virt"
+#define VIRTUAL_FUN_MATCH_ID "virt"
+#define VIRTUAL_FUN_MATCH_SCORE 100
+
+static int root_dev_add(ddf_dev_t *dev);
+static int root_fun_online(ddf_fun_t *fun);
+static int root_fun_offline(ddf_fun_t *fun);
+
+/** The root device driver's standard operations. */
+static driver_ops_t root_ops = {
+	.dev_add = &root_dev_add,
+	.fun_online = &root_fun_online,
+	.fun_offline = &root_fun_offline
+};
+
+/** The root device driver structure. */
+static driver_t root_driver = {
+	.name = NAME,
+	.driver_ops = &root_ops
+};
+
+/** Create the function which represents the root of virtual device tree.
+ *
+ * @param dev	Device
+ * @return	EOK on success or negative error code
+ */
+static int add_virtual_root_fun(ddf_dev_t *dev)
+{
+	const char *name = VIRTUAL_FUN_NAME;
+	ddf_fun_t *fun;
+	int rc;
+
+	ddf_msg(LVL_DEBUG, "Adding new function for virtual devices. "
+	    "Function node is `%s' (%d %s)", name,
+	    VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID);
+
+	fun = ddf_fun_create(dev, fun_inner, name);
+	if (fun == NULL) {
+		ddf_msg(LVL_ERROR, "Failed creating function %s", name);
+		return ENOMEM;
+	}
+
+	rc = ddf_fun_add_match_id(fun, VIRTUAL_FUN_MATCH_ID,
+	    VIRTUAL_FUN_MATCH_SCORE);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
+		    str_error(rc));
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	return EOK;
+}
+
+/** Create the function which represents the root of HW device tree.
+ *
+ * @param dev	Device
+ * @return	EOK on success or negative error code
+ */
+static int add_platform_fun(ddf_dev_t *dev)
+{
+	char *match_id;
+	char *platform;
+	size_t platform_size;
+
+	const char *name = PLATFORM_FUN_NAME;
+	ddf_fun_t *fun;
+	int rc;
+
+	/* Get platform name from sysinfo. */
+	platform = sysinfo_get_data("platform", &platform_size);
+	if (platform == NULL) {
+		ddf_msg(LVL_ERROR, "Failed to obtain platform name.");
+		return ENOENT;
+	}
+
+	/* Null-terminate string. */
+	platform = realloc(platform, platform_size + 1);
+	if (platform == NULL) {
+		ddf_msg(LVL_ERROR, "Memory allocation failed.");
+		return ENOMEM;
+	}
+
+	platform[platform_size] = '\0';
+
+	/* Construct match ID. */
+	if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
+		ddf_msg(LVL_ERROR, "Memory allocation failed.");
+		free(platform);
+		return ENOMEM;
+	}
+
+	free(platform);
+
+	/* Add function. */
+	ddf_msg(LVL_DEBUG, "Adding platform function. Function node is `%s' "
+	    " (%d %s)", PLATFORM_FUN_NAME, PLATFORM_FUN_MATCH_SCORE,
+	    match_id);
+
+	fun = ddf_fun_create(dev, fun_inner, name);
+	if (fun == NULL) {
+		ddf_msg(LVL_ERROR, "Error creating function %s", name);
+		free(match_id);
+		return ENOMEM;
+	}
+
+	rc = ddf_fun_add_match_id(fun, match_id, PLATFORM_FUN_MATCH_SCORE);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
+		free(match_id);
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	free(match_id);
+
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
+		    str_error(rc));
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	return EOK;
+}
+
+/** Get the root device.
+ *
+ * @param dev		The device which is root of the whole device tree (both
+ *			of HW and pseudo devices).
+ */
+static int root_dev_add(ddf_dev_t *dev)
+{
+	ddf_msg(LVL_DEBUG, "root_dev_add, device handle=%" PRIun,
+	    ddf_dev_get_handle(dev));
+
+	/*
+	 * Register virtual devices root.
+	 * We warn on error occurrence because virtual devices shall not be
+	 * vital for the system.
+	 */
+	int res = add_virtual_root_fun(dev);
+	if (res != EOK)
+		ddf_msg(LVL_WARN, "Failed to add virtual child.");
+
+	/* Register root device's children. */
+	res = add_platform_fun(dev);
+	if (EOK != res)
+		ddf_msg(LVL_ERROR, "Failed adding child device for platform.");
+
+	return res;
+}
+
+static int root_fun_online(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "root_fun_online()");
+	return ddf_fun_online(fun);
+}
+
+static int root_fun_offline(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "root_fun_offline()");
+	return ddf_fun_offline(fun);
+}
+
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS root device driver\n");
+
+	ddf_log_init(NAME);
+	return ddf_driver_main(&root_driver);
+}
+
+/**
+ * @}
+ */
+
Index: uspace/drv/root/root/root.ma
===================================================================
--- uspace/drv/root/root/root.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/root/root/root.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+10 root
Index: uspace/drv/root/virt/Makefile
===================================================================
--- uspace/drv/root/virt/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/root/virt/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2010 Vojtech Horky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = virt
+
+SOURCES = \
+	virt.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/root/virt/devices.def
===================================================================
--- uspace/drv/root/virt/devices.def	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/root/virt/devices.def	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,46 @@
+/*
+ * Add list of virtual devices you want to launch driver for here.
+ *
+ * Unless the list is empty, the last item shall be followed by a comma.
+ */
+
+/* Kernel framebuffer */
+{
+    .name = "kfb",
+    .match_id = "virtual&kfb"
+},
+
+#ifdef CONFIG_TEST_DRIVERS
+
+{
+	.name = "test1",
+	.match_id = "virtual&test1"
+},
+{
+	.name = "test2alpha",
+	.match_id = "virtual&test2"
+},
+{
+	.name = "test2bravo",
+	.match_id = "virtual&test2"
+},
+{
+	.name = "null",
+	.match_id = "virtual&test1"
+},
+{
+	.name = "test3",
+	.match_id = "virtual&test3"
+},
+
+#endif
+
+#ifdef CONFIG_RUN_VIRTUAL_USB_HC
+
+/* Virtual USB host controller. */
+{
+	.name = "usbhc",
+	.match_id = "usb&hc=vhc"
+},
+
+#endif
Index: uspace/drv/root/virt/virt.c
===================================================================
--- uspace/drv/root/virt/virt.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/root/virt/virt.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @defgroup virt Root device driver for virtual devices.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+#include <str_error.h>
+#include <ddf/driver.h>
+#include <ddf/log.h>
+
+#define NAME "virt"
+
+/** Virtual function entry */
+typedef struct {
+	/** Function name */
+	const char *name;
+	/** Function match ID */
+	const char *match_id;
+} virtual_function_t;
+
+/** List of existing virtual functions */
+virtual_function_t virtual_functions[] = {
+#include "devices.def"
+	/* Terminating item */
+	{
+		.name = NULL,
+		.match_id = NULL
+	}
+};
+
+static int virt_dev_add(ddf_dev_t *dev);
+static int virt_dev_remove(ddf_dev_t *dev);
+static int virt_fun_online(ddf_fun_t *fun);
+static int virt_fun_offline(ddf_fun_t *fun);
+
+static driver_ops_t virt_ops = {
+	.dev_add = &virt_dev_add,
+	.dev_remove = &virt_dev_remove,
+	.fun_online = &virt_fun_online,
+	.fun_offline = &virt_fun_offline
+};
+
+static driver_t virt_driver = {
+	.name = NAME,
+	.driver_ops = &virt_ops
+};
+
+/* Device soft state */
+typedef struct {
+	ddf_dev_t *dev;
+	list_t functions;
+} virt_t;
+
+/* Function soft state */
+typedef struct {
+	ddf_fun_t *fun;
+	link_t dev_link;
+} virt_fun_t;
+
+static int instances = 0;
+
+
+/** Add function to the virtual device.
+ *
+ * @param vdev		The virtual device
+ * @param vfun		Virtual function description
+ * @return		EOK on success or negative error code.
+ */
+static int virt_add_fun(virt_t *virt, virtual_function_t *vfun)
+{
+	ddf_dev_t *vdev = virt->dev;
+	ddf_fun_t *fun;
+	virt_fun_t *rvfun;
+	int rc;
+
+	ddf_msg(LVL_DEBUG, "Registering function `%s' (match \"%s\")",
+	    vfun->name, vfun->match_id);
+
+	fun = ddf_fun_create(vdev, fun_inner, vfun->name);
+	if (fun == NULL) {
+		ddf_msg(LVL_ERROR, "Failed creating function %s", vfun->name);
+		return ENOMEM;
+	}
+
+	rvfun = ddf_fun_data_alloc(fun, sizeof(virt_fun_t));
+	if (rvfun == NULL) {
+		ddf_msg(LVL_ERROR, "Failed allocating soft state for %s.",
+		    vfun->name);
+		ddf_fun_destroy(fun);
+		return ENOMEM;
+	}
+
+	rvfun->fun = fun;
+
+	rc = ddf_fun_add_match_id(fun, vfun->match_id, 10);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    vfun->name);
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s",
+		    vfun->name, str_error(rc));
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	list_append(&rvfun->dev_link, &virt->functions);
+
+	ddf_msg(LVL_NOTE, "Registered child device `%s'", vfun->name);
+	return EOK;
+}
+
+static int virt_fun_remove(virt_fun_t *rvfun)
+{
+	int rc;
+	const char *name = ddf_fun_get_name(rvfun->fun);
+
+	ddf_msg(LVL_DEBUG, "virt_fun_remove('%s')", name);
+	rc = ddf_fun_offline(rvfun->fun);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Error offlining function '%s'.", name);
+		return rc;
+	}
+
+	rc = ddf_fun_unbind(rvfun->fun);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", name);
+		return rc;
+	}
+
+	list_remove(&rvfun->dev_link);
+	ddf_fun_destroy(rvfun->fun);
+	return EOK;
+}
+
+
+static int virt_dev_add(ddf_dev_t *dev)
+{
+	virt_t *virt;
+
+	/*
+	 * Allow only single instance of root virtual device.
+	 */
+	if (++instances > 1) {
+		return ELIMIT;
+	}
+
+	ddf_msg(LVL_DEBUG, "dev_add(handle=%d)", (int)ddf_dev_get_handle(dev));
+
+	virt = ddf_dev_data_alloc(dev, sizeof(virt_t));
+	if (virt == NULL)
+		return ENOMEM;
+
+	virt->dev = dev;
+	list_initialize(&virt->functions);
+
+	/*
+	 * Go through all virtual functions and try to add them.
+	 * We silently ignore failures.
+	 */
+	virtual_function_t *vfun = virtual_functions;
+	while (vfun->name != NULL) {
+		(void) virt_add_fun(virt, vfun);
+		vfun++;
+	}
+
+	return EOK;
+}
+
+static int virt_dev_remove(ddf_dev_t *dev)
+{
+	virt_t *virt = (virt_t *)ddf_dev_data_get(dev);
+	int rc;
+
+	while (!list_empty(&virt->functions)) {
+		virt_fun_t *rvfun = list_get_instance(
+		    list_first(&virt->functions), virt_fun_t,
+			dev_link);
+
+		rc = virt_fun_remove(rvfun);
+		if (rc != EOK)
+			return rc;
+	}
+
+	--instances;
+	return EOK;
+}
+
+static int virt_fun_online(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "virt_fun_online()");
+	return ddf_fun_online(fun);
+}
+
+static int virt_fun_offline(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "virt_fun_offline()");
+	return ddf_fun_offline(fun);
+}
+
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS virtual devices root driver\n");
+
+	ddf_log_init(NAME);
+	return ddf_driver_main(&virt_driver);
+}
+
+/**
+ * @}
+ */
+
Index: uspace/drv/root/virt/virt.ma
===================================================================
--- uspace/drv/root/virt/virt.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/drv/root/virt/virt.ma	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+10 virt
Index: uspace/lib/block/block.c
===================================================================
--- uspace/lib/block/block.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/block/block.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -194,4 +194,6 @@
 	if (devcon->cache)
 		(void) block_cache_fini(service_id);
+	
+	(void)bd_sync_cache(devcon->bd, 0, 0);
 	
 	devcon_remove(devcon);
@@ -877,26 +879,14 @@
  *
  * @return Allocated TOC structure.
- * @return NULL on failure.
- *
- */
-toc_block_t *block_get_toc(service_id_t service_id, uint8_t session)
+ * @return EOK on success or negative error code.
+ *
+ */
+int block_read_toc(service_id_t service_id, uint8_t session, void *buf,
+    size_t bufsize)
 {
 	devcon_t *devcon = devcon_search(service_id);
-	toc_block_t *toc = NULL;
-	int rc;
-	
-	assert(devcon);
-	
-	toc = (toc_block_t *) malloc(sizeof(toc_block_t));
-	if (toc == NULL)
-		return NULL;
-	
-	rc = bd_read_toc(devcon->bd, session, toc, sizeof(toc_block_t));
-	if (rc != EOK) {
-		free(toc);
-		return NULL;
-	}
-	
-	return toc;
+	
+	assert(devcon);
+	return bd_read_toc(devcon->bd, session, buf, bufsize);
 }
 
Index: uspace/lib/block/block.h
===================================================================
--- uspace/lib/block/block.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/block/block.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -99,17 +99,4 @@
 };
 
-typedef struct {
-	uint16_t size;
-	uint8_t first_session;
-	uint8_t last_session;
-	
-	uint8_t res0;
-	uint8_t adr_ctrl;
-	uint8_t first_track;
-	uint8_t res1;
-	
-	uint32_t first_lba;
-} __attribute__((packed)) toc_block_t;
-
 extern int block_init(exch_mgmt_t, service_id_t, size_t);
 extern void block_fini(service_id_t);
@@ -129,5 +116,5 @@
 extern int block_get_bsize(service_id_t, size_t *);
 extern int block_get_nblocks(service_id_t, aoff64_t *);
-extern toc_block_t *block_get_toc(service_id_t, uint8_t);
+extern int block_read_toc(service_id_t, uint8_t, void *, size_t);
 extern int block_read_direct(service_id_t, aoff64_t, size_t, void *);
 extern int block_read_bytes_direct(service_id_t, aoff64_t, size_t, void *);
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -50,4 +50,11 @@
 -include arch/$(UARCH)/Makefile.inc
 
+ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG)))
+ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG)))
+ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG)))
+
+PRE_DEPEND += $(ARCH_AUTOGENS_H)
+EXTRA_CLEAN += $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)
+
 GENERIC_SOURCES = \
 	generic/libc.c \
@@ -92,4 +99,6 @@
 	generic/io/input.c \
 	generic/io/io.c \
+	generic/io/chardev.c \
+	generic/io/chardev_srv.c \
 	generic/io/chargrid.c \
 	generic/io/output.c \
@@ -110,4 +119,5 @@
 	generic/iplink_srv.c \
 	generic/irc.c \
+	generic/irq.c \
 	generic/ieee_double.c \
 	generic/power_of_ten.c \
@@ -157,4 +167,9 @@
 include $(USPACE_PREFIX)/Makefile.common
 
+%.h: %.ag
+	$(AUTOGEN) probe $< >$<.probe.c
+	$(CC) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
+	$(AUTOGEN) generate $< <$<.probe.s >$@   
+
 $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
 	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@
Index: uspace/lib/c/arch/amd64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/amd64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/amd64/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,3 +37,8 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/istate_struct.ag \
+	arch/$(UARCH)/include/libarch/fibril_context.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
+
Index: pace/lib/c/arch/amd64/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/amd64/include/arch/context_offset.h
Index: uspace/lib/c/arch/amd64/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/fibril.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/amd64/include/libarch/fibril.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,5 +36,5 @@
 #define LIBC_amd64_FIBRIL_H_
 
-#include <sys/types.h>
+#include <libarch/fibril_context.h>
 
 /*
@@ -53,22 +53,4 @@
 	} while (0)
 
-/* We include only registers that must be preserved
- * during function call
- */
-typedef struct {
-	uint64_t sp;
-	uint64_t pc;
-
-	uint64_t rbx;
-	uint64_t rbp;
-
-	uint64_t r12;
-	uint64_t r13;
-	uint64_t r14;
-	uint64_t r15;
-
-	uint64_t tls;
-} context_t;
-
 static inline uintptr_t context_get_fp(context_t *ctx)
 {
Index: uspace/lib/c/arch/amd64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/amd64/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,83 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                #
+                # We include only registers that must be preserved
+                # during function call.
+                #
+
+                {
+                        name : sp,
+                        type : uint64_t
+                },
+                {
+                        name : pc,
+                        type : uint64_t
+                },
+
+                {
+                        name : rbx,
+                        type : uint64_t
+                },
+                {
+                        name : rbp,
+                        type : uint64_t
+                },
+
+                {
+                        name : r12,
+                        type : uint64_t
+                },
+                {
+                        name : r13,
+                        type : uint64_t
+                },
+                {
+                        name : r14,
+                        type : uint64_t
+                },
+                {
+                        name : r15,
+                        type : uint64_t
+                },
+
+                {
+                        name : tls,
+                        type : uint64_t
+                }
+        ]
+}
Index: uspace/lib/c/arch/amd64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/amd64/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/amd64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/amd64/src/fibril.S
===================================================================
--- uspace/lib/c/arch/amd64/src/fibril.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/amd64/src/fibril.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -32,5 +32,5 @@
 .global context_restore
 
-#include <libarch/context_offset.h>
+#include <libarch/fibril_context.h>
 
 ## Save current CPU context
@@ -42,12 +42,20 @@
 	movq (%rsp), %rdx     # the caller's return %eip
 	
-	# in %edi is passed 1st argument
-	CONTEXT_SAVE_ARCH_CORE %rdi %rdx 
+	# in %rdi is passed 1st argument
+	movq %rdx, CONTEXT_OFFSET_PC(%rdi)
+	movq %rsp, CONTEXT_OFFSET_SP(%rdi)
+	
+	movq %rbx, CONTEXT_OFFSET_RBX(%rdi)
+	movq %rbp, CONTEXT_OFFSET_RBP(%rdi)
+	movq %r12, CONTEXT_OFFSET_R12(%rdi)
+	movq %r13, CONTEXT_OFFSET_R13(%rdi)
+	movq %r14, CONTEXT_OFFSET_R14(%rdi)
+	movq %r15, CONTEXT_OFFSET_R15(%rdi)
 	
 	# save TLS
 	movq %fs:0, %rax
-	movq %rax, OFFSET_TLS(%rdi)
+	movq %rax, CONTEXT_OFFSET_TLS(%rdi)
 	
-	xorl %eax, %eax       # context_save returns 1
+	xorl %eax, %eax                      # context_save returns 1
 	incl %eax
 	ret
@@ -60,13 +68,23 @@
 context_restore:
 	
-	CONTEXT_RESTORE_ARCH_CORE %rdi %rdx
+	movq CONTEXT_OFFSET_R15(%rdi), %r15
+	movq CONTEXT_OFFSET_R14(%rdi), %r14
+	movq CONTEXT_OFFSET_R13(%rdi), %r13
+	movq CONTEXT_OFFSET_R12(%rdi), %r12
+	movq CONTEXT_OFFSET_RBP(%rdi), %rbp
+	movq CONTEXT_OFFSET_RBX(%rdi), %rbx
+	
+	movq CONTEXT_OFFSET_SP(%rdi), %rsp   # ctx->sp -> %rsp
+	
+	movq CONTEXT_OFFSET_PC(%rdi), %rdx
 	
 	movq %rdx,(%rsp)
 	
 	# Set thread local storage
-	movq OFFSET_TLS(%rdi), %rdi  # Set arg1 to TLS addr
-	movl $1, %eax                # SYS_TLS_SET
+	movq CONTEXT_OFFSET_TLS(%rdi), %rdi  # Set arg1 to TLS addr
+	movl $1, %eax                        # SYS_TLS_SET
 	syscall
 	
-	xorl %eax, %eax              # context_restore returns 0
+	xorl %eax, %eax                      # context_restore returns 0
 	ret
+
Index: uspace/lib/c/arch/arm32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/arm32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/arm32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,3 +39,8 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/istate_struct.ag \
+	arch/$(UARCH)/include/libarch/fibril_context.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
+
Index: uspace/lib/c/arch/arm32/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/fibril.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/arm32/include/libarch/fibril.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,4 +40,5 @@
 #include <align.h>
 #include <thread.h>
+#include <libarch/fibril_context.h>
 
 /** Size of a stack item */
@@ -66,24 +67,4 @@
 	} while (0)
 
-/** Fibril context.
- *
- *  Only registers preserved accross function calls are included. r9 is used 
- *  to store a TLS address. -ffixed-r9 gcc forces gcc not to use this
- *  register. -mtp=soft forces gcc to use #__aeabi_read_tp to obtain
- *  TLS address.
- */
-typedef struct  {
-	uint32_t sp;
-	uint32_t pc;
-	uint32_t r4;
-	uint32_t r5;
-	uint32_t r6;
-	uint32_t r7;
-	uint32_t r8;
-	uint32_t tls;	/* r9 */
-	uint32_t r10;
-	uint32_t fp;	/* r11 */
-} context_t;
-
 static inline uintptr_t context_get_fp(context_t *ctx)
 {
Index: uspace/lib/c/arch/arm32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/arm32/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,89 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <sys/types.h>
+                },
+        ],
+
+       #
+       # Only registers preserved accross function calls are included. r9 is
+       # used to store a TLS address. -ffixed-r9 gcc forces gcc not to use this
+       # register. -mtp=soft forces gcc to use #__aeabi_read_tp to obtain
+       # TLS address.
+       #
+        members : [
+                {
+                        name : sp,
+                        type : uintptr_t
+                },
+                {
+                        name : pc,
+                        type : uintptr_t
+                },
+
+                {
+                        name : r4,
+                        type : uint32_t
+                },
+                {
+                        name : r5,
+                        type : uint32_t
+                },
+                {
+                        name : r6,
+                        type : uint32_t
+                },
+                {
+                        name : r7,
+                        type : uint32_t
+                },
+                {
+                        name : r8,
+                        type : uint32_t
+                },
+                {
+                        # r9
+                        name : tls,
+                        type : uint32_t
+                },
+                {
+                        name : r10,
+                        type : uint32_t
+                },
+                {
+                        # r11
+                        name : fp,
+                        type : uint32_t
+                }
+        ]
+}
+
Index: uspace/lib/c/arch/arm32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/arm32/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/arm32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ia32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ia32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/ia32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,3 +39,7 @@
 	arch/$(UARCH)/src/rtld/reloc.c
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/istate_struct.ag \
+	arch/$(UARCH)/include/libarch/fibril_context.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/ia32/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/ia32/include/arch/context_offset.h
Index: uspace/lib/c/arch/ia32/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/fibril.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/ia32/include/libarch/fibril.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,4 +37,5 @@
 
 #include <sys/types.h>
+#include <libarch/fibril_context.h>
 
 /*
@@ -53,20 +54,4 @@
 	} while (0)
 
-/*
- * We include only registers that must be preserved
- * during function call
- */
-typedef struct {
-	uint32_t sp;
-	uint32_t pc;
-	
-	uint32_t ebx;
-	uint32_t esi;
-	uint32_t edi;
-	uint32_t ebp;
-	
-	uint32_t tls;
-} context_t;
-
 static inline uintptr_t context_get_fp(context_t *ctx)
 {
Index: uspace/lib/c/arch/ia32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/ia32/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,74 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                #
+                # We include only registers that must be preserved
+                # during function call.
+                #
+
+                {
+                        name : sp,
+                        type : uint32_t
+                },
+                {
+                        name : pc,
+                        type : uint32_t
+                },
+
+                {
+                        name : ebx,
+                        type : uint32_t
+                },
+                {
+                        name : esi,
+                        type : uint32_t
+                },
+                {
+                        name : edi,
+                        type : uint32_t
+                },
+                {
+                        name : ebp,
+                        type : uint32_t
+                },
+
+                {
+                        name : tls,
+                        type : uint32_t
+                }
+        ]
+}
Index: uspace/lib/c/arch/ia32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/ia32/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ia32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ia32/src/fibril.S
===================================================================
--- uspace/lib/c/arch/ia32/src/fibril.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/ia32/src/fibril.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -27,5 +27,5 @@
 #
 
-#include <libarch/context_offset.h>
+#include <libarch/fibril_context.h>
 
 .text
@@ -44,11 +44,16 @@
 	
 	# save registers to the context structure
-	CONTEXT_SAVE_ARCH_CORE %edx %eax
+	movl %esp, CONTEXT_OFFSET_SP(%edx)	# %esp -> ctx->sp
+	movl %eax, CONTEXT_OFFSET_PC(%edx)	# %eip -> ctx->pc
+	movl %ebx, CONTEXT_OFFSET_EBX(%edx)	# %ebx -> ctx->ebx
+	movl %esi, CONTEXT_OFFSET_ESI(%edx)	# %esi -> ctx->esi
+	movl %edi, CONTEXT_OFFSET_EDI(%edx)	# %edi -> ctx->edi
+	movl %ebp, CONTEXT_OFFSET_EBP(%edx)	# %ebp -> ctx->ebp
 	
 	# save TLS
 	movl %gs:0, %eax
-	movl %eax, OFFSET_TLS(%edx)     # tls -> ctx->tls
+	movl %eax, CONTEXT_OFFSET_TLS(%edx)	# tls -> ctx->tls
 	
-	xorl %eax, %eax     # context_save returns 1
+	xorl %eax, %eax		# context_save returns 1
 	incl %eax
 	ret
@@ -63,5 +68,10 @@
 	
 	# restore registers from the context structure
-	CONTEXT_RESTORE_ARCH_CORE %eax %edx
+	movl CONTEXT_OFFSET_SP(%eax),%esp	# ctx->sp -> %esp
+	movl CONTEXT_OFFSET_PC(%eax),%edx	# ctx->pc -> \pc
+	movl CONTEXT_OFFSET_EBX(%eax),%ebx	# ctx->ebx -> %ebx
+	movl CONTEXT_OFFSET_ESI(%eax),%esi	# ctx->esi -> %esi
+	movl CONTEXT_OFFSET_EDI(%eax),%edi	# ctx->edi -> %edi
+	movl CONTEXT_OFFSET_EBP(%eax),%ebp	# ctx->ebp -> %ebp
 	
 	movl %edx, 0(%esp)  # ctx->pc -> saver's return %eip
@@ -69,9 +79,10 @@
 	# set thread local storage
 	pushl %edx
-	movl OFFSET_TLS(%eax), %edx  # Set arg1 to TLS addr
-	movl $1, %eax                # Syscall SYS_TLS_SET
+	movl CONTEXT_OFFSET_TLS(%eax), %edx	# Set arg1 to TLS addr
+	movl $1, %eax				# Syscall SYS_TLS_SET
 	int $0x30
 	popl %edx
 	
-	xorl %eax, %eax     # context_restore returns 0
+	xorl %eax, %eax		# context_restore returns 0
 	ret
+
Index: uspace/lib/c/arch/ia64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ia64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/ia64/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,3 +38,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/istate_struct.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/ia64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/ia64/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ia64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/mips32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/mips32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,3 +37,7 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/istate_struct.ag \
+	arch/$(UARCH)/include/libarch/fibril_context.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/mips32/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips32/include/arch/context_offset.h
Index: uspace/lib/c/arch/mips32/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/fibril.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/mips32/include/libarch/fibril.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,4 +38,5 @@
 
 #include <sys/types.h>
+#include <libarch/fibril_context.h>
 #include <libarch/stack.h>
 #include <align.h>
@@ -56,34 +57,4 @@
 	} while (0)
 
-typedef struct  {
-	uint32_t sp;
-	uint32_t pc;
-	
-	uint32_t s0;
-	uint32_t s1;
-	uint32_t s2;
-	uint32_t s3;
-	uint32_t s4;
-	uint32_t s5;
-	uint32_t s6;
-	uint32_t s7;
-	uint32_t s8;
-	uint32_t gp;
-	uint32_t tls; /* Thread local storage(=k1) */
-
-	uint32_t f20;
-	uint32_t f21;
-	uint32_t f22;
-	uint32_t f23;
-	uint32_t f24;
-	uint32_t f25;
-	uint32_t f26;
-	uint32_t f27;
-	uint32_t f28;
-	uint32_t f29;
-	uint32_t f30;
-	
-} context_t;
-
 static inline uintptr_t context_get_fp(context_t *ctx)
 {
Index: uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,138 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : sp,
+                        type : uint32_t
+                },
+                {
+                        name : pc,
+                        type : uint32_t
+                },
+
+                {
+                        name : s0,
+                        type : uint32_t
+                },
+                {
+                        name : s1,
+                        type : uint32_t
+                },
+                {
+                        name : s2,
+                        type : uint32_t
+                },
+                {
+                        name : s3,
+                        type : uint32_t
+                },
+                {
+                        name : s4,
+                        type : uint32_t
+                },
+                {
+                        name : s5,
+                        type : uint32_t
+                },
+                {
+                        name : s6,
+                        type : uint32_t
+                },
+                {
+                        name : s7,
+                        type : uint32_t
+                },
+                {
+                        name : s8,
+                        type : uint32_t
+                },
+                {
+                        name : gp,
+                        type : uint32_t
+                },
+                {
+                        # Thread local storage (k1)
+                        name : tls,
+                        type : uint32_t
+                },
+
+                {
+                        name : f20,
+                        type : uint32_t
+                },
+                {
+                        name : f21,
+                        type : uint32_t
+                },
+                {
+                        name : f22,
+                        type : uint32_t
+                },
+                {
+                        name : f23,
+                        type : uint32_t
+                },
+                {
+                        name : f24,
+                        type : uint32_t
+                },
+                {
+                        name : f25,
+                        type : uint32_t
+                },
+                {
+                        name : f26,
+                        type : uint32_t
+                },
+                {
+                        name : f27,
+                        type : uint32_t
+                },
+                {
+                        name : f28,
+                        type : uint32_t
+                },
+                {
+                        name : f29,
+                        type : uint32_t
+                },
+                {
+                        name : f30,
+                        type : uint32_t
+                }
+        ]
+}
Index: uspace/lib/c/arch/mips32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/mips32/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/mips32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/mips32/src/fibril.S
===================================================================
--- uspace/lib/c/arch/mips32/src/fibril.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/mips32/src/fibril.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -32,5 +32,5 @@
 .set noreorder
 
-#include <libarch/context_offset.h>
+#include <libarch/fibril_context.h>
 
 .global context_save
@@ -38,5 +38,54 @@
 
 context_save:
-	CONTEXT_SAVE_ARCH_CORE $a0
+	sw $s0, CONTEXT_OFFSET_S0($a0)
+	sw $s1, CONTEXT_OFFSET_S1($a0)
+	sw $s2, CONTEXT_OFFSET_S2($a0)
+	sw $s3, CONTEXT_OFFSET_S3($a0)
+	sw $s4, CONTEXT_OFFSET_S4($a0)
+	sw $s5, CONTEXT_OFFSET_S5($a0)
+	sw $s6, CONTEXT_OFFSET_S6($a0)
+	sw $s7, CONTEXT_OFFSET_S7($a0)
+	sw $s8, CONTEXT_OFFSET_S8($a0)
+	sw $gp, CONTEXT_OFFSET_GP($a0)
+	
+	sw $k1, CONTEXT_OFFSET_TLS($a0)
+	
+#ifdef CONFIG_FPU
+	mfc1 $t0, $20
+	sw $t0, CONTEXT_OFFSET_F20($a0)
+	
+	mfc1 $t0, $21
+	sw $t0, CONTEXT_OFFSET_F21($a0)
+	
+	mfc1 $t0, $22
+	sw $t0, CONTEXT_OFFSET_F22($a0)
+	
+	mfc1 $t0, $23
+	sw $t0, CONTEXT_OFFSET_F23($a0)
+	
+	mfc1 $t0, $24
+	sw $t0, CONTEXT_OFFSET_F24($a0)
+	
+	mfc1 $t0, $25
+	sw $t0, CONTEXT_OFFSET_F25($a0)
+	
+	mfc1 $t0, $26
+	sw $t0, CONTEXT_OFFSET_F26($a0)
+	
+	mfc1 $t0, $27
+	sw $t0, CONTEXT_OFFSET_F27($a0)
+	
+	mfc1 $t0, $28
+	sw $t0, CONTEXT_OFFSET_F28($a0)
+	
+	mfc1 $t0, $29
+	sw $t0, CONTEXT_OFFSET_F29($a0)
+	
+	mfc1 $t0, $30
+	sw $t0, CONTEXT_OFFSET_F30($a0)
+#endif /* CONFIG_FPU */
+	
+	sw $ra, CONTEXT_OFFSET_PC($a0)
+	sw $sp, CONTEXT_OFFSET_SP($a0)
 	
 	# context_save returns 1
@@ -45,5 +94,53 @@
 
 context_restore:
-	CONTEXT_RESTORE_ARCH_CORE $a0
+	lw $s0, CONTEXT_OFFSET_S0($a0)
+	lw $s1, CONTEXT_OFFSET_S1($a0)
+	lw $s2, CONTEXT_OFFSET_S2($a0)
+	lw $s3, CONTEXT_OFFSET_S3($a0)
+	lw $s4, CONTEXT_OFFSET_S4($a0)
+	lw $s5, CONTEXT_OFFSET_S5($a0)
+	lw $s6, CONTEXT_OFFSET_S6($a0)
+	lw $s7, CONTEXT_OFFSET_S7($a0)
+	lw $s8, CONTEXT_OFFSET_S8($a0)
+	lw $gp, CONTEXT_OFFSET_GP($a0)
+	lw $k1, CONTEXT_OFFSET_TLS($a0)
+	
+#ifdef CONFIG_FPU
+	lw $t0, CONTEXT_OFFSET_F20($a0)
+	mtc1 $t0, $20
+	
+	lw $t0, CONTEXT_OFFSET_F21($a0)
+	mtc1 $t0, $21
+	
+	lw $t0, CONTEXT_OFFSET_F22($a0)
+	mtc1 $t0, $22
+	
+	lw $t0, CONTEXT_OFFSET_F23($a0)
+	mtc1 $t0, $23
+	
+	lw $t0, CONTEXT_OFFSET_F24($a0)
+	mtc1 $t0, $24
+	
+	lw $t0, CONTEXT_OFFSET_F25($a0)
+	mtc1 $t0, $25
+	
+	lw $t0, CONTEXT_OFFSET_F26($a0)
+	mtc1 $t0, $26
+	
+	lw $t0, CONTEXT_OFFSET_F27($a0)
+	mtc1 $t0, $27
+	
+	lw $t0, CONTEXT_OFFSET_F28($a0)
+	mtc1 $t0, $28
+	
+	lw $t0, CONTEXT_OFFSET_F29($a0)
+	mtc1 $t0, $29
+	
+	lw $t0, CONTEXT_OFFSET_F30($a0)
+	mtc1 $t0, $30
+#endif /* CONFIG_FPU */
+	
+	lw $ra, CONTEXT_OFFSET_PC($a0)
+	lw $sp, CONTEXT_OFFSET_SP($a0)
 	
 	# Just for the jump into first function,
Index: uspace/lib/c/arch/mips32eb/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32eb/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/mips32eb/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,3 +37,7 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/istate_struct.ag \
+	arch/$(UARCH)/include/libarch/fibril_context.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/mips32eb/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../mips32/include/libarch/context_offset.h
Index: uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../mips32/include/libarch/fibril_context.ag
Index: uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../mips32/include/libarch/istate_struct.ag
Index: pace/lib/c/arch/mips64/Makefile.common
===================================================================
--- uspace/lib/c/arch/mips64/Makefile.common	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,36 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-GCC_CFLAGS += -msoft-float -mips3 -mabi=64
-BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
-AFLAGS = -64
-
-ENDIANESS = LE
-
-BFD_ARCH = mips:4000
-BFD_NAME = elf64-tradlittlemips
Index: pace/lib/c/arch/mips64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-ARCH_SOURCES = \
-	arch/$(UARCH)/src/entry.S \
-	arch/$(UARCH)/src/entryjmp.S \
-	arch/$(UARCH)/src/thread_entry.S \
-	arch/$(UARCH)/src/syscall.c \
-	arch/$(UARCH)/src/fibril.S \
-	arch/$(UARCH)/src/tls.c \
-	arch/$(UARCH)/src/stacktrace.c \
-	arch/$(UARCH)/src/stacktrace_asm.S
-
-.PRECIOUS: arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/mips64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/mips64/_link.ld.in	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,76 +1,0 @@
-OUTPUT_FORMAT(elf64-tradlittlemips)
-STARTUP(LIBC_PATH/arch/UARCH/src/entry.o)
-ENTRY(__entry)
-
-PHDRS {
-#ifdef LOADER
-	interp PT_INTERP;
-	text PT_LOAD FILEHDR PHDRS FLAGS(5);
-#else
-	text PT_LOAD FLAGS(5);
-#endif
-	data PT_LOAD FLAGS(6);
-}
-
-SECTIONS {
-#ifdef LOADER
-	. = 0x70004000 + SIZEOF_HEADERS;
-#else
-	. = 0x4000 + SIZEOF_HEADERS;
-#endif
-	
-	.init : {
-		*(.init);
-	} :text
-	
-	.text : {
-		*(.text .text.*);
-		*(.rodata .rodata.*);
-	} :text
-	
-#ifdef LOADER
-	.interp : {
-		*(.interp);
-	} :interp :text
-#endif
-	
-	. = . + 0x4000;
-	
-	.data : {
-		*(.data);
-		*(.data.rel*);
-	} :data
-	
-	.got : {
-		_gp = .;
-		*(.got);
-	} :data
-	
-	.tdata : {
-		_tdata_start = .;
-		*(.tdata);
-		_tdata_end = .;
-	} :data
-	
-	.tbss : {
-		_tbss_start = .;
-		*(.tbss);
-		_tbss_end = .;
-	} :data
-	
-	_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
-	
-	.sbss : {
-		*(.scommon);
-		*(.sbss);
-	}
-	
-	.bss : {
-		*(.bss);
-		*(COMMON);
-	} :data
-	
-	/DISCARD/ : {
-		*(*);
-	}
-}
Index: pace/lib/c/arch/mips64/include/libarch/atomic.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/atomic.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/*
- * Copyright (c) 2005 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 libcmips64
- * @{
- */
-/** @file
- * @ingroup libcmips64
- */
-
-#ifndef LIBC_mips64_ATOMIC_H_
-#define LIBC_mips64_ATOMIC_H_
-
-#define LIBC_ARCH_ATOMIC_H_
-
-#include <atomicdflt.h>
-
-#define atomic_inc(x)  ((void) atomic_add(x, 1))
-#define atomic_dec(x)  ((void) atomic_add(x, -1))
-
-#define atomic_postinc(x)  (atomic_add(x, 1) - 1)
-#define atomic_postdec(x)  (atomic_add(x, -1) + 1)
-
-#define atomic_preinc(x)  atomic_add(x, 1)
-#define atomic_predec(x)  atomic_add(x, -1)
-
-/* Atomic addition of immediate value.
- *
- * @param val Memory location to which will be the immediate value added.
- * @param i   Signed immediate that will be added to *val.
- *
- * @return Value after addition.
- *
- */
-static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
-{
-	atomic_count_t tmp;
-	atomic_count_t v;
-	
-	asm volatile (
-		"1:\n"
-		"	lld %0, %1\n"
-		"	daddu %0, %0, %3\n"  /* same as add, but never traps on overflow */
-		"	move %2, %0\n"
-		"	scd %0, %1\n"
-		"	beq %0, %4, 1b\n"    /* if the atomic operation failed, try again */
-		"	nop\n"
-		: "=&r" (tmp),
-		  "+m" (val->count),
-		  "=&r" (v)
-		: "r" (i),
-		  "i" (0)
-	);
-	
-	return v;
-}
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/barrier.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/barrier.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips64/include/arch/barrier.h
Index: pace/lib/c/arch/mips64/include/libarch/config.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/config.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libcmips64
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_mips64_CONFIG_H_
-#define LIBC_mips64_CONFIG_H_
-
-#define PAGE_WIDTH  14
-#define PAGE_SIZE   (1 << PAGE_WIDTH)
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips64/include/arch/context_offset.h
Index: pace/lib/c/arch/mips64/include/libarch/cp0.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/cp0.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips64/include/arch/cp0.h
Index: pace/lib/c/arch/mips64/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/ddi.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*
- * Copyright (c) 2009 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @file
- * @ingroup libcmips64
- */
-
-#ifndef LIBC_mips64_DDI_H_
-#define LIBC_mips64_DDI_H_
-
-#include <sys/types.h>
-#include <libarch/types.h>
-
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
-{
-	*port = v;
-}
-
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
-{
-	*port = v;
-}
-
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
-{
-	*port = v;
-}
-
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
-{
-	return *port;
-}
-
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
-{
-	return *port;
-}
-
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
-{
-	return *port;
-}
-
-#endif
Index: pace/lib/c/arch/mips64/include/libarch/elf.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/elf.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips64/include/arch/elf.h
Index: pace/lib/c/arch/mips64/include/libarch/elf_linux.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/elf_linux.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,55 +1,0 @@
-/*
- * Copyright (c) 2011 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 libcmips64
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_mips64_ELF_LINUX_H_
-#define LBIC_mips64_ELF_LINUX_H_
-
-#include <libarch/istate.h>
-#include <sys/types.h>
-
-typedef struct {
-	/* TODO */
-	uint64_t pad[16];
-} elf_regs_t;
-
-static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs)
-{
-	/* TODO */
-	(void) istate; (void) elf_regs;
-}
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/faddr.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/faddr.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2005 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 libcmips64
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_mips64_FADDR_H_
-#define LIBC_mips64_FADDR_H_
-
-#include <libarch/types.h>
-
-#define FADDR(fptr)  ((uintptr_t) (fptr))
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/fibril.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,95 +1,0 @@
-/*
- * Copyright (c) 2006 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libcmips64
- * @{
- */
-/** @file
- * @ingroup libcmips64
- */
-
-#ifndef LIBC_mips64_FIBRIL_H_
-#define LIBC_mips64_FIBRIL_H_
-
-#include <sys/types.h>
-#include <libarch/stack.h>
-#include <align.h>
-
-#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
-
-/*
- * We define our own context_set, because we need to set
- * the TLS pointer to the tcb + 0x7000
- *
- * See tls_set in thread.h
- */
-#define context_set(c, _pc, stack, size, ptls) \
-	do { \
-		(c)->pc = (sysarg_t) (_pc); \
-		(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
-		(c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t); \
-	} while (0)
-
-typedef struct {
-	uint64_t sp;
-	uint64_t pc;
-	
-	uint64_t s0;
-	uint64_t s1;
-	uint64_t s2;
-	uint64_t s3;
-	uint64_t s4;
-	uint64_t s5;
-	uint64_t s6;
-	uint64_t s7;
-	uint64_t s8;
-	uint64_t gp;
-	uint64_t tls; /* Thread local storage (k1) */
-	
-	uint64_t f20;
-	uint64_t f21;
-	uint64_t f22;
-	uint64_t f23;
-	uint64_t f24;
-	uint64_t f25;
-	uint64_t f26;
-	uint64_t f27;
-	uint64_t f28;
-	uint64_t f29;
-	uint64_t f30;
-} context_t;
-
-static inline uintptr_t context_get_fp(context_t *ctx)
-{
-	return ctx->sp;
-}
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/inttypes.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/inttypes.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * Copyright (c) 2010 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 libcmips64
- * @{
- */
-
-#ifndef LIBC_mips64_INTTYPES_H_
-#define LIBC_mips64_INTTYPES_H_
-
-#define PRIdn  PRId64  /**< Format for native_t. */
-#define PRIun  PRIu64  /**< Format for sysarg_t. */
-#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
-#define PRIua  PRIu64  /**< Format for atomic_count_t. */
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/istate.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/istate.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips64/include/arch/istate.h
Index: pace/lib/c/arch/mips64/include/libarch/regname.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/regname.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips64/include/arch/asm/regname.h
Index: pace/lib/c/arch/mips64/include/libarch/stack.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/stack.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * 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 libcmips64
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_mips64_STACK_H_
-#define LIBC_mips64_STACK_H_
-
-#define STACK_ITEM_SIZE  8
-#define STACK_ALIGNMENT  8
-#define ABI_STACK_FRAME  64
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/syscall.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/syscall.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/**
- * @file
- */
-
-#ifndef LIBC_mips64_SYSCALL_H_
-#define LIBC_mips64_SYSCALL_H_
-
-#define LIBARCH_SYSCALL_GENERIC
-
-#include <syscall.h>
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/thread.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/thread.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,42 +1,0 @@
-/*
- * Copyright (c) 2006 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libcmips64
- * @{
- */
-/** @file
- * @ingroup libcmips64
- */
-
-#ifndef LIBC_mips64_THREAD_H_
-#define LIBC_mips64_THREAD_H_
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/tls.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/tls.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/*
- * Copyright (c) 2006 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libcmips64
- * @{
- */
-/** @file
- * @ingroup libcmips64
- */
-
-/* TLS for MIPS is described in http://www.linux-mips.org/wiki/NPTL */
-
-#ifndef LIBC_mips64_TLS_H_
-#define LIBC_mips64_TLS_H_
-
-/*
- * FIXME: Note that the use of variant I contradicts the observations made in
- * the note below. Nevertheless the scheme we have used for allocating and
- * deallocatin TLS corresponds to TLS variant I.
- */
-#define CONFIG_TLS_VARIANT_1
-
-/* I did not find any specification (neither MIPS nor PowerPC), but
- * as I found it
- * - it uses Variant II
- * - TCB is at Address(First TLS Block)+0x7000.
- * - DTV is at Address(First TLS Block)+0x8000
- * - What would happen if the TLS data was larger then 0x7000?
- * - The linker never accesses DTV directly, has the second definition any
- *   sense?
- * We will make it this way:
- * - TCB is at TP-0x7000-sizeof(tcb)
- * - No assumption about DTV etc., but it will not have a fixed address
- */
-#define MIPS_TP_OFFSET 0x7000
-
-typedef struct {
-	void *fibril_data;
-} tcb_t;
-
-static inline void __tcb_set(tcb_t *tcb)
-{
-	void *tp = tcb;
-	tp += MIPS_TP_OFFSET + sizeof(tcb_t);
-	
-	/* Move tls to K1 */
-	asm volatile (
-		"add $27, %0, $0"
-		:: "r" (tp)
-	);
-}
-
-static inline tcb_t *__tcb_get(void)
-{
-	void *retval;
-	
-	asm volatile (
-		"add %0, $27, $0"
-		: "=r" (retval)
-	);
-	
-	return (tcb_t *) (retval - MIPS_TP_OFFSET - sizeof(tcb_t));
-}
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/types.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,63 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libcmips64
- * @{
- */
-/** @file
- * @ingroup libcmips32
- */
-
-#ifndef LIBC_mips64_TYPES_H_
-#define LIBC_mips64_TYPES_H_
-
-#define __64_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT64_MIN
-#define SIZE_MAX  UINT64_MAX
-
-#define SSIZE_MIN  INT64_MIN
-#define SSIZE_MAX  INT64_MAX
-
-typedef uint64_t sysarg_t;
-typedef int64_t native_t;
-
-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;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/src/entry.S
===================================================================
--- uspace/lib/c/arch/mips64/src/entry.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-#include <libarch/stack.h>
-
-.text
-.section .init, "ax"
-
-.global __entry
-
-.set noreorder
-.option pic2
-
-## User-space task entry point
-#
-# $a0 ($4) contains the PCB pointer
-#
-.ent __entry
-__entry:
-	.frame $sp, ABI_STACK_FRAME, $ra
-	.cpload $t9
-	
-	# Allocate the stack frame.
-	addiu $sp, -ABI_STACK_FRAME
-	
-	# Allow PIC code
-	.cprestore 16
-	
-	# Pass pcb_ptr to __main() as the first argument. It is already
-	# in $a0. As the first argument is passed in $a0, no operation
-	# is needed.
-	
-	jal __main
-	nop
-	
-	#
-	# Not reached.
-	#
-	addiu $sp, ABI_STACK_FRAME
-.end __entry
Index: pace/lib/c/arch/mips64/src/entryjmp.S
===================================================================
--- uspace/lib/c/arch/mips64/src/entryjmp.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,53 +1,0 @@
-#
-# Copyright (c) 2008 Jiri Svoboda
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-#include <libarch/stack.h>
-
-.text
-.section .text
-.global entry_point_jmp
-.set noreorder
-
-## void entry_point_jmp(void *entry_point, void *pcb);
-#
-# $a0 (=$4) contains entry_point
-# $a1 (=$5) contains pcb
-#
-# Jump to program entry point
-.ent entry_point_jmp
-entry_point_jmp:
-	# tmp := entry_point
-	move $t9, $a0
-	
-	# Pass pcb to the entry point in $a0
-	move $a0, $a1
-	
-	jr $t9
-	addiu $sp, -ABI_STACK_FRAME
-	addiu $sp, ABI_STACK_FRAME
-.end entry_point_jmp
Index: pace/lib/c/arch/mips64/src/fibril.S
===================================================================
--- uspace/lib/c/arch/mips64/src/fibril.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,55 +1,0 @@
-#
-# Copyright (c) 2003-2004 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-.text
-
-.set noat
-.set noreorder
-
-#include <libarch/context_offset.h>
-
-.global context_save
-.global context_restore
-
-context_save:
-	CONTEXT_SAVE_ARCH_CORE $a0
-	
-	# context_save returns 1
-	j $ra
-	li $v0, 1
-
-context_restore:
-	CONTEXT_RESTORE_ARCH_CORE $a0
-	
-	# Just for the jump into first function,
-	# but one instruction should not bother us
-	move $t9, $ra
-	
-	# context_restore returns 0
-	j $ra
-	xor $v0, $v0
Index: pace/lib/c/arch/mips64/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/mips64/src/stacktrace.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,62 +1,0 @@
-/*
- * Copyright (c) 2010 Jakub Jermar
- * Copyright (c) 2010 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 libcmips64 mips64
- * @ingroup lc
- * @{
- */
-/** @file
- */
-
-#include <sys/types.h>
-#include <stdbool.h>
-#include <errno.h>
-
-#include <stacktrace.h>
-
-bool stacktrace_fp_valid(stacktrace_t *st, uintptr_t fp)
-{
-	(void) st; (void) fp;
-	return false;
-}
-
-int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
-{
-	(void) st; (void) fp; (void) prev;
-	return ENOTSUP;
-}
-
-int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
-{
-	(void) st; (void) fp; (void) ra;
-	return ENOTSUP;
-}
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/src/stacktrace_asm.S
===================================================================
--- uspace/lib/c/arch/mips64/src/stacktrace_asm.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,42 +1,0 @@
-#
-# Copyright (c) 2009 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-.text
-
-.set noat
-.set noreorder
-
-.global stacktrace_prepare
-.global stacktrace_fp_get
-.global stacktrace_pc_get
-
-stacktrace_prepare:
-stacktrace_fp_get:
-stacktrace_pc_get:
-	j $ra
-	xor $v0, $v0
Index: pace/lib/c/arch/mips64/src/syscall.c
===================================================================
--- uspace/lib/c/arch/mips64/src/syscall.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,70 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libcmips64
- * @{
- */
-/** @file
-  * @ingroup libcmips64
- */
-
-#include <libc.h>
-
-sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2, const sysarg_t p3,
-    const sysarg_t p4, const sysarg_t p5, const sysarg_t p6, const syscall_t id)
-{
-	register sysarg_t __mips_reg_a0 asm("$4") = p1;
-	register sysarg_t __mips_reg_a1 asm("$5") = p2;
-	register sysarg_t __mips_reg_a2 asm("$6") = p3;
-	register sysarg_t __mips_reg_a3 asm("$7") = p4;
-	register sysarg_t __mips_reg_t0 asm("$8") = p5;
-	register sysarg_t __mips_reg_t1 asm("$9") = p6;
-	register sysarg_t __mips_reg_v0 asm("$2") = id;
-	
-	asm volatile (
-		"syscall\n"
-		: "=r" (__mips_reg_v0)
-		: "r" (__mips_reg_a0),
-		  "r" (__mips_reg_a1),
-		  "r" (__mips_reg_a2),
-		  "r" (__mips_reg_a3),
-		  "r" (__mips_reg_t0),
-		  "r" (__mips_reg_t1),
-		  "r" (__mips_reg_v0)
-		/*
-		 * We are a function call, although
-		 * C does not know it
-		 */
-		: "%ra"
-	);
-	
-	return __mips_reg_v0;
-}
-
-/** @}
- */
Index: pace/lib/c/arch/mips64/src/thread_entry.S
===================================================================
--- uspace/lib/c/arch/mips64/src/thread_entry.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#
-# Copyright (c) 2006 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-#include <libarch/stack.h>
-
-.text
-
-.set noat
-.set noreorder
-.option pic2
-
-.globl __thread_entry
-
-## User-space thread entry point for all but the first threads.
-#
-#
-.ent __thread_entry
-__thread_entry:
-	.frame $sp, ABI_STACK_FRAME, $ra
-	.cpload $t9
-	
-	#
-	# v0 contains address of uarg.
-	#
-	add $a0, $v0, 0
-	
-	# Allocate the stack frame.
-	addiu $sp, -ABI_STACK_FRAME
-	
-	# Allow PIC code
-	.cprestore 16
-	
-	jal __thread_main
-	nop
-	
-	#
-	# Not reached.
-	#
-	addiu $sp, ABI_STACK_FRAME
-.end __thread_entry
Index: pace/lib/c/arch/mips64/src/tls.c
===================================================================
--- uspace/lib/c/arch/mips64/src/tls.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Copyright (c) 2006 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libcmips64
- * @{
- */
-/** @file
- * @ingroup libcmips64
- */
-
-#include <tls.h>
-#include <sys/types.h>
-
-tcb_t *tls_alloc_arch(void **data, size_t size)
-{
-	return tls_alloc_variant_1(data, size);
-}
-
-void tls_free_arch(tcb_t *tcb, size_t size)
-{
-	tls_free_variant_1(tcb, size);
-}
-
-/** @}
- */
Index: uspace/lib/c/arch/ppc32/Makefile.common
===================================================================
--- uspace/lib/c/arch/ppc32/Makefile.common	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/ppc32/Makefile.common	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -27,5 +27,12 @@
 #
 
-GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
+
+ifeq ($(CONFIG_FPU),y)
+FLOATS=hard
+else
+FLOATS=soft
+endif
+
+GCC_CFLAGS += -mcpu=powerpc -m$(FLOATS)-float -m32
 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
 AFLAGS = -a32
Index: uspace/lib/c/arch/ppc32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ppc32/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/ppc32/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,3 +37,7 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/istate_struct.ag \
+	arch/$(UARCH)/include/libarch/fibril_context.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/ppc32/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/context_offset.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/ppc32/include/arch/context_offset.h
Index: uspace/lib/c/arch/ppc32/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/fibril.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/ppc32/include/libarch/fibril.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,4 +37,5 @@
 
 #include <sys/types.h>
+#include <libarch/fibril_context.h>
 
 #define SP_DELTA  16
@@ -53,32 +54,4 @@
 	} while (0)
 
-typedef struct {
-	uint32_t sp;
-	uint32_t pc;
-	
-	uint32_t tls;
-	uint32_t r13;
-	uint32_t r14;
-	uint32_t r15;
-	uint32_t r16;
-	uint32_t r17;
-	uint32_t r18;
-	uint32_t r19;
-	uint32_t r20;
-	uint32_t r21;
-	uint32_t r22;
-	uint32_t r23;
-	uint32_t r24;
-	uint32_t r25;
-	uint32_t r26;
-	uint32_t r27;
-	uint32_t r28;
-	uint32_t r29;
-	uint32_t r30;
-	uint32_t r31;
-	
-	uint32_t cr;
-} __attribute__ ((packed)) context_t;
-
 static inline uintptr_t context_get_fp(context_t *ctx)
 {
Index: uspace/lib/c/arch/ppc32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/ppc32/include/libarch/fibril_context.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,134 @@
+# Copyright (c) 2014 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : context,
+
+        includes : [
+                {
+                        include : <sys/types.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : sp,
+                        type : uint32_t
+                },
+                {
+                        name : pc,
+                        type : uint32_t
+                },
+
+                {
+                        name : tls,
+                        type : uint32_t
+                },
+                {
+                        name : r13,
+                        type : uint32_t
+                },
+                {
+                        name : r14,
+                        type : uint32_t
+                },
+                {
+                        name : r15,
+                        type : uint32_t
+                },
+                {
+                        name : r16,
+                        type : uint32_t
+                },
+                {
+                        name : r17,
+                        type : uint32_t
+                },
+                {
+                        name : r18,
+                        type : uint32_t
+                },
+                {
+                        name : r19,
+                        type : uint32_t
+                },
+                {
+                        name : r20,
+                        type : uint32_t
+                },
+                {
+                        name : r21,
+                        type : uint32_t
+                },
+                {
+                        name : r22,
+                        type : uint32_t
+                },
+                {
+                        name : r23,
+                        type : uint32_t
+                },
+                {
+                        name : r24,
+                        type : uint32_t
+                },
+                {
+                        name : r25,
+                        type : uint32_t
+                },
+                {
+                        name : r26,
+                        type : uint32_t
+                },
+                {
+                        name : r27,
+                        type : uint32_t
+                },
+                {
+                        name : r28,
+                        type : uint32_t
+                },
+                {
+                        name : r29,
+                        type : uint32_t
+                },
+                {
+                        name : r30,
+                        type : uint32_t
+                },
+                {
+                        name : r31,
+                        type : uint32_t
+                },
+
+                {
+                        name : cr,
+                        type : uint32_t
+                }
+        ]
+}
+
Index: uspace/lib/c/arch/ppc32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/ppc32/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ppc32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ppc32/src/fibril.S
===================================================================
--- uspace/lib/c/arch/ppc32/src/fibril.S	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/ppc32/src/fibril.S	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -33,14 +33,34 @@
 
 #include <libarch/regname.h>
-#include <libarch/context_offset.h>
+#include <libarch/fibril_context.h>
 
 context_save:
-	CONTEXT_SAVE_ARCH_CORE r3
+	stw sp, CONTEXT_OFFSET_SP(r3)
+	stw r2, CONTEXT_OFFSET_TLS(r3)
+	stw r13, CONTEXT_OFFSET_R13(r3)
+	stw r14, CONTEXT_OFFSET_R14(r3)
+	stw r15, CONTEXT_OFFSET_R15(r3)
+	stw r16, CONTEXT_OFFSET_R16(r3)
+	stw r17, CONTEXT_OFFSET_R17(r3)
+	stw r18, CONTEXT_OFFSET_R18(r3)
+	stw r19, CONTEXT_OFFSET_R19(r3)
+	stw r20, CONTEXT_OFFSET_R20(r3)
+	stw r21, CONTEXT_OFFSET_R21(r3)
+	stw r22, CONTEXT_OFFSET_R22(r3)
+	stw r23, CONTEXT_OFFSET_R23(r3)
+	stw r24, CONTEXT_OFFSET_R24(r3)
+	stw r25, CONTEXT_OFFSET_R25(r3)
+	stw r26, CONTEXT_OFFSET_R26(r3)
+	stw r27, CONTEXT_OFFSET_R27(r3)
+	stw r28, CONTEXT_OFFSET_R28(r3)
+	stw r29, CONTEXT_OFFSET_R29(r3)
+	stw r30, CONTEXT_OFFSET_R30(r3)
+	stw r31, CONTEXT_OFFSET_R31(r3)
 	
 	mflr r4
-	stw r4, OFFSET_PC(r3)
+	stw r4, CONTEXT_OFFSET_PC(r3)
 	
 	mfcr r4
-	stw r4, OFFSET_CR(r3)
+	stw r4, CONTEXT_OFFSET_CR(r3)
 	
 	# context_save returns 1
@@ -50,10 +70,30 @@
 
 context_restore:
-	CONTEXT_RESTORE_ARCH_CORE r3
+	lwz sp, CONTEXT_OFFSET_SP(r3)
+	lwz r2, CONTEXT_OFFSET_TLS(r3)
+	lwz r13, CONTEXT_OFFSET_R13(r3)
+	lwz r14, CONTEXT_OFFSET_R14(r3)
+	lwz r15, CONTEXT_OFFSET_R15(r3)
+	lwz r16, CONTEXT_OFFSET_R16(r3)
+	lwz r17, CONTEXT_OFFSET_R17(r3)
+	lwz r18, CONTEXT_OFFSET_R18(r3)
+	lwz r19, CONTEXT_OFFSET_R19(r3)
+	lwz r20, CONTEXT_OFFSET_R20(r3)
+	lwz r21, CONTEXT_OFFSET_R21(r3)
+	lwz r22, CONTEXT_OFFSET_R22(r3)
+	lwz r23, CONTEXT_OFFSET_R23(r3)
+	lwz r24, CONTEXT_OFFSET_R24(r3)
+	lwz r25, CONTEXT_OFFSET_R25(r3)
+	lwz r26, CONTEXT_OFFSET_R26(r3)
+	lwz r27, CONTEXT_OFFSET_R27(r3)
+	lwz r28, CONTEXT_OFFSET_R28(r3)
+	lwz r29, CONTEXT_OFFSET_R29(r3)
+	lwz r30, CONTEXT_OFFSET_R30(r3)
+	lwz r31, CONTEXT_OFFSET_R31(r3)
 	
-	lwz r4, OFFSET_CR(r3)
+	lwz r4, CONTEXT_OFFSET_CR(r3)
 	mtcr r4
 	
-	lwz r4, OFFSET_PC(r3)
+	lwz r4, CONTEXT_OFFSET_PC(r3)
 	mtlr r4
 	
Index: uspace/lib/c/arch/sparc64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/sparc64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/arch/sparc64/Makefile.inc	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,3 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/istate_struct.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/sparc64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/arch/sparc64/include/libarch/istate_struct.ag	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/sparc64/include/arch/istate_struct.ag
Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/async.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -101,4 +101,6 @@
 #undef LIBC_ASYNC_C_
 
+#include <ipc/irq.h>
+#include <ipc/event.h>
 #include <futex.h>
 #include <fibril.h>
@@ -116,5 +118,4 @@
 #include "private/libc.h"
 
-
 /** Session data */
 struct async_sess {
@@ -242,4 +243,18 @@
 	async_client_conn_t cfibril;
 } connection_t;
+
+/* Notification data */
+typedef struct {
+	ht_link_t link;
+	
+	/** Notification method */
+	sysarg_t imethod;
+	
+	/** Notification handler */
+	async_notification_handler_t handler;
+	
+	/** Notification data */
+	void *data;
+} notification_t;
 
 /** Identifier of the incoming connection handled by the current fibril. */
@@ -335,20 +350,6 @@
 }
 
-/** Default fibril function that gets called to handle interrupt notifications.
- *
- * This function is defined as a weak symbol - to be redefined in user code.
- *
- * @param callid Hash of the incoming call.
- * @param call   Data of the incoming call.
- * @param arg    Local argument.
- *
- */
-static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)
-{
-}
-
 static async_client_conn_t client_connection = default_client_connection;
-static async_interrupt_handler_t interrupt_received = default_interrupt_received;
-static size_t interrupt_handler_stksz = FIBRIL_DFLT_STK_SIZE;
+static size_t notification_handler_stksz = FIBRIL_DFLT_STK_SIZE;
 
 /** Setter for client_connection function pointer.
@@ -363,21 +364,11 @@
 }
 
-/** Setter for interrupt_received function pointer.
- *
- * @param intr Function that will implement a new interrupt
- *             notification fibril.
- */
-void async_set_interrupt_received(async_interrupt_handler_t intr)
-{
-	interrupt_received = intr;
-}
-
-/** Set the stack size for the interrupt handler notification fibrils.
+/** Set the stack size for the notification handler notification fibrils.
  *
  * @param size Stack size in bytes.
  */
-void async_set_interrupt_handler_stack_size(size_t size)
-{
-	interrupt_handler_stksz = size;
+void async_set_notification_handler_stack_size(size_t size)
+{
+	notification_handler_stksz = size;
 }
 
@@ -399,10 +390,13 @@
 static hash_table_t client_hash_table;
 static hash_table_t conn_hash_table;
+static hash_table_t notification_hash_table;
 static LIST_INITIALIZE(timeout_list);
 
-static size_t client_key_hash(void *k)
-{
-	task_id_t key = *(task_id_t*)k;
-	return key;
+static sysarg_t notification_avail = 0;
+
+static size_t client_key_hash(void *key)
+{
+	task_id_t in_task_id = *(task_id_t *) key;
+	return in_task_id;
 }
 
@@ -413,11 +407,10 @@
 }
 
-static bool client_key_equal(void *k, const ht_link_t *item)
-{
-	task_id_t key = *(task_id_t*)k;
+static bool client_key_equal(void *key, const ht_link_t *item)
+{
+	task_id_t in_task_id = *(task_id_t *) key;
 	client_t *client = hash_table_get_inst(item, client_t, link);
-	return key == client->in_task_id;
-}
-
+	return in_task_id == client->in_task_id;
+}
 
 /** Operations for the client hash table. */
@@ -439,6 +432,6 @@
 static size_t conn_key_hash(void *key)
 {
-	sysarg_t in_phone_hash  = *(sysarg_t*)key;
-	return in_phone_hash ;
+	sysarg_t in_phone_hash = *(sysarg_t *) key;
+	return in_phone_hash;
 }
 
@@ -451,9 +444,8 @@
 static bool conn_key_equal(void *key, const ht_link_t *item)
 {
-	sysarg_t in_phone_hash = *(sysarg_t*)key;
+	sysarg_t in_phone_hash = *(sysarg_t *) key;
 	connection_t *conn = hash_table_get_inst(item, connection_t, link);
 	return (in_phone_hash == conn->in_phone_hash);
 }
-
 
 /** Operations for the connection hash table. */
@@ -462,4 +454,34 @@
 	.key_hash = conn_key_hash,
 	.key_equal = conn_key_equal,
+	.equal = NULL,
+	.remove_callback = NULL
+};
+
+static size_t notification_key_hash(void *key)
+{
+	sysarg_t id = *(sysarg_t *) key;
+	return id;
+}
+
+static size_t notification_hash(const ht_link_t *item)
+{
+	notification_t *notification =
+	    hash_table_get_inst(item, notification_t, link);
+	return notification_key_hash(&notification->imethod);
+}
+
+static bool notification_key_equal(void *key, const ht_link_t *item)
+{
+	sysarg_t id = *(sysarg_t *) key;
+	notification_t *notification =
+	    hash_table_get_inst(item, notification_t, link);
+	return id == notification->imethod;
+}
+
+/** Operations for the notification hash table. */
+static hash_table_ops_t notification_hash_table_ops = {
+	.hash = notification_hash,
+	.key_hash = notification_key_hash,
+	.key_equal = notification_key_equal,
 	.equal = NULL,
 	.remove_callback = NULL
@@ -511,12 +533,11 @@
 	futex_down(&async_futex);
 	
-	ht_link_t *hlp = hash_table_find(&conn_hash_table, &call->in_phone_hash);
-	
-	if (!hlp) {
+	ht_link_t *link = hash_table_find(&conn_hash_table, &call->in_phone_hash);
+	if (!link) {
 		futex_up(&async_futex);
 		return false;
 	}
 	
-	connection_t *conn = hash_table_get_inst(hlp, connection_t, link);
+	connection_t *conn = hash_table_get_inst(link, connection_t, link);
 	
 	msg_t *msg = malloc(sizeof(*msg));
@@ -553,5 +574,6 @@
  *
  * When a notification arrives, a fibril with this implementing function is
- * created. It calls interrupt_received() and does the final cleanup.
+ * created. It calls the corresponding notification handler and does the final
+ * cleanup.
  *
  * @param arg Message structure pointer.
@@ -565,5 +587,22 @@
 	
 	msg_t *msg = (msg_t *) arg;
-	interrupt_received(msg->callid, &msg->call);
+	async_notification_handler_t handler = NULL;
+	void *data = NULL;
+	
+	futex_down(&async_futex);
+	
+	ht_link_t *link = hash_table_find(&notification_hash_table,
+	    &IPC_GET_IMETHOD(msg->call));
+	if (link) {
+		notification_t *notification =
+		    hash_table_get_inst(link, notification_t, link);
+		handler = notification->handler;
+		data = notification->data;
+	}
+	
+	futex_up(&async_futex);
+	
+	if (handler)
+		handler(msg->callid, &msg->call, data);
 	
 	free(msg);
@@ -571,5 +610,5 @@
 }
 
-/** Process interrupt notification.
+/** Process notification.
  *
  * A new fibril is created which would process the notification.
@@ -598,5 +637,5 @@
 	
 	fid_t fid = fibril_create_generic(notification_fibril, msg,
-	    interrupt_handler_stksz);
+	    notification_handler_stksz);
 	if (fid == 0) {
 		free(msg);
@@ -609,4 +648,145 @@
 	futex_up(&async_futex);
 	return true;
+}
+
+/** Subscribe to IRQ notification.
+ *
+ * @param inr     IRQ number.
+ * @param devno   Device number of the device generating inr.
+ * @param handler Notification handler.
+ * @param data    Notification handler client data.
+ * @param ucode   Top-half pseudocode handler.
+ *
+ * @return Zero on success or a negative error code.
+ *
+ */
+int async_irq_subscribe(int inr, int devno,
+    async_notification_handler_t handler, void *data, const irq_code_t *ucode)
+{
+	notification_t *notification =
+	    (notification_t *) malloc(sizeof(notification_t));
+	if (!notification)
+		return ENOMEM;
+	
+	futex_down(&async_futex);
+	
+	sysarg_t imethod = notification_avail;
+	notification_avail++;
+	
+	notification->imethod = imethod;
+	notification->handler = handler;
+	notification->data = data;
+	
+	hash_table_insert(&notification_hash_table, &notification->link);
+	
+	futex_up(&async_futex);
+	
+	return ipc_irq_subscribe(inr, devno, imethod, ucode);
+}
+
+/** Unsubscribe from IRQ notification.
+ *
+ * @param inr     IRQ number.
+ * @param devno   Device number of the device generating inr.
+ *
+ * @return Zero on success or a negative error code.
+ *
+ */
+int async_irq_unsubscribe(int inr, int devno)
+{
+	// TODO: Remove entry from hash table
+	//       to avoid memory leak
+	
+	return ipc_irq_unsubscribe(inr, devno);
+}
+
+/** Subscribe to event notifications.
+ *
+ * @param evno    Event type to subscribe.
+ * @param handler Notification handler.
+ * @param data    Notification handler client data.
+ *
+ * @return Zero on success or a negative error code.
+ *
+ */
+int async_event_subscribe(event_type_t evno,
+    async_notification_handler_t handler, void *data)
+{
+	notification_t *notification =
+	    (notification_t *) malloc(sizeof(notification_t));
+	if (!notification)
+		return ENOMEM;
+	
+	futex_down(&async_futex);
+	
+	sysarg_t imethod = notification_avail;
+	notification_avail++;
+	
+	notification->imethod = imethod;
+	notification->handler = handler;
+	notification->data = data;
+	
+	hash_table_insert(&notification_hash_table, &notification->link);
+	
+	futex_up(&async_futex);
+	
+	return ipc_event_subscribe(evno, imethod);
+}
+
+/** Subscribe to task event notifications.
+ *
+ * @param evno    Event type to subscribe.
+ * @param handler Notification handler.
+ * @param data    Notification handler client data.
+ *
+ * @return Zero on success or a negative error code.
+ *
+ */
+int async_event_task_subscribe(event_task_type_t evno,
+    async_notification_handler_t handler, void *data)
+{
+	notification_t *notification =
+	    (notification_t *) malloc(sizeof(notification_t));
+	if (!notification)
+		return ENOMEM;
+	
+	futex_down(&async_futex);
+	
+	sysarg_t imethod = notification_avail;
+	notification_avail++;
+	
+	notification->imethod = imethod;
+	notification->handler = handler;
+	notification->data = data;
+	
+	hash_table_insert(&notification_hash_table, &notification->link);
+	
+	futex_up(&async_futex);
+	
+	return ipc_event_task_subscribe(evno, imethod);
+}
+
+/** Unmask event notifications.
+ *
+ * @param evno Event type to unmask.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int async_event_unmask(event_type_t evno)
+{
+	return ipc_event_unmask(evno);
+}
+
+/** Unmask task event notifications.
+ *
+ * @param evno Event type to unmask.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int async_event_task_unmask(event_task_type_t evno)
+{
+	return ipc_event_task_unmask(evno);
 }
 
@@ -702,7 +882,7 @@
 
 	futex_down(&async_futex);
-	ht_link_t *lnk = hash_table_find(&client_hash_table, &client_id);
-	if (lnk) {
-		client = hash_table_get_inst(lnk, client_t, link);
+	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) {
@@ -1106,4 +1286,8 @@
 	
 	if (!hash_table_create(&conn_hash_table, 0, 0, &conn_hash_table_ops))
+		abort();
+	
+	if (!hash_table_create(&notification_hash_table, 0, 0,
+	    &notification_hash_table_ops))
 		abort();
 	
Index: uspace/lib/c/generic/bd.c
===================================================================
--- uspace/lib/c/generic/bd.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/bd.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -150,4 +150,15 @@
 }
 
+int bd_sync_cache(bd_t *bd, aoff64_t ba, size_t cnt)
+{
+	async_exch_t *exch = async_exchange_begin(bd->sess);
+
+	int rc = async_req_3_0(exch, BD_SYNC_CACHE, LOWER32(ba),
+	    UPPER32(ba), cnt);
+	async_exchange_end(exch);
+
+	return rc;
+}
+
 int bd_get_block_size(bd_t *bd, size_t *rbsize)
 {
Index: uspace/lib/c/generic/bd_srv.c
===================================================================
--- uspace/lib/c/generic/bd_srv.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/bd_srv.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -128,4 +128,23 @@
 }
 
+static void bd_sync_cache_srv(bd_srv_t *srv, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	aoff64_t ba;
+	size_t cnt;
+	int rc;
+
+	ba = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call));
+	cnt = IPC_GET_ARG3(*call);
+
+	if (srv->srvs->ops->sync_cache == NULL) {
+		async_answer_0(callid, ENOTSUP);
+		return;
+	}
+
+	rc = srv->srvs->ops->sync_cache(srv, ba, cnt);
+	async_answer_0(callid, rc);
+}
+
 static void bd_write_blocks_srv(bd_srv_t *srv, ipc_callid_t callid,
     ipc_call_t *call)
@@ -190,5 +209,5 @@
 	bd_srv_t *srv;
 
-	srv = calloc(1, sizeof(srv));
+	srv = calloc(1, sizeof(bd_srv_t));
 	if (srv == NULL)
 		return NULL;
@@ -244,4 +263,7 @@
 			bd_read_toc_srv(srv, callid, &call);
 			break;
+		case BD_SYNC_CACHE:
+			bd_sync_cache_srv(srv, callid, &call);
+			break;
 		case BD_WRITE_BLOCKS:
 			bd_write_blocks_srv(srv, callid, &call);
Index: uspace/lib/c/generic/ddi.c
===================================================================
--- uspace/lib/c/generic/ddi.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/ddi.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -87,4 +87,19 @@
 }
 
+/** Unmap a piece of physical memory to task.
+ *
+ * Caller of this function must have the CAP_MEM_MANAGER capability.
+ *
+ * @param virt Virtual address from the phys-mapped region.
+ *
+ * @return EOK on success.
+ * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
+ *
+ */
+int physmem_unmap(void *virt)
+{
+	return __SYSCALL1(SYS_PHYSMEM_UNMAP, (sysarg_t) virt);
+}
+
 /** Lock a piece physical memory for DMA transfers.
  *
@@ -179,4 +194,28 @@
 	
 	return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
+}
+
+/** Disable I/O space range to task.
+ *
+ * Caller of this function must have the IO_MEM_MANAGER capability.
+ *
+ * @param id     Task ID.
+ * @param ioaddr Starting address of the I/O range.
+ * @param size   Size of the range.
+ *
+ * @return EOK on success
+ * @return EPERM if the caller lacks the CAP_IO_MANAGER capability
+ * @return ENOENT if there is no task with specified ID
+ *
+ */
+static int iospace_disable(task_id_t id, void *ioaddr, size_t size)
+{
+	const ddi_ioarg_t arg = {
+		.task_id = id,
+		.ioaddr = ioaddr,
+		.size = size
+	};
+	
+	return __SYSCALL1(SYS_IOSPACE_DISABLE, (sysarg_t) &arg);
 }
 
@@ -273,4 +312,24 @@
 }
 
+/** Disable PIO for specified I/O range.
+ *
+ * @param virt     I/O start address.
+ * @param size     Size of the I/O region.
+ *
+ * @return EOK on success.
+ * @return Negative error code on failure.
+ *
+ */
+int pio_disable(void *virt, size_t size)
+{
+#ifdef IO_SPACE_BOUNDARY
+	if (virt < IO_SPACE_BOUNDARY)
+		return iospace_disable(task_get_id(), virt, size);
+#else
+	(void) iospace_disable;
+#endif
+	return physmem_unmap(virt);
+}
+
 void pio_write_8(ioport8_t *reg, uint8_t val)
 {
@@ -312,33 +371,4 @@
 }
 
-/** Register IRQ notification.
- *
- * @param inr    IRQ number.
- * @param devno  Device number of the device generating inr.
- * @param method Use this method for notifying me.
- * @param ucode  Top-half pseudocode handler.
- *
- * @return Value returned by the kernel.
- *
- */
-int irq_register(int inr, int devno, int method, const irq_code_t *ucode)
-{
-	return __SYSCALL4(SYS_IRQ_REGISTER, inr, devno, method,
-	    (sysarg_t) ucode);
-}
-
-/** Unregister IRQ notification.
- *
- * @param inr   IRQ number.
- * @param devno Device number of the device generating inr.
- *
- * @return Value returned by the kernel.
- *
- */
-int irq_unregister(int inr, int devno)
-{
-	return __SYSCALL2(SYS_IRQ_UNREGISTER, inr, devno);
-}
-
 /** @}
  */
Index: uspace/lib/c/generic/event.c
===================================================================
--- uspace/lib/c/generic/event.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/event.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,7 +38,7 @@
 
 #include <libc.h>
-#include <event.h>
+#include <ipc/event.h>
 
-/** Subscribe event notifications.
+/** Subscribe to event notifications.
  *
  * @param evno    Event type to subscribe.
@@ -48,14 +48,46 @@
  *
  */
-int event_subscribe(event_type_t evno, sysarg_t imethod)
+int ipc_event_subscribe(event_type_t evno, sysarg_t imethod)
 {
-	return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) evno,
+	return __SYSCALL2(SYS_IPC_EVENT_SUBSCRIBE, (sysarg_t) evno,
 	    (sysarg_t) imethod);
 }
 
-int event_task_subscribe(event_task_type_t evno, sysarg_t imethod)
+/** Subscribe to task event notifications.
+ *
+ * @param evno    Event type to subscribe.
+ * @param imethod Use this interface and method for notifying me.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int ipc_event_task_subscribe(event_task_type_t evno, sysarg_t imethod)
 {
-	return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) evno,
+	return __SYSCALL2(SYS_IPC_EVENT_SUBSCRIBE, (sysarg_t) evno,
 	    (sysarg_t) imethod);
+}
+
+/** Unsubscribe from event notifications.
+ *
+ * @param evno    Event type to unsubscribe.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int ipc_event_unsubscribe(event_type_t evno)
+{
+	return __SYSCALL1(SYS_IPC_EVENT_UNSUBSCRIBE, (sysarg_t) evno);
+}
+
+/** Unsubscribe from task event notifications.
+ *
+ * @param evno    Event type to unsubscribe.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int ipc_event_task_unsubscribe(event_task_type_t evno)
+{
+	return __SYSCALL1(SYS_IPC_EVENT_UNSUBSCRIBE, (sysarg_t) evno);
 }
 
@@ -67,12 +99,19 @@
  *
  */
-int event_unmask(event_type_t evno)
+int ipc_event_unmask(event_type_t evno)
 {
-	return __SYSCALL1(SYS_EVENT_UNMASK, (sysarg_t) evno);
+	return __SYSCALL1(SYS_IPC_EVENT_UNMASK, (sysarg_t) evno);
 }
 
-int event_task_unmask(event_task_type_t evno)
+/** Unmask task event notifications.
+ *
+ * @param evno Event type to unmask.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int ipc_event_task_unmask(event_task_type_t evno)
 {
-	return __SYSCALL1(SYS_EVENT_UNMASK, (sysarg_t) evno);
+	return __SYSCALL1(SYS_IPC_EVENT_UNMASK, (sysarg_t) evno);
 }
 
Index: uspace/lib/c/generic/io/asprintf.c
===================================================================
--- uspace/lib/c/generic/io/asprintf.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/io/asprintf.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -76,4 +76,32 @@
  *             the newly allocated string.
  * @fmt        Format string.
+ * @args       Variable argument list
+ *
+ * @return Number of characters printed or a negative error code.
+ *
+ */
+int vasprintf(char **strp, const char *fmt, va_list args)
+{
+	va_list args2;
+	va_copy(args2, args);
+	int ret = vprintf_size(fmt, args2);
+	va_end(args2);
+	
+	if (ret > 0) {
+		*strp = malloc(STR_BOUNDS(ret) + 1);
+		if (*strp == NULL)
+			return -1;
+		
+		vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args);
+	}
+	
+	return ret;
+}
+
+/** Allocate and print to string.
+ *
+ * @param strp Address of the pointer where to store the address of
+ *             the newly allocated string.
+ * @fmt        Format string.
  *
  * @return Number of characters printed or a negative error code.
@@ -84,16 +112,6 @@
 	va_list args;
 	va_start(args, fmt);
-	int ret = vprintf_size(fmt, args);
+	int ret = vasprintf(strp, fmt, args);
 	va_end(args);
-	
-	if (ret > 0) {
-		*strp = malloc(STR_BOUNDS(ret) + 1);
-		if (*strp == NULL)
-			return -1;
-		
-		va_start(args, fmt);
-		vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args);
-		va_end(args);
-	}
 	
 	return ret;
Index: uspace/lib/c/generic/io/chardev.c
===================================================================
--- uspace/lib/c/generic/io/chardev.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/generic/io/chardev.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <mem.h>
+#include <io/chardev.h>
+#include <ipc/chardev.h>
+
+ssize_t chardev_read(async_exch_t *exch, void *data, size_t size)
+{
+	if (!exch)
+		return EBADMEM;
+	if (size > 4 * sizeof(sysarg_t))
+		return ELIMIT;
+
+	sysarg_t message[4] = { 0 };
+	const ssize_t ret = async_req_1_4(exch, CHARDEV_READ, size,
+	    &message[0], &message[1], &message[2], &message[3]);
+	if (ret > 0 && (size_t)ret <= size)
+		memcpy(data, message, size);
+	return ret;
+}
+
+ssize_t chardev_write(async_exch_t *exch, const void *data, size_t size)
+{
+	if (!exch)
+		return EBADMEM;
+	if (size > 3 * sizeof(sysarg_t))
+		return ELIMIT;
+
+	sysarg_t message[3] = { 0 };
+	memcpy(message, data, size);
+	return async_req_4_0(exch, CHARDEV_WRITE, size,
+	    message[0], message[1], message[2]);
+}
Index: uspace/lib/c/generic/io/chardev_srv.c
===================================================================
--- uspace/lib/c/generic/io/chardev_srv.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/generic/io/chardev_srv.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2014 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 libc
+ * @{
+ */
+/**
+ * @file
+ * @brief Character device server stub
+ */
+#include <errno.h>
+#include <io/chardev_srv.h>
+#include <ipc/chardev.h>
+#include <macros.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+static chardev_srv_t *chardev_srv_create(chardev_srvs_t *);
+
+static void chardev_read_srv(chardev_srv_t *srv, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	size_t size = IPC_GET_ARG1(*call);
+	int rc;
+
+	if (srv->srvs->ops->read == NULL) {
+		async_answer_0(callid, ENOTSUP);
+		return;
+	}
+
+	if (size <= 4 * sizeof(sysarg_t)) {
+		sysarg_t message[4] = {};
+
+		rc = srv->srvs->ops->read(srv, (char *)message, size);
+		async_answer_4(callid, rc, message[0], message[1],
+		    message[2], message[3]);
+	} else {
+		async_answer_0(callid, ELIMIT);
+	}
+}
+
+static void chardev_write_srv(chardev_srv_t *srv, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	size_t size = IPC_GET_ARG1(*call);
+	int rc;
+
+	if (srv->srvs->ops->write == NULL) {
+		async_answer_0(callid, ENOTSUP);
+		return;
+	}
+
+	if (size <= 3 * sizeof(sysarg_t)) {
+		const sysarg_t message[3] = {
+			IPC_GET_ARG2(*call),
+			IPC_GET_ARG3(*call),
+			IPC_GET_ARG4(*call)
+		};
+
+		rc = srv->srvs->ops->write(srv, (char *)message, size);
+		async_answer_0(callid, rc);
+	} else {
+		async_answer_0(callid, ELIMIT);
+	}
+}
+
+static chardev_srv_t *chardev_srv_create(chardev_srvs_t *srvs)
+{
+	chardev_srv_t *srv;
+
+	srv = calloc(1, sizeof(chardev_srv_t));
+	if (srv == NULL)
+		return NULL;
+
+	srv->srvs = srvs;
+	return srv;
+}
+
+void chardev_srvs_init(chardev_srvs_t *srvs)
+{
+	srvs->ops = NULL;
+	srvs->sarg = NULL;
+}
+
+int chardev_conn(ipc_callid_t iid, ipc_call_t *icall, chardev_srvs_t *srvs)
+{
+	chardev_srv_t *srv;
+	int rc;
+
+	/* Accept the connection */
+	async_answer_0(iid, EOK);
+
+	srv = chardev_srv_create(srvs);
+	if (srv == NULL)
+		return ENOMEM;
+
+	if (srvs->ops->open != NULL) {
+		rc = srvs->ops->open(srvs, srv);
+		if (rc != EOK)
+			return rc;
+	}
+
+	while (true) {
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+		sysarg_t method = IPC_GET_IMETHOD(call);
+
+		if (!method) {
+			/* The other side has hung up */
+			async_answer_0(callid, EOK);
+			break;
+		}
+
+		switch (method) {
+		case CHARDEV_READ:
+			chardev_read_srv(srv, callid, &call);
+			break;
+		case CHARDEV_WRITE:
+			chardev_write_srv(srv, callid, &call);
+			break;
+		default:
+			async_answer_0(callid, EINVAL);
+		}
+	}
+
+	if (srvs->ops->close != NULL)
+		rc = srvs->ops->close(srv);
+	else
+		rc = EOK;
+
+	free(srv);
+
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/io/console.c
===================================================================
--- uspace/lib/c/generic/io/console.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/io/console.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -75,5 +75,5 @@
 bool console_kcon(void)
 {
-	return __SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE);
+	return __SYSCALL0(SYS_DEBUG_CONSOLE);
 }
 
Index: uspace/lib/c/generic/io/input.c
===================================================================
--- uspace/lib/c/generic/io/input.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/io/input.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -80,22 +80,25 @@
 }
 
-int input_yield(input_t *input)
+int input_activate(input_t *input)
 {
 	async_exch_t *exch = async_exchange_begin(input->sess);
-
-	int rc = async_req_0_0(exch, INPUT_YIELD);
+	int rc = async_req_0_0(exch, INPUT_ACTIVATE);
 	async_exchange_end(exch);
-
+	
 	return rc;
 }
 
-int input_reclaim(input_t *input)
-{
-	async_exch_t *exch = async_exchange_begin(input->sess);
-
-	int rc = async_req_0_0(exch, INPUT_RECLAIM);
-	async_exchange_end(exch);
-
-	return rc;
+static void input_ev_active(input_t *input, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	int rc = input->ev_ops->active(input);
+	async_answer_0(callid, rc);
+}
+
+static void input_ev_deactive(input_t *input, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	int rc = input->ev_ops->deactive(input);
+	async_answer_0(callid, rc);
 }
 
@@ -178,4 +181,10 @@
 
 		switch (IPC_GET_IMETHOD(call)) {
+		case INPUT_EVENT_ACTIVE:
+			input_ev_active(input, callid, &call);
+			break;
+		case INPUT_EVENT_DEACTIVE:
+			input_ev_deactive(input, callid, &call);
+			break;
 		case INPUT_EVENT_KEY:
 			input_ev_key(input, callid, &call);
Index: uspace/lib/c/generic/iplink.c
===================================================================
--- uspace/lib/c/generic/iplink.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/iplink.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -171,4 +171,27 @@
 }
 
+int iplink_set_mac48(iplink_t *iplink, addr48_t mac)
+{
+	async_exch_t *exch = async_exchange_begin(iplink->sess);
+	
+	ipc_call_t answer;
+	aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer);
+	
+	int rc = async_data_read_start(exch, mac, sizeof(addr48_t));
+	
+	loc_exchange_end(exch);
+	
+	if (rc != EOK) {
+		async_forget(req);
+		return rc;
+	}
+	
+	sysarg_t retval;
+	async_wait_for(req, &retval);
+	
+	return (int) retval;
+}
+
+
 int iplink_addr_add(iplink_t *iplink, inet_addr_t *addr)
 {
@@ -230,4 +253,22 @@
 	free(sdu.data);
 	async_answer_0(iid, rc);
+}
+
+static void iplink_ev_change_addr(iplink_t *iplink, ipc_callid_t iid,
+    ipc_call_t *icall)
+{
+	addr48_t *addr;
+	size_t size;
+	
+	int rc = async_data_write_accept((void **)&addr, false,
+	    sizeof(addr48_t), sizeof(addr48_t), 0, &size);
+	if (rc != EOK) {
+		async_answer_0(iid, rc);
+		return;
+	}
+
+	rc = iplink->ev_ops->change_addr(iplink, *addr);
+	free(addr);
+	async_answer_0(iid, EOK);
 }
 
@@ -249,4 +290,6 @@
 			iplink_ev_recv(iplink, callid, &call);
 			break;
+		case IPLINK_EV_CHANGE_ADDR:
+			iplink_ev_change_addr(iplink, callid, &call);
 		default:
 			async_answer_0(callid, ENOTSUP);
Index: uspace/lib/c/generic/iplink_srv.c
===================================================================
--- uspace/lib/c/generic/iplink_srv.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/iplink_srv.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -81,4 +81,31 @@
 }
 
+static void iplink_set_mac48_srv(iplink_srv_t *srv, ipc_callid_t iid,
+    ipc_call_t *icall)
+{
+	int rc;
+	size_t size;
+	addr48_t mac;
+	ipc_callid_t callid;
+
+	rc = async_data_write_receive(&callid, &size);
+	if (rc != EOK) {
+		async_answer_0(callid, (sysarg_t) rc);
+		async_answer_0(iid, (sysarg_t) rc);
+	}
+
+	rc = srv->ops->set_mac48(srv, &mac);
+	if (rc != EOK) {
+		async_answer_0(iid, rc);
+		return;
+	}
+	
+	rc = async_data_read_finalize(callid, &mac, sizeof(addr48_t));
+	if (rc != EOK)
+		async_answer_0(callid, rc);
+	
+	async_answer_0(iid, (sysarg_t) rc);
+}
+
 static void iplink_addr_add_srv(iplink_srv_t *srv, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -252,4 +279,7 @@
 			iplink_get_mac48_srv(srv, callid, &call);
 			break;
+		case IPLINK_SET_MAC48:
+			iplink_set_mac48_srv(srv, callid, &call);
+			break;
 		case IPLINK_SEND:
 			iplink_send_srv(srv, callid, &call);
@@ -300,4 +330,30 @@
 }
 
+int iplink_ev_change_addr(iplink_srv_t *srv, addr48_t *addr)
+{
+	if (srv->client_sess == NULL)
+		return EIO;
+	
+	async_exch_t *exch = async_exchange_begin(srv->client_sess);
+	
+	ipc_call_t answer;
+	aid_t req = async_send_0(exch, IPLINK_EV_CHANGE_ADDR, &answer);
+	
+	int rc = async_data_write_start(exch, addr, sizeof(addr48_t));
+	async_exchange_end(exch);
+	
+	if (rc != EOK) {
+		async_forget(req);
+		return rc;
+	}
+	
+	sysarg_t retval;
+	async_wait_for(req, &retval);
+	if (retval != EOK)
+		return retval;
+	
+	return EOK;
+}
+
 /** @}
  */
Index: uspace/lib/c/generic/irc.c
===================================================================
--- uspace/lib/c/generic/irc.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/irc.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -49,14 +49,8 @@
 static int irc_init(void)
 {
-	sysarg_t apic;
-	sysarg_t i8259;
-
 	assert(irc_sess == NULL);
 
-	if (((sysinfo_get_value("apic", &apic) == EOK) && (apic))
-	    || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) {
-		irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-		    SERVICE_IRC, 0, 0);
-	}
+	irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
+	    SERVICE_IRC, 0, 0);
 
 	if (irc_sess == NULL)
Index: uspace/lib/c/generic/irq.c
===================================================================
--- uspace/lib/c/generic/irq.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/generic/irq.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,69 @@
+/*
+ * 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 libc
+ * @{
+ */
+/** @file
+ */
+
+#include <ipc/irq.h>
+#include <libc.h>
+
+/** Subscribe to IRQ notification.
+ *
+ * @param inr    IRQ number.
+ * @param devno  Device number of the device generating inr.
+ * @param method Use this method for notifying me.
+ * @param ucode  Top-half pseudocode handler.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int ipc_irq_subscribe(int inr, int devno, sysarg_t method,
+    const irq_code_t *ucode)
+{
+	return __SYSCALL4(SYS_IPC_IRQ_SUBSCRIBE, inr, devno, method,
+	    (sysarg_t) ucode);
+}
+
+/** Unsubscribe from IRQ notification.
+ *
+ * @param inr   IRQ number.
+ * @param devno Device number of the device generating inr.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int ipc_irq_unsubscribe(int inr, int devno)
+{
+	return __SYSCALL2(SYS_IPC_IRQ_UNSUBSCRIBE, inr, devno);
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/task.c
===================================================================
--- uspace/lib/c/generic/task.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/generic/task.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -2,4 +2,5 @@
  * Copyright (c) 2006 Jakub Jermar
  * Copyright (c) 2008 Jiri Svoboda
+ * Copyright (c) 2014 Martin Sucha
  * All rights reserved.
  *
@@ -94,4 +95,6 @@
  *
  * @param id   If not NULL, the ID of the task is stored here on success.
+ * @param wait If not NULL, setup waiting for task's return value and store
+ *             the information necessary for waiting here on success.
  * @param path Pathname of the binary to execute.
  * @param argv Command-line arguments.
@@ -100,5 +103,6 @@
  *
  */
-int task_spawnv(task_id_t *id, const char *path, const char *const args[])
+int task_spawnv(task_id_t *id, task_wait_t *wait, const char *path,
+    const char *const args[])
 {
 	/* Send default files */
@@ -125,5 +129,5 @@
 	files[3] = NULL;
 	
-	return task_spawnvf(id, path, args, files);
+	return task_spawnvf(id, wait, path, args, files);
 }
 
@@ -135,4 +139,6 @@
  *
  * @param id    If not NULL, the ID of the task is stored here on success.
+ * @param wait  If not NULL, setup waiting for task's return value and store
+ *              the information necessary for waiting here on success.
  * @param path  Pathname of the binary to execute.
  * @param argv  Command-line arguments.
@@ -142,6 +148,6 @@
  *
  */
-int task_spawnvf(task_id_t *id, const char *path, const char *const args[],
-    int *const files[])
+int task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path,
+    const char *const args[], int *const files[])
 {
 	/* Connect to a program loader. */
@@ -150,4 +156,6 @@
 		return EREFUSED;
 	
+	bool wait_initialized = false;
+	
 	/* Get task ID. */
 	task_id_t task_id;
@@ -181,4 +189,12 @@
 		goto error;
 	
+	/* Setup waiting for return value if needed */
+	if (wait) {
+		rc = task_setup_wait(task_id, wait);
+		if (rc != EOK)
+			goto error;
+		wait_initialized = true;
+	}
+	
 	/* Run it. */
 	rc = loader_run(ldr);
@@ -193,4 +209,7 @@
 	
 error:
+	if (wait_initialized)
+		task_cancel_wait(wait);
+	
 	/* Error exit */
 	loader_abort(ldr);
@@ -204,4 +223,6 @@
  *
  * @param id   If not NULL, the ID of the task is stored here on success.
+ * @param wait If not NULL, setup waiting for task's return value and store
+ *             the information necessary for waiting here on success.
  * @param path Pathname of the binary to execute.
  * @param cnt  Number of arguments.
@@ -211,5 +232,6 @@
  *
  */
-int task_spawn(task_id_t *task_id, const char *path, int cnt, va_list ap)
+int task_spawn(task_id_t *task_id, task_wait_t *wait, const char *path,
+    int cnt, va_list ap)
 {
 	/* Allocate argument list. */
@@ -227,5 +249,5 @@
 	
 	/* Spawn task. */
-	int rc = task_spawnv(task_id, path, arglist);
+	int rc = task_spawnv(task_id, wait, path, arglist);
 	
 	/* Free argument list. */
@@ -240,4 +262,6 @@
  *
  * @param id   If not NULL, the ID of the task is stored here on success.
+ * @param wait If not NULL, setup waiting for task's return value and store
+ *             the information necessary for waiting here on success.
  * @param path Pathname of the binary to execute.
  * @param ...  Command-line arguments.
@@ -246,5 +270,5 @@
  *
  */
-int task_spawnl(task_id_t *task_id, const char *path, ...)
+int task_spawnl(task_id_t *task_id, task_wait_t *wait, const char *path, ...)
 {
 	/* Count the number of arguments. */
@@ -262,5 +286,5 @@
 	
 	va_start(ap, path);
-	int rc = task_spawn(task_id, path, cnt, ap);
+	int rc = task_spawn(task_id, wait, path, cnt, ap);
 	va_end(ap);
 	
@@ -268,19 +292,90 @@
 }
 
-int task_wait(task_id_t id, task_exit_t *texit, int *retval)
+/** Setup waiting for a task.
+ * 
+ * If the task finishes after this call succeeds, it is guaranteed that
+ * task_wait(wait, &texit, &retval) will return correct return value for
+ * the task.
+ *
+ * @param id   ID of the task to setup waiting for.
+ * @param wait Information necessary for the later task_wait call is stored here.
+ *
+ * @return EOK on success, else error code.
+ */
+int task_setup_wait(task_id_t id, task_wait_t *wait)
+{
+	async_exch_t *exch = async_exchange_begin(session_ns);
+	wait->aid = async_send_2(exch, NS_TASK_WAIT, LOWER32(id), UPPER32(id),
+	    &wait->result);
+	async_exchange_end(exch);
+
+	return EOK;
+}
+
+/** Cancel waiting for a task.
+ *
+ * This can be called *instead of* task_wait if the caller is not interested
+ * in waiting for the task anymore.
+ *
+ * This function cannot be called if the task_wait was already called.
+ *
+ * @param wait task_wait_t previously initialized by task_setup_wait.
+ */
+void task_cancel_wait(task_wait_t *wait) {
+	async_forget(wait->aid);
+}
+
+/** Wait for a task to finish.
+ *
+ * This function returns correct values even if the task finished in
+ * between task_setup_wait and this task_wait call.
+ *
+ * This function cannot be called more than once with the same task_wait_t
+ * (it can be reused, but must be reinitialized with task_setup_wait first)
+ *
+ * @param wait   task_wait_t previously initialized by task_setup_wait.
+ * @param texit  Store type of task exit here.
+ * @param retval Store return value of the task here.
+ * 
+ * @return EOK on success, else error code.
+ */
+int task_wait(task_wait_t *wait, task_exit_t *texit, int *retval)
 {
 	assert(texit);
 	assert(retval);
-	
-	async_exch_t *exch = async_exchange_begin(session_ns);
-	sysarg_t te, rv;
-	int rc = (int) async_req_2_2(exch, NS_TASK_WAIT, LOWER32(id),
-	    UPPER32(id), &te, &rv);
-	async_exchange_end(exch);
-	
-	*texit = te;
-	*retval = rv;
-	
-	return rc;
+
+	sysarg_t rc;
+	async_wait_for(wait->aid, &rc);
+
+	if (rc == EOK) {
+		*texit = IPC_GET_ARG1(wait->result);
+		*retval = IPC_GET_ARG2(wait->result);
+	}
+
+	return rc;
+}
+
+/** Wait for a task to finish by its id.
+ *
+ * Note that this will fail with ENOENT if the task id is not registered in ns
+ * (e.g. if the task finished). If you are spawning a task and need to wait
+ * for its completion, use wait parameter of the task_spawn* functions instead
+ * to prevent a race where the task exits before you may have a chance to wait
+ * wait for it.
+ *
+ * @param id ID of the task to wait for.
+ * @param texit  Store type of task exit here.
+ * @param retval Store return value of the task here.
+ * 
+ * @return EOK on success, else error code.
+ */
+int task_wait_task_id(task_id_t id, task_exit_t *texit, int *retval)
+{
+	task_wait_t wait;
+	int rc = task_setup_wait(id, &wait);
+	if (rc != EOK)
+		return rc;
+	
+	return task_wait(&wait, texit, retval);
 }
 
Index: uspace/lib/c/include/adt/list.h
===================================================================
--- uspace/lib/c/include/adt/list.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/adt/list.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,5 +39,5 @@
 #include <assert.h>
 #include <stdbool.h>
-#include <unistd.h>
+#include <stddef.h>
 
 /** Doubly linked list link. */
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/async.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -45,5 +45,7 @@
 #include <atomic.h>
 #include <stdbool.h>
-#include <task.h>
+#include <abi/proc/task.h>
+#include <abi/ddi/irq.h>
+#include <abi/ipc/event.h>
 
 typedef ipc_callid_t aid_t;
@@ -62,6 +64,7 @@
 typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *, void *);
 
-/** Interrupt handler */
-typedef void (*async_interrupt_handler_t)(ipc_callid_t, ipc_call_t *);
+/** Notification handler */
+typedef void (*async_notification_handler_t)(ipc_callid_t, ipc_call_t *,
+    void *);
 
 /** Exchange management style
@@ -155,6 +158,18 @@
 
 extern void async_set_client_connection(async_client_conn_t);
-extern void async_set_interrupt_received(async_interrupt_handler_t);
-extern void async_set_interrupt_handler_stack_size(size_t);
+extern void async_set_notification_handler_stack_size(size_t);
+
+extern int async_irq_subscribe(int, int, async_notification_handler_t, void *,
+    const irq_code_t *);
+extern int async_irq_unsubscribe(int, int);
+
+extern int async_event_subscribe(event_type_t, async_notification_handler_t,
+    void *);
+extern int async_event_task_subscribe(event_task_type_t,
+    async_notification_handler_t, void *);
+extern int async_event_unsubscribe(event_type_t);
+extern int async_event_task_unsubscribe(event_task_type_t);
+extern int async_event_unmask(event_type_t);
+extern int async_event_task_unmask(event_task_type_t);
 
 /*
Index: uspace/lib/c/include/bd.h
===================================================================
--- uspace/lib/c/include/bd.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/bd.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -48,4 +48,5 @@
 extern int bd_read_toc(bd_t *, uint8_t, void *, size_t);
 extern int bd_write_blocks(bd_t *, aoff64_t, size_t, const void *, size_t);
+extern int bd_sync_cache(bd_t *, aoff64_t, size_t);
 extern int bd_get_block_size(bd_t *, size_t *);
 extern int bd_get_num_blocks(bd_t *, aoff64_t *);
Index: uspace/lib/c/include/bd_srv.h
===================================================================
--- uspace/lib/c/include/bd_srv.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/bd_srv.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -62,4 +62,5 @@
 	int (*read_blocks)(bd_srv_t *, aoff64_t, size_t, void *, size_t);
 	int (*read_toc)(bd_srv_t *, uint8_t, void *, size_t);
+	int (*sync_cache)(bd_srv_t *, aoff64_t, size_t);
 	int (*write_blocks)(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
 	int (*get_block_size)(bd_srv_t *, size_t *);
Index: uspace/lib/c/include/ddi.h
===================================================================
--- uspace/lib/c/include/ddi.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/ddi.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -51,4 +51,5 @@
 
 extern int physmem_map(uintptr_t, size_t, unsigned int, void **);
+extern int physmem_unmap(void *);
 
 extern int dmamem_map(void *, size_t, unsigned int, unsigned int, uintptr_t *);
@@ -61,4 +62,5 @@
 extern int pio_enable_resource(pio_window_t *, hw_resource_t *, void **);
 extern int pio_enable(void *, size_t, void **);
+extern int pio_disable(void *, size_t);
 
 typedef void (*trace_fnc)(const volatile void *place, uint32_t val,
@@ -130,7 +132,4 @@
 }
 
-extern int irq_register(int, int, int, const irq_code_t *);
-extern int irq_unregister(int, int);
-
 #endif
 
Index: pace/lib/c/include/event.h
===================================================================
--- uspace/lib/c/include/event.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Copyright (c) 2009 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_EVENT_H_
-#define LIBC_EVENT_H_
-
-#include <abi/ipc/event.h>
-#include <libarch/types.h>
-
-extern int event_subscribe(event_type_t, sysarg_t);
-extern int event_task_subscribe(event_task_type_t, sysarg_t);
-extern int event_unmask(event_type_t);
-extern int event_task_unmask(event_task_type_t);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/inet/iplink.h
===================================================================
--- uspace/lib/c/include/inet/iplink.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/inet/iplink.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -78,4 +78,5 @@
 typedef struct iplink_ev_ops {
 	int (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
+	int (*change_addr)(iplink_t *, addr48_t);
 } iplink_ev_ops_t;
 
@@ -88,4 +89,5 @@
 extern int iplink_get_mtu(iplink_t *, size_t *);
 extern int iplink_get_mac48(iplink_t *, addr48_t *);
+extern int iplink_set_mac48(iplink_t *, addr48_t);
 
 #endif
Index: uspace/lib/c/include/inet/iplink_srv.h
===================================================================
--- uspace/lib/c/include/inet/iplink_srv.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/inet/iplink_srv.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -59,4 +59,5 @@
 	int (*get_mtu)(iplink_srv_t *, size_t *);
 	int (*get_mac48)(iplink_srv_t *, addr48_t *);
+	int (*set_mac48)(iplink_srv_t *, addr48_t *);
 	int (*addr_add)(iplink_srv_t *, inet_addr_t *);
 	int (*addr_remove)(iplink_srv_t *, inet_addr_t *);
@@ -67,4 +68,5 @@
 extern int iplink_conn(ipc_callid_t, ipc_call_t *, void *);
 extern int iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t);
+extern int iplink_ev_change_addr(iplink_srv_t *, addr48_t *);
 
 #endif
Index: uspace/lib/c/include/io/chardev.h
===================================================================
--- uspace/lib/c/include/io/chardev.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/include/io/chardev.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** @addtogroup libc
+ * @{
+ */
+
+#ifndef LIBC_IO_CHARDEV_H_
+#define LIBC_IO_CHARDEV_H_
+
+#include <libarch/types.h>
+#include <async.h>
+
+ssize_t chardev_read(async_exch_t *, void *, size_t);
+ssize_t chardev_write(async_exch_t *, const void *, size_t);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/c/include/io/chardev_srv.h
===================================================================
--- uspace/lib/c/include/io/chardev_srv.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/include/io/chardev_srv.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2014 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 libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IO_CHARDEV_SRV_H_
+#define LIBC_IO_CHARDEV_SRV_H_
+
+#include <adt/list.h>
+#include <async.h>
+#include <fibril_synch.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+typedef struct chardev_ops chardev_ops_t;
+
+/** Service setup (per sevice) */
+typedef struct {
+	chardev_ops_t *ops;
+	void *sarg;
+} chardev_srvs_t;
+
+/** Server structure (per client session) */
+typedef struct {
+	chardev_srvs_t *srvs;
+	void *carg;
+} chardev_srv_t;
+
+struct chardev_ops {
+	int (*open)(chardev_srvs_t *, chardev_srv_t *);
+	int (*close)(chardev_srv_t *);
+	int (*read)(chardev_srv_t *, void *, size_t);
+	int (*write)(chardev_srv_t *, const void *, size_t);
+};
+
+extern void chardev_srvs_init(chardev_srvs_t *);
+
+extern int chardev_conn(ipc_callid_t, ipc_call_t *, chardev_srvs_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/io/input.h
===================================================================
--- uspace/lib/c/include/io/input.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/io/input.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -49,4 +49,6 @@
 
 typedef struct input_ev_ops {
+	int (*active)(input_t *);
+	int (*deactive)(input_t *);
 	int (*key)(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
 	int (*move)(input_t *, int, int);
@@ -57,6 +59,5 @@
 extern int input_open(async_sess_t *, input_ev_ops_t *, void *, input_t **);
 extern void input_close(input_t *);
-extern int input_yield(input_t *);
-extern int input_reclaim(input_t *);
+extern int input_activate(input_t *);
 
 #endif
Index: uspace/lib/c/include/io/pixelmap.h
===================================================================
--- uspace/lib/c/include/io/pixelmap.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/io/pixelmap.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2011 Petr Koupy
+ * Copyright (c) 2014 Martin Sucha
  * All rights reserved.
  *
@@ -40,4 +41,21 @@
 #include <unistd.h>
 #include <io/pixel.h>
+
+/* Defines how a pixel outside of pixmap rectangle shall be treated */
+typedef enum {
+	/* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */
+	PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0,
+	
+	/* The pixmap is repeated infinetely */
+	PIXELMAP_EXTEND_TILE,
+	
+	/* If outside of a pixmap, return closest pixel from the edge */
+	PIXELMAP_EXTEND_SIDES,
+	
+	/* If outside of a pixmap, return closest pixel from the edge,
+	 * with alpha = 0
+	 */
+	PIXELMAP_EXTEND_TRANSPARENT_SIDES
+} pixelmap_extend_t;
 
 typedef struct {
@@ -86,4 +104,48 @@
 }
 
+static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap,
+    native_t x, native_t y, pixelmap_extend_t extend)
+{
+	bool transparent = false;
+	if (extend == PIXELMAP_EXTEND_TILE) {
+		x %= pixmap->width;
+		y %= pixmap->height;
+	}
+	else if (extend == PIXELMAP_EXTEND_SIDES ||
+	    extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) {
+		bool transparent_outside =
+		    (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES);
+		if (x < 0) {
+			x = 0;
+			transparent = transparent_outside;
+		}
+		else if (((sysarg_t) x) >= pixmap->width) {
+			x = pixmap->width - 1;
+			transparent = transparent_outside;
+		}
+		
+		if (y < 0) {
+			y = 0;
+			transparent = transparent_outside;
+		}
+		else if (((sysarg_t) y) >= pixmap->height) {
+			y = pixmap->height - 1;
+			transparent = transparent_outside;
+		}
+	}
+	
+	if (x < 0 || ((sysarg_t) x) >= pixmap->width ||
+	    y < 0 || ((sysarg_t) y) >= pixmap->height)
+		return PIXEL(0, 0, 0, 0);
+
+	pixel_t pixel = pixelmap_get_pixel(pixmap, x, y);
+	
+	if (transparent)
+		pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel));
+	
+	return pixel;
+}
+
+
 #endif
 
Index: uspace/lib/c/include/ipc/bd.h
===================================================================
--- uspace/lib/c/include/ipc/bd.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/ipc/bd.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -42,4 +42,5 @@
 	BD_GET_NUM_BLOCKS,
 	BD_READ_BLOCKS,
+	BD_SYNC_CACHE,
 	BD_WRITE_BLOCKS,
 	BD_READ_TOC
Index: uspace/lib/c/include/ipc/chardev.h
===================================================================
--- uspace/lib/c/include/ipc/chardev.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/include/ipc/chardev.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014 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 libcipc
+ * @{
+ */
+/** @file
+ * @brief Character device interface.
+ */
+
+#ifndef LIBC_IPC_CHARDEV_H_
+#define LIBC_IPC_CHARDEV_H_
+
+#include <ipc/common.h>
+
+typedef enum {
+	CHARDEV_READ = IPC_FIRST_USER_METHOD,
+	CHARDEV_WRITE
+} chardev_request_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/ipc/common.h
===================================================================
--- uspace/lib/c/include/ipc/common.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/ipc/common.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,5 +39,5 @@
 #include <abi/ipc/ipc.h>
 #include <atomic.h>
-#include <task.h>
+#include <abi/proc/task.h>
 
 #define IPC_FLAG_BLOCKING  0x01
Index: uspace/lib/c/include/ipc/event.h
===================================================================
--- uspace/lib/c/include/ipc/event.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/include/ipc/event.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IPC_EVENT_H_
+#define LIBC_IPC_EVENT_H_
+
+#include <abi/ipc/event.h>
+#include <libarch/types.h>
+
+extern int ipc_event_subscribe(event_type_t, sysarg_t);
+extern int ipc_event_task_subscribe(event_task_type_t, sysarg_t);
+extern int ipc_event_unsubscribe(event_type_t);
+extern int ipc_event_task_unsubscribe(event_task_type_t);
+extern int ipc_event_unmask(event_type_t);
+extern int ipc_event_task_unmask(event_task_type_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/ipc/input.h
===================================================================
--- uspace/lib/c/include/ipc/input.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/ipc/input.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,10 +39,11 @@
 
 typedef enum {
-	INPUT_YIELD = IPC_FIRST_USER_METHOD,
-	INPUT_RECLAIM
+	INPUT_ACTIVATE = IPC_FIRST_USER_METHOD
 } input_request_t;
 
 typedef enum {
-	INPUT_EVENT_KEY = IPC_FIRST_USER_METHOD,
+	INPUT_EVENT_ACTIVE = IPC_FIRST_USER_METHOD,
+	INPUT_EVENT_DEACTIVE,
+	INPUT_EVENT_KEY,
 	INPUT_EVENT_MOVE,
 	INPUT_EVENT_ABS_MOVE,
Index: uspace/lib/c/include/ipc/ipc.h
===================================================================
--- uspace/lib/c/include/ipc/ipc.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/ipc/ipc.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,5 +44,5 @@
 #include <abi/ipc/methods.h>
 #include <abi/synch.h>
-#include <task.h>
+#include <abi/proc/task.h>
 
 typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
Index: uspace/lib/c/include/ipc/iplink.h
===================================================================
--- uspace/lib/c/include/ipc/iplink.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/ipc/iplink.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -41,4 +41,5 @@
 	IPLINK_GET_MTU = IPC_FIRST_USER_METHOD,
 	IPLINK_GET_MAC48,
+	IPLINK_SET_MAC48,
 	IPLINK_SEND,
 	IPLINK_SEND6,
@@ -48,5 +49,6 @@
 
 typedef enum {
-	IPLINK_EV_RECV = IPC_FIRST_USER_METHOD
+	IPLINK_EV_RECV = IPC_FIRST_USER_METHOD,
+	IPLINK_EV_CHANGE_ADDR,
 } iplink_event_t;
 
Index: uspace/lib/c/include/ipc/irq.h
===================================================================
--- uspace/lib/c/include/ipc/irq.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/include/ipc/irq.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,47 @@
+/*
+ * 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 libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IPC_IRQ_H_
+#define LIBC_IPC_IRQ_H_
+
+#include <sys/types.h>
+#include <abi/ddi/irq.h>
+
+extern int ipc_irq_subscribe(int, int, sysarg_t, const irq_code_t *);
+extern int ipc_irq_unsubscribe(int, int);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/loader/loader.h
===================================================================
--- uspace/lib/c/include/loader/loader.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/loader/loader.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,5 +37,5 @@
 #define LIBC_LOADER_H_
 
-#include <task.h>
+#include <abi/proc/task.h>
 
 /** Forward declararion */
Index: uspace/lib/c/include/stddef.h
===================================================================
--- uspace/lib/c/include/stddef.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/stddef.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,4 +38,9 @@
 #include <sys/types.h>
 
+#ifndef NULL
+	#define NULL  ((void *) 0)
+#endif
+
+
 #endif
 
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/stdio.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -120,4 +120,5 @@
 extern int snprintf(char *, size_t , const char *, ...)
     PRINTF_ATTRIBUTE(3, 4);
+extern int vasprintf(char **, const char *, va_list);
 extern int asprintf(char **, const char *, ...)
     PRINTF_ATTRIBUTE(2, 3);
Index: uspace/lib/c/include/task.h
===================================================================
--- uspace/lib/c/include/task.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/c/include/task.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,9 +39,14 @@
 #include <abi/proc/task.h>
 #include <stdarg.h>
+#include <async.h>
+#include <types/task.h>
 
-typedef enum {
-	TASK_EXIT_NORMAL,
-	TASK_EXIT_UNEXPECTED
-} task_exit_t;
+typedef struct {
+	ipc_call_t result;
+	aid_t aid;
+} task_wait_t;
+
+struct _TASK;
+typedef struct _TASK task_t;
 
 extern task_id_t task_get_id(void);
@@ -49,11 +54,16 @@
 extern int task_kill(task_id_t);
 
-extern int task_spawnv(task_id_t *, const char *path, const char *const []);
-extern int task_spawnvf(task_id_t *, const char *path, const char *const [],
-    int *const []);
-extern int task_spawn(task_id_t *, const char *path, int, va_list ap);
-extern int task_spawnl(task_id_t *, const char *path, ...);
+extern int task_spawnv(task_id_t *, task_wait_t *, const char *path,
+    const char *const []);
+extern int task_spawnvf(task_id_t *, task_wait_t *, const char *path,
+    const char *const [], int *const []);
+extern int task_spawn(task_id_t *, task_wait_t *, const char *path, int,
+    va_list ap);
+extern int task_spawnl(task_id_t *, task_wait_t *, const char *path, ...);
 
-extern int task_wait(task_id_t id, task_exit_t *, int *);
+extern int task_setup_wait(task_id_t, task_wait_t *);
+extern void task_cancel_wait(task_wait_t *);
+extern int task_wait(task_wait_t *, task_exit_t *, int *);
+extern int task_wait_task_id(task_id_t, task_exit_t *, int *);
 extern int task_retval(int);
 
Index: uspace/lib/c/include/types/task.h
===================================================================
--- uspace/lib/c/include/types/task.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/c/include/types/task.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_TYPES_TASK_H_
+#define LIBC_TYPES_TASK_H_
+
+typedef enum {
+	TASK_EXIT_NORMAL,
+	TASK_EXIT_UNEXPECTED
+} task_exit_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/draw/Makefile
===================================================================
--- uspace/lib/draw/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,4 +37,6 @@
 	cursor/embedded.c \
 	font/embedded.c \
+	font/bitmap_backend.c \
+	font/pcf.c \
 	gfx/font-8x16.c \
 	gfx/cursor-11x18.c \
Index: uspace/lib/draw/font.c
===================================================================
--- uspace/lib/draw/font.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/font.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2012 Petr Koupy
+ * Copyright (c) 2014 Martin Sucha
  * All rights reserved.
  *
@@ -34,6 +35,7 @@
  */
 
-#include <assert.h>
 #include <malloc.h>
+#include <errno.h>
+#include <str.h>
 
 #include "font.h"
@@ -41,127 +43,129 @@
 #include "drawctx.h"
 
-void font_init(font_t *font, font_decoder_type_t decoder, char *path, uint16_t points)
+font_t *font_create(font_backend_t *backend, void *backend_data)
 {
-	font->points = points;
-
-	switch (decoder) {
-	case FONT_DECODER_EMBEDDED:
-		font->decoder = &fd_embedded;
-		break;
-	default:
-		font->decoder = NULL;
-		break;
-	}
-
-	if (font->decoder) {
-		font->decoder->init(path, &font->glyph_count, &font->decoder_data);
-
-		if (font->glyph_count > 0) {
-			font->glyphs = (surface_t **) malloc(sizeof(surface_t *) * font->glyph_count);
-		} else {
-			font->glyphs = NULL;
-		}
-
-		if (font->glyphs) {
-			for (size_t i = 0; i < font->glyph_count; ++i) {
-				font->glyphs[i] = NULL;
-			}
-		} else {
-			font->glyph_count = 0;
-		}
-	} else {
-		font->glyph_count = 0;
-		font->glyphs = NULL;
-		font->decoder_data = NULL;
-	}
+	font_t *font = malloc(sizeof(font_t));
+	if (font == NULL)
+		return NULL;
+	
+	font->backend = backend;
+	font->backend_data = backend_data;
+	
+	return font;
 }
 
 void font_release(font_t *font)
 {
-	if (font->glyphs) {
-		for (size_t i = 0; i < font->glyph_count; ++i) {
-			if (font->glyphs[i]) {
-				surface_destroy(font->glyphs[i]);
+	font->backend->release(font->backend_data);
+}
+
+int font_get_metrics(font_t *font, font_metrics_t *metrics) {
+	return font->backend->get_font_metrics(font->backend_data, metrics);
+}
+
+int font_resolve_glyph(font_t *font, wchar_t c, glyph_id_t *glyph_id) {
+	return font->backend->resolve_glyph(font->backend_data, c, glyph_id);
+}
+
+int font_get_glyph_metrics(font_t *font, glyph_id_t glyph_id,
+    glyph_metrics_t *glyph_metrics)
+{
+	return font->backend->get_glyph_metrics(font->backend_data,
+	    glyph_id, glyph_metrics);
+}
+
+int font_render_glyph(font_t *font, drawctx_t *context, source_t *source,
+    sysarg_t x, sysarg_t y, glyph_id_t glyph_id)
+{
+	return font->backend->render_glyph(font->backend_data, context, source,
+	    x, y, glyph_id);
+}
+
+/* TODO this is bad interface */
+int font_get_box(font_t *font, char *text, sysarg_t *width, sysarg_t *height)
+{
+	font_metrics_t fm;
+	int rc = font_get_metrics(font, &fm);
+	if (rc != EOK)
+		return rc;
+
+	native_t x = 0;
+
+	size_t off = 0;
+	while (true) {
+		wchar_t c = str_decode(text, &off, STR_NO_LIMIT);
+		if (c == 0)
+			break;
+		
+		glyph_id_t glyph_id;
+		rc = font_resolve_glyph(font, c, &glyph_id);
+		if (rc != EOK) {
+			int rc2 = font_resolve_glyph(font, U_SPECIAL, &glyph_id);
+			if (rc2 != EOK) {
+				return rc;
 			}
 		}
-		free(font->glyphs);
+		
+		glyph_metrics_t glyph_metrics;
+		rc = font_get_glyph_metrics(font, glyph_id, &glyph_metrics);
+		if (rc != EOK)
+			return rc;
+		
+		x += glyph_metrics_get_advancement(&glyph_metrics);
 	}
-	
-	if (font->decoder) {
-		font->decoder->release(font->decoder_data);
-	}
+
+	*width = x;
+	*height = fm.ascender + fm.descender;
+	return EOK;
 }
 
-void font_get_box(font_t *font, char *text, sysarg_t *width, sysarg_t *height)
+/* TODO this is bad interface */
+int font_draw_text(font_t *font, drawctx_t *context, source_t *source,
+    const char *text, sysarg_t sx, sysarg_t sy)
 {
-	assert(width);
-	assert(height);
-
-	(*width) = 0;
-	(*height) = 0;
-
-	if (!text) {
-		return;
-	}
-
-	while (*text) {
-		uint16_t glyph_idx = font->decoder->resolve(*text, font->decoder_data);
-		if (glyph_idx < font->glyph_count) {
-			if (!font->glyphs[glyph_idx]) {
-				font->glyphs[glyph_idx] =
-				    font->decoder->render(glyph_idx, font->points);
-			}
-
-			surface_t *glyph = font->glyphs[glyph_idx];
-			if (glyph) {
-				sysarg_t w;
-				sysarg_t h;
-				surface_get_resolution(glyph, &w, &h);
-				(*width) += w;
-				(*height) = (*height) < h ? h : (*height);
-			}
-		}
-		++text;
-	}
-}
-
-void font_draw_text(font_t *font, drawctx_t *context, source_t *source,
-    const char *text, sysarg_t x, sysarg_t y)
-{
-	assert(context);
-	assert(source);
-
 	drawctx_save(context);
 	drawctx_set_compose(context, compose_over);
 
-	while (*text) {
-		uint16_t glyph_idx = font->decoder->resolve(*text, font->decoder_data);
-		if (glyph_idx < font->glyph_count) {
-			if (!font->glyphs[glyph_idx]) {
-				font->glyphs[glyph_idx] =
-				    font->decoder->render(glyph_idx, font->points);
-			}
+	font_metrics_t fm;
+	int rc = font_get_metrics(font, &fm);
+	if (rc != EOK)
+		return rc;
 
-			surface_t *glyph = font->glyphs[glyph_idx];
-			if (glyph) {
-				sysarg_t w;
-				sysarg_t h;
-				surface_get_resolution(glyph, &w, &h);
+	native_t baseline = sy + fm.ascender;
+	native_t x = sx;
 
-				transform_t transform;
-				transform_identity(&transform);
-				transform_translate(&transform, x, y);
-				source_set_transform(source, transform);
-				source_set_mask(source, glyph, false);
-				drawctx_transfer(context, x, y, w, h);
-
-				x += w;
+	size_t off = 0;
+	while (true) {
+		wchar_t c = str_decode(text, &off, STR_NO_LIMIT);
+		if (c == 0)
+			break;
+		
+		glyph_id_t glyph_id;
+		rc = font_resolve_glyph(font, c, &glyph_id);
+		if (rc != EOK) {
+			int rc2 = font_resolve_glyph(font, U_SPECIAL, &glyph_id);
+			if (rc2 != EOK) {
+				return rc;
 			}
 		}
-		++text;
+		
+		glyph_metrics_t glyph_metrics;
+		rc = font_get_glyph_metrics(font, glyph_id, &glyph_metrics);
+		if (rc != EOK)
+			return rc;
+
+		rc = font_render_glyph(font, context, source, x, baseline,
+		    glyph_id);
+		if (rc != EOK)
+			return rc;
+
+		x += glyph_metrics_get_advancement(&glyph_metrics);
+
 	}
 
 	drawctx_restore(context);
 	source_set_mask(source, NULL, false);
+
+	return EOK;
 }
 
Index: uspace/lib/draw/font.h
===================================================================
--- uspace/lib/draw/font.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/font.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2012 Petr Koupy
+ * Copyright (c) 2014 Martin Sucha
  * All rights reserved.
  *
@@ -45,28 +46,72 @@
 typedef struct drawctx drawctx_t;
 
-typedef enum {
-	FONT_DECODER_EMBEDDED
-} font_decoder_type_t;
+typedef int metric_t;
 
 typedef struct {
-	void (*init)(char *, uint16_t *, void **);
-	uint16_t (*resolve)(const wchar_t, void *);
-	surface_t *(*render)(uint16_t, uint16_t);
+	/* Horizontal distance between origin and left side of the glyph */ 
+	metric_t left_side_bearing;
+	
+	/* Width of the actual glyph drawn */
+	metric_t width;
+	
+	/* Horizontal distance between right side of the glyph and origin
+	   of the next glyph */
+	metric_t right_side_bearing;
+	
+	/* Vertical distance between baseline and top of the glyph
+	   (positive to top) */
+	metric_t ascender;
+	
+	/* Height of the actual glyph drawn */
+	metric_t height;
+} glyph_metrics_t;
+
+static inline metric_t glyph_metrics_get_descender(glyph_metrics_t *gm)
+{
+	return gm->height - gm->ascender;
+}
+
+static inline metric_t glyph_metrics_get_advancement(glyph_metrics_t *gm)
+{
+	return gm->left_side_bearing + gm->width + gm->right_side_bearing;
+}
+
+typedef struct {
+	/* Distance between top of the line and baseline */
+	metric_t ascender;
+	
+	/* Distance between baseline and bottom of the line */
+	metric_t descender;
+	
+	/* Distance between bottom of the line and top of the next line */
+	metric_t leading;
+} font_metrics_t;
+
+typedef uint32_t glyph_id_t;
+
+typedef struct {
+	int (*get_font_metrics)(void *, font_metrics_t *);
+	int (*resolve_glyph)(void *, wchar_t, glyph_id_t *);
+	int (*get_glyph_metrics)(void *, glyph_id_t, glyph_metrics_t *);
+	int (*render_glyph)(void *, drawctx_t *, source_t *, sysarg_t,
+	    sysarg_t, glyph_id_t);
 	void (*release)(void *);
-} font_decoder_t;
+} font_backend_t;
 
-typedef struct font {
-	uint16_t points;
-	uint16_t glyph_count;
-	surface_t **glyphs;
-	font_decoder_t *decoder;
-	void *decoder_data;
+typedef struct {
+	font_backend_t *backend;
+	void *backend_data;
 } font_t;
 
-extern void font_init(font_t *, font_decoder_type_t, char *, uint16_t);
+extern font_t *font_create(font_backend_t *, void *);
+extern int font_get_metrics(font_t *, font_metrics_t *);
+extern int font_resolve_glyph(font_t *, wchar_t, glyph_id_t *);
+extern int font_get_glyph_metrics(font_t *, glyph_id_t, glyph_metrics_t *);
+extern int font_render_glyph(font_t *, drawctx_t *, source_t *,
+    sysarg_t, sysarg_t, glyph_id_t);
 extern void font_release(font_t *);
 
-extern void font_get_box(font_t *, char *, sysarg_t *, sysarg_t *);
-extern void font_draw_text(font_t *, drawctx_t *, source_t *, const char *,
+extern int font_get_box(font_t *, char *, sysarg_t *, sysarg_t *);
+extern int font_draw_text(font_t *, drawctx_t *, source_t *, const char *,
     sysarg_t, sysarg_t);
 
Index: uspace/lib/draw/font/bitmap_backend.c
===================================================================
--- uspace/lib/draw/font/bitmap_backend.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/draw/font/bitmap_backend.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2012 Petr Koupy
+ * Copyright (c) 2014 Martin Sucha
+ * 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 draw
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include <malloc.h>
+#include <errno.h>
+
+#include "../font.h"
+#include "../drawctx.h"
+#include "bitmap_backend.h"
+
+typedef struct {
+	surface_t *surface;
+	glyph_metrics_t metrics;
+	bool metrics_loaded;
+} glyph_cache_item_t;
+
+typedef struct {
+	uint16_t points;
+	uint32_t glyph_count;
+	font_metrics_t font_metrics;
+	glyph_cache_item_t *glyph_cache;
+	bitmap_font_decoder_t *decoder;
+	void *decoder_data;
+	bool scale;
+	double scale_ratio;
+} bitmap_backend_data_t;
+
+static int bb_get_font_metrics(void *backend_data, font_metrics_t *font_metrics)
+{
+	bitmap_backend_data_t *data = (bitmap_backend_data_t *) backend_data;
+	
+	*font_metrics = data->font_metrics;
+	
+	return EOK;
+}
+
+static int bb_resolve_glyph(void *backend_data, wchar_t c, glyph_id_t *glyph_id)
+{
+	bitmap_backend_data_t *data = (bitmap_backend_data_t *) backend_data;
+	return data->decoder->resolve_glyph(data->decoder_data, c, glyph_id);
+}
+
+static int bb_get_glyph_metrics(void *backend_data, glyph_id_t glyph_id,
+    glyph_metrics_t *glyph_metrics)
+{
+	bitmap_backend_data_t *data = (bitmap_backend_data_t *) backend_data;
+	
+	if (glyph_id >= data->glyph_count)
+		return ENOENT;
+	
+	if (data->glyph_cache[glyph_id].metrics_loaded) {
+		*glyph_metrics = data->glyph_cache[glyph_id].metrics;
+		return EOK;
+	}
+	
+	glyph_metrics_t gm;
+	
+	int rc = data->decoder->load_glyph_metrics(data->decoder_data, glyph_id,
+	    &gm);
+	if (rc != EOK)
+		return rc;
+	
+	if (data->scale) {
+		gm.left_side_bearing = (metric_t)
+		    (data->scale_ratio * gm.left_side_bearing + 0.5);
+		gm.width = (metric_t)
+		    (data->scale_ratio * gm.width + 0.5);
+		gm.right_side_bearing = (metric_t)
+		    (data->scale_ratio * gm.right_side_bearing + 0.5);
+		gm.ascender = (metric_t)
+		    (data->scale_ratio * gm.ascender + 0.5);
+		gm.height = (metric_t)
+		    (data->scale_ratio * gm.height + 0.5);
+	}
+	
+	
+	
+	data->glyph_cache[glyph_id].metrics = gm;
+	data->glyph_cache[glyph_id].metrics_loaded = true;
+	*glyph_metrics = gm;
+	return EOK;
+}
+
+static int get_glyph_surface(bitmap_backend_data_t *data, glyph_id_t glyph_id,
+    surface_t **result)
+{
+	if (glyph_id >= data->glyph_count)
+		return ENOENT;
+	
+	if (data->glyph_cache[glyph_id].surface != NULL) {
+		*result = data->glyph_cache[glyph_id].surface;
+		return EOK;
+	}
+	
+	surface_t *raw_surface;
+	int rc = data->decoder->load_glyph_surface(data->decoder_data, glyph_id,
+	    &raw_surface);
+	if (rc != EOK)
+		return rc;
+	
+	sysarg_t w;
+	sysarg_t h;
+	surface_get_resolution(raw_surface, &w, &h);
+	
+	if (!data->scale) {
+		*result = raw_surface;
+		return EOK;
+	}
+	
+	source_t source;
+	source_init(&source);
+	source_set_texture(&source, raw_surface, PIXELMAP_EXTEND_TRANSPARENT_BLACK);
+
+	transform_t transform;
+	transform_identity(&transform);
+	transform_translate(&transform, 0.5, 0.5);
+	transform_scale(&transform, data->scale_ratio, data->scale_ratio);
+	source_set_transform(&source, transform);
+
+	surface_coord_t scaled_width = (data->scale_ratio * ((double) w) + 0.5);
+	surface_coord_t scaled_height = (data->scale_ratio * ((double) h) + 0.5);
+
+	surface_t *scaled_surface = surface_create(scaled_width, scaled_height,
+	    NULL, 0);
+	if (!scaled_surface) {
+		surface_destroy(raw_surface);
+		return ENOMEM;
+	}
+
+	drawctx_t context;
+	drawctx_init(&context, scaled_surface);
+	drawctx_set_source(&context, &source);
+	drawctx_transfer(&context, 0, 0, scaled_width, scaled_height);
+
+	surface_destroy(raw_surface);
+	
+	data->glyph_cache[glyph_id].surface = scaled_surface;
+	*result = scaled_surface;
+	return EOK;
+}
+
+static int bb_render_glyph(void *backend_data, drawctx_t *context,
+    source_t *source, sysarg_t ox, sysarg_t oy, glyph_id_t glyph_id)
+{
+	bitmap_backend_data_t *data = (bitmap_backend_data_t *) backend_data;
+	
+	glyph_metrics_t glyph_metrics;
+	int rc = bb_get_glyph_metrics(backend_data, glyph_id, &glyph_metrics);
+	if (rc != EOK)
+		return rc;
+	
+	surface_t *glyph_surface;
+	rc = get_glyph_surface(data, glyph_id, &glyph_surface);
+	if (rc != EOK)
+		return rc;
+	
+	native_t x = ox + glyph_metrics.left_side_bearing;
+	native_t y = oy - glyph_metrics.ascender;
+	
+	transform_t transform;
+	transform_identity(&transform);
+	transform_translate(&transform, x, y);
+	source_set_transform(source, transform);
+	source_set_mask(source, glyph_surface, false);
+	drawctx_transfer(context, x, y, glyph_metrics.width,
+	    glyph_metrics.height);
+
+	return EOK;
+}
+
+static void bb_release(void *backend_data)
+{
+	bitmap_backend_data_t *data = (bitmap_backend_data_t *) backend_data;
+
+	for (size_t i = 0; i < data->glyph_count; ++i) {
+		if (data->glyph_cache[i].surface) {
+			surface_destroy(data->glyph_cache[i].surface);
+		}
+	}
+	free(data->glyph_cache);
+
+	data->decoder->release(data->decoder_data);
+}
+
+font_backend_t bitmap_backend = {
+	.get_font_metrics = bb_get_font_metrics,
+	.resolve_glyph = bb_resolve_glyph,
+	.get_glyph_metrics = bb_get_glyph_metrics,
+	.render_glyph = bb_render_glyph,
+	.release = bb_release
+};
+
+int bitmap_font_create(bitmap_font_decoder_t *decoder, void *decoder_data,
+    uint32_t glyph_count, font_metrics_t font_metrics, uint16_t points,
+    font_t **out_font)
+{
+	if (glyph_count == 0)
+		return EINVAL;
+	
+	bitmap_backend_data_t *data = malloc(sizeof(bitmap_backend_data_t));
+	if (data == NULL)
+		return ENOMEM;
+
+	data->glyph_count = glyph_count;
+	data->points = points;
+	data->decoder = decoder;
+	data->decoder_data = decoder_data;
+	data->font_metrics = font_metrics;
+	metric_t line_height = (font_metrics.ascender + font_metrics.descender);
+	if (points == line_height) {
+		data->scale = false;
+		data->scale_ratio = 1.0;
+	}
+	else {
+		data->scale = true;
+		data->scale_ratio = ((double) points) / ((double) line_height);
+		line_height = (data->scale_ratio * ((double) line_height));
+		data->font_metrics.ascender = (metric_t)
+		    (data->scale_ratio * data->font_metrics.ascender + 0.5);
+		data->font_metrics.descender =
+		    line_height - data->font_metrics.ascender;
+		data->font_metrics.leading = (metric_t)
+		    (data->scale_ratio * data->font_metrics.leading + 0.5);
+	}
+
+	data->glyph_cache = calloc(data->glyph_count,
+	    sizeof(glyph_cache_item_t));
+	if (data->glyph_cache == NULL) {
+		free(data);
+		return ENOMEM;
+	}
+
+	for (size_t i = 0; i < data->glyph_count; ++i) {
+		data->glyph_cache[i].surface = NULL;
+		data->glyph_cache[i].metrics_loaded = false;
+	}
+
+	font_t *font = font_create(&bitmap_backend, data);
+	if (font == NULL) {
+		free(data->glyph_cache);
+		free(data);
+		return ENOMEM;
+	}
+	
+	*out_font = font;
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/draw/font/bitmap_backend.h
===================================================================
--- uspace/lib/draw/font/bitmap_backend.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/draw/font/bitmap_backend.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2012 Petr Koupy
+ * Copyright (c) 2014 Martin Sucha
+ * 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 draw
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef DRAW_FONT_BITMAP_BACKEND_H_
+#define DRAW_FONT_BITMAP_BACKEND_H_
+
+#include <sys/types.h>
+
+#include "../font.h"
+#include "../surface.h"
+#include "../source.h"
+
+typedef struct {
+	int (*resolve_glyph)(void *, const wchar_t, glyph_id_t *);
+	int (*load_glyph_surface)(void *, glyph_id_t, surface_t **);
+	int (*load_glyph_metrics)(void *, glyph_id_t, glyph_metrics_t *);
+	void (*release)(void *);
+} bitmap_font_decoder_t;
+
+extern int bitmap_font_create(bitmap_font_decoder_t *, void *, uint32_t,
+    font_metrics_t, uint16_t, font_t **);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/draw/font/embedded.c
===================================================================
--- uspace/lib/draw/font/embedded.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/font/embedded.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2012 Petr Koupy
+ * Copyright (c) 2014 Martin Sucha
  * All rights reserved.
  *
@@ -34,71 +35,55 @@
  */
 
-#include <assert.h>
 #include <sys/types.h>
 #include <malloc.h>
+#include <errno.h>
 
 #include "../gfx/font-8x16.h"
 #include "embedded.h"
 #include "../drawctx.h"
+#include "bitmap_backend.h"
 
-static void fde_init(char *path, uint16_t *glyph_count, void **data)
+static int fde_resolve_glyph(void *unused, const wchar_t chr,
+    glyph_id_t *glyph_id)
 {
-	assert(glyph_count);
-	assert(data);
-
-	(*glyph_count) = FONT_GLYPHS;
-	(*data) = NULL;
+	bool found = false;
+	uint16_t glyph = fb_font_glyph(chr, &found);
+	if (!found)
+		return ENOENT;
+	
+	*glyph_id = glyph;
+	return EOK;
 }
 
-static uint16_t fde_resolve(const wchar_t chr, void *data)
+static int fde_load_glyph_surface(void *unused, glyph_id_t glyph_id,
+    surface_t **out_surface)
 {
-	return fb_font_glyph(chr);
+	surface_t *surface = surface_create(FONT_WIDTH, FONT_SCANLINES, NULL, 0);
+	if (!surface)
+		return ENOMEM;
+	
+	for (unsigned int y = 0; y < FONT_SCANLINES; ++y) {
+		for (unsigned int x = 0; x < FONT_WIDTH; ++x) {
+			pixel_t p = (fb_font[glyph_id][y] & (1 << (7 - x))) ? 
+			    PIXEL(255, 0, 0, 0) : PIXEL(0, 0, 0, 0);
+			surface_put_pixel(surface, x, y, p);
+		}
+	}
+	
+	*out_surface = surface;
+	return EOK;
 }
 
-static surface_t *fde_render(uint16_t glyph, uint16_t points)
+static int fde_load_glyph_metrics(void *unused, glyph_id_t glyph_id,
+    glyph_metrics_t *gm)
 {
-	surface_t *template = surface_create(FONT_WIDTH, FONT_SCANLINES, NULL, 0);
-	if (!template) {
-		return NULL;
-	}
-	for (unsigned int y = 0; y < FONT_SCANLINES; ++y) {
-		for (unsigned int x = 0; x < FONT_WIDTH; ++x) {
-			pixel_t p = (fb_font[glyph][y] & (1 << (7 - x))) ? 
-			    PIXEL(255, 0, 0, 0) : PIXEL(0, 0, 0, 0);
-			surface_put_pixel(template, x, y, p);
-		}
-	}
-
-	source_t source;
-	source_init(&source);
-	source_set_texture(&source, template, false);
-
-	transform_t transform;
-	transform_identity(&transform);
-	if (points != FONT_SCANLINES) {
-		double ratio = ((double) points) / ((double) FONT_SCANLINES);
-		transform_scale(&transform, ratio, ratio);
-		source_set_transform(&source, transform);
-	}
-
-	double width = FONT_WIDTH;
-	double height = FONT_SCANLINES;
-	transform_apply_linear(&transform, &width, &height);
-	surface_t *result =
-	    surface_create((sysarg_t) (width + 0.5), (sysarg_t) (height + 0.5), NULL, 0);
-	if (!result) {
-		surface_destroy(template);
-		return NULL;
-	}
-
-	drawctx_t context;
-	drawctx_init(&context, result);
-	drawctx_set_source(&context, &source);
-	drawctx_transfer(&context, 0, 0,
-	    (sysarg_t) (width + 0.5), (sysarg_t) (height + 0.5));
-
-	surface_destroy(template);
-
-	return result;
+	/* This is simple monospaced font, so fill this data statically */
+	gm->left_side_bearing = 0;
+	gm->width = FONT_WIDTH;
+	gm->right_side_bearing = 0;
+	gm->ascender = FONT_ASCENDER;
+	gm->height = FONT_SCANLINES;
+	
+	return EOK;
 }
 
@@ -108,11 +93,23 @@
 }
 
-font_decoder_t fd_embedded = {
-	.init = fde_init,
-	.resolve = fde_resolve,
-	.render = fde_render,
+bitmap_font_decoder_t fd_embedded = {
+	.resolve_glyph = fde_resolve_glyph,
+	.load_glyph_surface = fde_load_glyph_surface,
+	.load_glyph_metrics = fde_load_glyph_metrics,
 	.release = fde_release
 };
 
+font_metrics_t font_metrics = {
+	.ascender = FONT_ASCENDER,
+	.descender = (FONT_SCANLINES - FONT_ASCENDER),
+	.leading = 0
+};
+
+int embedded_font_create(font_t **font, uint16_t points)
+{
+	return bitmap_font_create(&fd_embedded, NULL, FONT_GLYPHS, font_metrics,
+	    points, font);
+}
+
 /** @}
  */
Index: uspace/lib/draw/font/embedded.h
===================================================================
--- uspace/lib/draw/font/embedded.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/font/embedded.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -39,5 +39,5 @@
 #include "../font.h"
 
-extern font_decoder_t fd_embedded;
+extern int embedded_font_create(font_t **, uint16_t points);
 
 #endif
Index: uspace/lib/draw/font/pcf.c
===================================================================
--- uspace/lib/draw/font/pcf.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/draw/font/pcf.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,628 @@
+/*
+ * Copyright (c) 2014 Martin Sucha
+ * 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 draw
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include <sys/types.h>
+#include <malloc.h>
+#include <errno.h>
+#include <byteorder.h>
+#include <stdio.h>
+#include <align.h>
+
+#include "pcf.h"
+#include "../drawctx.h"
+#include "bitmap_backend.h"
+
+#define PCF_TABLE_ACCELERATORS 0x02
+#define PCF_TABLE_METRICS      0x04
+#define PCF_TABLE_BITMAPS      0x08
+#define PCF_TABLE_INK_METRICS  0x10
+#define PCF_TABLE_ENCODINGS    0x20
+
+#define PCF_FORMAT_DEFAULT            0x00000000
+#define PCF_FORMAT_MASK               0xffffff00
+#define PCF_FORMAT_MSBYTE_FIRST       0x00000004
+#define PCF_FORMAT_MSBIT_FIRST        0x00000008
+#define PCF_FORMAT_COMPRESSED_METRICS 0x00000100
+
+typedef struct {
+	uint32_t type;
+	uint32_t format;
+	uint32_t size; /* in bytes */
+	uint32_t offset; /* in bytes from beginning of file */
+} __attribute__((__packed__)) pcf_toc_entry_t;
+
+typedef struct {
+	uint16_t min_byte2;
+	uint16_t max_byte2;
+	uint16_t min_byte1;
+	uint16_t max_byte1;
+	uint16_t default_char;
+} __attribute__((__packed__)) pcf_encoding_t;
+
+typedef struct {
+	uint8_t left_side_bearing;
+	uint8_t right_side_bearing;
+	uint8_t character_width;
+	uint8_t character_ascent;
+	uint8_t character_descent;
+} __attribute__((__packed__)) pcf_compressed_metrics_t;
+
+typedef struct {
+	int16_t left_side_bearing;
+	int16_t right_side_bearing;
+	int16_t character_width;
+	int16_t character_ascent;
+	int16_t character_descent;
+	uint16_t character_attributes;
+} __attribute__((__packed__)) pcf_default_metrics_t;
+
+typedef struct {
+	uint8_t unused_font_information[8];
+	int32_t font_ascent;
+	int32_t font_descent;
+} __attribute__((__packed__)) pcf_accelerators_t;
+
+typedef struct {
+	FILE *file;
+	uint32_t glyph_count;
+	pcf_toc_entry_t bitmap_table;
+	pcf_toc_entry_t metrics_table;
+	pcf_toc_entry_t encodings_table;
+	pcf_toc_entry_t accelerators_table;
+	pcf_encoding_t encoding;
+	font_metrics_t font_metrics;
+} pcf_data_t;
+
+static inline uint32_t uint32_t_pcf2host(uint32_t val, uint32_t format)
+{
+	if (format & PCF_FORMAT_MSBYTE_FIRST) {
+		return uint32_t_be2host(val);
+	}
+	else {
+		return uint32_t_le2host(val);
+	}
+}
+
+static inline uint16_t uint16_t_pcf2host(uint16_t val, uint32_t format)
+{
+	if (format & PCF_FORMAT_MSBYTE_FIRST) {
+		return uint16_t_be2host(val);
+	}
+	else {
+		return uint16_t_le2host(val);
+	}
+}
+
+static inline int16_t int16_t_pcf2host(int16_t val, uint32_t format)
+{
+	return (int16_t) uint16_t_pcf2host((uint16_t) val, format);
+}
+
+static inline int32_t int32_t_pcf2host(int32_t val, uint32_t format)
+{
+	return (int32_t) uint32_t_pcf2host((uint32_t) val, format);
+}
+
+
+static int16_t compressed2int(uint8_t compressed)
+{
+	int16_t ret = compressed;
+	ret -= 0x80;
+	return ret;
+}
+
+static int pcf_resolve_glyph(void *opaque_data, const wchar_t chr,
+    glyph_id_t *glyph_id)
+{
+	pcf_data_t *data = (pcf_data_t *) opaque_data;
+	
+	/* TODO is this correct? */
+	uint8_t byte1 = (chr >> 8) & 0xff;
+	uint8_t byte2 = chr & 0xff;
+	pcf_encoding_t *e = &data->encoding;
+
+	aoff64_t entry_index =
+	    (byte1 - e->min_byte1) * (e->max_byte2 - e->min_byte2 + 1) +
+	    (byte2 - e->min_byte2);
+	
+	aoff64_t entry_offset = data->encodings_table.offset +
+	    (sizeof(uint32_t) + 5 * sizeof(uint16_t)) +
+	    entry_index * sizeof(uint16_t);
+	
+	int rc = fseek(data->file, entry_offset, SEEK_SET);
+	if (rc != 0)
+		return errno;
+	
+	uint16_t glyph = 0;
+	size_t records_read = fread(&glyph, sizeof(uint16_t), 1, data->file);
+	if (records_read != 1)
+		return EINVAL;
+	
+	glyph = uint16_t_pcf2host(glyph, data->encodings_table.format);
+	
+	if (glyph == 0xffff)
+		return ENOENT;
+	
+	*glyph_id = glyph;
+	
+	return EOK;
+}
+
+static int load_glyph_metrics(pcf_data_t *data, uint32_t glyph_id,
+    pcf_toc_entry_t *table, pcf_default_metrics_t *metrics)
+{
+	aoff64_t offset;
+	int rc;
+	size_t records_read;
+	
+	if (table->format & PCF_FORMAT_COMPRESSED_METRICS) {
+		offset = table->offset + sizeof(uint32_t) + sizeof(uint16_t) +
+		    glyph_id * sizeof(pcf_compressed_metrics_t);
+		
+		rc = fseek(data->file, offset, SEEK_SET);
+		if (rc != 0)
+			return errno;
+		
+		pcf_compressed_metrics_t compressed_metrics;
+		records_read = fread(&compressed_metrics,
+		    sizeof(pcf_compressed_metrics_t), 1,data->file);
+		if (records_read != 1)
+			return EINVAL;
+		
+		metrics->left_side_bearing =
+		    compressed2int(compressed_metrics.left_side_bearing);
+		metrics->right_side_bearing =
+		    compressed2int(compressed_metrics.right_side_bearing);
+		metrics->character_width =
+		    compressed2int(compressed_metrics.character_width);
+		metrics->character_ascent =
+		    compressed2int(compressed_metrics.character_ascent);
+		metrics->character_descent =
+		    compressed2int(compressed_metrics.character_descent);
+		metrics->character_attributes = 0;
+	}
+	else {
+		offset = table->offset + 2 * sizeof(uint32_t) +
+		    glyph_id * sizeof(pcf_default_metrics_t);
+		
+		rc = fseek(data->file, offset, SEEK_SET);
+		if (rc != 0)
+			return errno;
+	
+		pcf_default_metrics_t uncompressed_metrics;
+		records_read = fread(&uncompressed_metrics,
+		    sizeof(pcf_default_metrics_t), 1,data->file);
+		if (records_read != 1)
+			return EINVAL;
+		
+		metrics->left_side_bearing =
+		    int16_t_pcf2host(uncompressed_metrics.left_side_bearing,
+		    table->format);
+		metrics->right_side_bearing =
+		    int16_t_pcf2host(uncompressed_metrics.right_side_bearing,
+		    table->format);
+		metrics->character_width =
+		    int16_t_pcf2host(uncompressed_metrics.character_width,
+		    table->format);
+		metrics->character_ascent =
+		    int16_t_pcf2host(uncompressed_metrics.character_ascent,
+		    table->format);
+		metrics->character_descent =
+		    int16_t_pcf2host(uncompressed_metrics.character_descent,
+		    table->format);
+		metrics->character_attributes =
+		    uint16_t_pcf2host(uncompressed_metrics.character_attributes,
+		    table->format);
+	}
+	
+	return EOK;
+}
+
+static int pcf_load_glyph_surface(void *opaque_data, glyph_id_t glyph_id,
+    surface_t **out_surface)
+{
+	pcf_data_t *data = (pcf_data_t *) opaque_data;
+	
+	pcf_default_metrics_t pcf_metrics;
+	memset(&pcf_metrics, 0, sizeof(pcf_default_metrics_t));
+	int rc = load_glyph_metrics(data, glyph_id, &data->metrics_table,
+	    &pcf_metrics);
+	if (rc != EOK)
+		return rc;
+	
+	aoff64_t offset = data->bitmap_table.offset + (2 * sizeof(uint32_t)) +
+	    (glyph_id * sizeof(uint32_t));
+	
+	rc = fseek(data->file, offset, SEEK_SET);
+	if (rc != 0)
+		return errno;
+	
+	uint32_t bitmap_offset = 0;
+	size_t records_read = fread(&bitmap_offset, sizeof(uint32_t), 1,
+	    data->file);
+	if (records_read != 1)
+		return EINVAL;
+	bitmap_offset = uint32_t_pcf2host(bitmap_offset,
+	    data->bitmap_table.format);
+	
+	offset = data->bitmap_table.offset + (2 * sizeof(uint32_t)) +
+	    (data->glyph_count * sizeof(uint32_t)) + (4 * sizeof(uint32_t))
+	    + bitmap_offset;
+	
+	rc = fseek(data->file, offset, SEEK_SET);
+	if (rc != 0)
+		return errno;
+	
+	surface_coord_t width = pcf_metrics.character_width;
+	surface_coord_t height = pcf_metrics.character_ascent +
+	    pcf_metrics.character_descent;
+	size_t row_padding_bytes = (1 << (data->bitmap_table.format & 3));
+	size_t word_size_bytes = (1 << ((data->bitmap_table.format >> 4) & 3));
+	size_t row_bytes = ALIGN_UP(ALIGN_UP(width, 8) / 8, row_padding_bytes);
+	size_t bitmap_bytes = height * row_bytes;
+	
+	uint8_t *bitmap = malloc(bitmap_bytes);
+	if (bitmap == NULL)
+		return ENOMEM;
+	
+	records_read = fread(bitmap, sizeof(uint8_t), bitmap_bytes,
+	    data->file);
+	
+	surface_t *surface = surface_create(width, height, NULL, 0);
+	if (!surface) {
+		free(bitmap);
+		return ENOMEM;
+	}
+	
+	for (unsigned int y = 0; y < height; ++y) {
+		size_t row_offset = row_bytes * y;
+		for (unsigned int x = 0; x < width; ++x) {
+			size_t word_index = x / (word_size_bytes * 8);
+			size_t column_offset1 = word_index * word_size_bytes;
+			size_t byte_index_within_word =
+				(x % (word_size_bytes * 8)) / 8;
+			size_t column_offset2;
+			if (data->bitmap_table.format & PCF_FORMAT_MSBYTE_FIRST) {
+				column_offset2 = (word_size_bytes - 1) - byte_index_within_word;
+			}
+			else {
+				column_offset2 = byte_index_within_word;
+			}
+			uint8_t b = bitmap[row_offset + column_offset1 + column_offset2];
+			bool set;
+			if (data->bitmap_table.format & PCF_FORMAT_MSBIT_FIRST) {
+				set = (b >> (7 - (x % 8))) & 1;
+			}
+			else {
+				set = (b >> (x % 8)) & 1;
+			}
+			pixel_t p = set ? PIXEL(255, 0, 0, 0) : PIXEL(0, 0, 0, 0);
+			surface_put_pixel(surface, x, y, p);
+		}
+	}
+	
+	*out_surface = surface;
+	free(bitmap);
+	return EOK;
+}
+
+static int pcf_load_glyph_metrics(void *opaque_data, glyph_id_t glyph_id,
+    glyph_metrics_t *gm)
+{
+	pcf_data_t *data = (pcf_data_t *) opaque_data;
+	
+	pcf_default_metrics_t pcf_metrics;
+	memset(&pcf_metrics, 0, sizeof(pcf_default_metrics_t));
+	int rc = load_glyph_metrics(data, glyph_id, &data->metrics_table,
+	    &pcf_metrics);
+	if (rc != EOK)
+		return rc;
+	
+	gm->left_side_bearing = pcf_metrics.left_side_bearing;
+	gm->width = pcf_metrics.character_width;
+	gm->right_side_bearing = pcf_metrics.right_side_bearing -
+	    pcf_metrics.character_width;
+	gm->height = pcf_metrics.character_descent +
+	    pcf_metrics.character_ascent;
+	gm->ascender = pcf_metrics.character_ascent;
+	
+	return EOK;
+}
+
+static void pcf_release(void *opaque_data)
+{
+	pcf_data_t *data = (pcf_data_t *) opaque_data;
+	
+	fclose(data->file);
+	free(data);
+}
+
+bitmap_font_decoder_t fd_pcf = {
+	.resolve_glyph = pcf_resolve_glyph,
+	.load_glyph_surface = pcf_load_glyph_surface,
+	.load_glyph_metrics = pcf_load_glyph_metrics,
+	.release = pcf_release
+};
+
+static int pcf_read_toc(pcf_data_t *data)
+{
+	int rc = fseek(data->file, 0, SEEK_END);
+	if (rc != 0)
+		return errno;
+	
+	aoff64_t file_size = ftell(data->file);
+	
+	rc = fseek(data->file, 0, SEEK_SET);
+	if (rc != 0)
+		return errno;
+	
+	char header[4];
+	size_t records_read = fread(header, sizeof(char), 4, data->file);
+	if (records_read != 4)
+		return EINVAL;
+	
+	if (header[0] != 1 || header[1] != 'f' || header[2] != 'c' ||
+	    header[3] != 'p')
+		return EINVAL;
+	
+	uint32_t table_count;
+	records_read = fread(&table_count, sizeof(uint32_t), 1,
+	    data->file);
+	if (records_read != 1)
+		return EINVAL;
+	
+	table_count = uint32_t_le2host(table_count);
+	
+	bool found_bitmap_table = false;
+	bool found_metrics_table = false;
+	bool found_encodings_table = false;
+	bool found_accelerators_table = false;
+	
+	for (uint32_t index = 0; index < table_count; index++) {
+		pcf_toc_entry_t toc_entry;
+		records_read = fread(&toc_entry, sizeof(pcf_toc_entry_t), 1,
+		    data->file);
+		toc_entry.type = uint32_t_le2host(toc_entry.type);
+		toc_entry.format = uint32_t_le2host(toc_entry.format);
+		toc_entry.size = uint32_t_le2host(toc_entry.size);
+		toc_entry.offset = uint32_t_le2host(toc_entry.offset);
+		
+		if (toc_entry.offset >= file_size)
+			continue;
+		
+		aoff64_t end = ((aoff64_t) toc_entry.offset) + ((aoff64_t) toc_entry.size);
+		if (end > file_size)
+			continue;
+		
+		if (toc_entry.type == PCF_TABLE_BITMAPS) {
+			if (found_bitmap_table)
+				return EINVAL;
+			found_bitmap_table = true;
+			data->bitmap_table = toc_entry;
+		}
+		else if (toc_entry.type == PCF_TABLE_METRICS) {
+			if (found_metrics_table)
+				return EINVAL;
+			found_metrics_table = true;
+			data->metrics_table = toc_entry;
+		}
+		else if (toc_entry.type == PCF_TABLE_ENCODINGS) {
+			if (found_encodings_table)
+				return EINVAL;
+			found_encodings_table = true;
+			data->encodings_table = toc_entry;
+		}
+		else if (toc_entry.type == PCF_TABLE_ACCELERATORS) {
+			if (found_accelerators_table)
+				return EINVAL;
+			found_accelerators_table = true;
+			data->accelerators_table = toc_entry;
+		}
+	}
+	
+	if (!found_bitmap_table || !found_metrics_table ||
+	    !found_encodings_table || !found_accelerators_table)
+		return EINVAL;
+	
+	return EOK;
+}
+
+static int pcf_seek_table_header(pcf_data_t *data, pcf_toc_entry_t *table)
+{
+	uint32_t format;
+	int rc = fseek(data->file, table->offset, SEEK_SET);
+	if (rc != 0)
+		return errno;
+	
+	size_t records_read = fread(&format, sizeof(uint32_t), 1, data->file);
+	if (records_read != 1)
+		return EINVAL;
+	
+	format = uint32_t_le2host(format);
+	if (format != table->format)
+		return EINVAL;
+	
+	return EOK;
+}
+
+static int pcf_read_bitmap_table_header(pcf_data_t *data)
+{
+	int rc = pcf_seek_table_header(data, &data->bitmap_table);
+	if (rc != EOK)
+		return rc;
+	
+	if ((data->bitmap_table.format & PCF_FORMAT_MASK) != PCF_FORMAT_DEFAULT)
+		return EINVAL;
+	
+	uint32_t glyph_count = 0;
+	size_t records_read = fread(&glyph_count, sizeof(uint32_t), 1,
+	    data->file);
+	if (records_read != 1)
+		return EINVAL;
+	glyph_count =  uint32_t_pcf2host(glyph_count, data->bitmap_table.format);
+
+	data->glyph_count = glyph_count;
+	return EOK;
+}
+
+static int pcf_read_metrics_table_header(pcf_data_t *data)
+{
+	int rc = pcf_seek_table_header(data, &data->metrics_table);
+	if (rc != EOK)
+		return rc;
+	
+	size_t records_read;
+	uint32_t metrics_count;
+	if (data->metrics_table.format & PCF_FORMAT_COMPRESSED_METRICS) {
+		uint16_t metrics_count_16;
+		records_read = fread(&metrics_count_16, sizeof(uint16_t), 1,
+		    data->file);
+		if (records_read != 1)
+			return EINVAL;
+		metrics_count_16 = uint16_t_pcf2host(metrics_count_16,
+		    data->metrics_table.format);
+		metrics_count = metrics_count_16;
+	}
+	else {
+		records_read = fread(&metrics_count, sizeof(uint32_t), 1,
+		    data->file);
+		if (records_read != 1)
+			return EINVAL;
+		metrics_count = uint32_t_pcf2host(metrics_count,
+		    data->metrics_table.format);
+	}
+	
+	if (metrics_count != data->glyph_count)
+		return EINVAL;
+	
+	return EOK;
+}
+
+static int pcf_read_encodings_table_header(pcf_data_t *data)
+{
+	int rc = pcf_seek_table_header(data, &data->encodings_table);
+	if (rc != EOK)
+		return rc;
+	
+	pcf_encoding_t encoding;
+	size_t records_read = fread(&encoding, sizeof(pcf_encoding_t), 1,
+	    data->file);
+	if (records_read != 1)
+		return EINVAL;
+	
+	encoding.min_byte1 = uint16_t_pcf2host(encoding.min_byte1,
+	    data->encodings_table.format);
+	encoding.max_byte1 = uint16_t_pcf2host(encoding.max_byte1,
+	    data->encodings_table.format);
+	encoding.min_byte2 = uint16_t_pcf2host(encoding.min_byte2,
+	    data->encodings_table.format);
+	encoding.max_byte2 = uint16_t_pcf2host(encoding.max_byte2,
+	    data->encodings_table.format);
+	encoding.default_char = uint16_t_pcf2host(encoding.default_char,
+	    data->encodings_table.format);
+	
+	data->encoding = encoding;
+	return EOK;
+}
+
+static int pcf_read_accelerators_table(pcf_data_t *data)
+{
+	int rc = pcf_seek_table_header(data, &data->accelerators_table);
+	if (rc != EOK)
+		return rc;
+	
+	pcf_accelerators_t accelerators;
+	size_t records_read = fread(&accelerators, sizeof(pcf_accelerators_t),
+	    1, data->file);
+	if (records_read != 1)
+		return EINVAL;
+	
+	data->font_metrics.ascender = int32_t_pcf2host(accelerators.font_ascent,
+	    data->accelerators_table.format);
+	data->font_metrics.descender = int32_t_pcf2host(accelerators.font_descent,
+	    data->accelerators_table.format);
+	data->font_metrics.leading = 0;
+	
+	return EOK;
+}
+
+int pcf_font_create(font_t **font, char *filename, uint16_t points)
+{
+	int rc;
+	pcf_data_t *data = malloc(sizeof(pcf_data_t));
+	if (data == NULL)
+		return ENOMEM;
+	
+	data->file = fopen(filename, "rb");
+	if (data->file == NULL)
+		goto read_error;
+	
+	rc = pcf_read_toc(data);
+	if (rc != EOK)
+		goto error;
+	
+	rc = pcf_read_bitmap_table_header(data);
+	if (rc != EOK)
+		goto error;
+	
+	rc = pcf_read_metrics_table_header(data);
+	if (rc != EOK)
+		goto error;
+	
+	rc = pcf_read_encodings_table_header(data);
+	if (rc != EOK)
+		goto error;
+	
+	rc = pcf_read_accelerators_table(data);
+	if (rc != EOK)
+		goto error;
+	
+	rc = bitmap_font_create(&fd_pcf, data, data->glyph_count,
+	    data->font_metrics, points, font);
+	if (rc != EOK)
+		goto error;
+	
+	return EOK;
+read_error:
+	rc = EINVAL;
+error:
+	if (data->file)
+		fclose(data->file);
+	free(data);
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/lib/draw/font/pcf.h
===================================================================
--- uspace/lib/draw/font/pcf.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/draw/font/pcf.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014 Martin Sucha
+ * 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 draw
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef DRAW_FONT_PBF_H_
+#define DRAW_FONT_PBF_H_
+
+#include "../font.h"
+
+extern int pcf_font_create(font_t **, char *path, uint16_t points);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/draw/gfx/font-8x16.c
===================================================================
--- uspace/lib/draw/gfx/font-8x16.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/gfx/font-8x16.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,7 +44,12 @@
  * mark glyph if no specific glyph exists.
  *
+ * If found is not null, indicate whether the glyph was found or not.
+ *
  */
-uint16_t fb_font_glyph(const wchar_t ch)
+uint16_t fb_font_glyph(const wchar_t ch, bool *found)
 {
+	if (found)
+		*found = true;
+	
 	if (ch == 0x0000)
 		return 0;
@@ -361,4 +366,7 @@
 	if (ch == 0xfeff)
 		return 2896;
+	
+	if (found)
+		*found = false;
 	
 	return 2898;
Index: uspace/lib/draw/gfx/font-8x16.h
===================================================================
--- uspace/lib/draw/gfx/font-8x16.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/gfx/font-8x16.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -37,10 +37,12 @@
 
 #include <sys/types.h>
+#include <stdbool.h>
 
 #define FONT_GLYPHS     2899
 #define FONT_WIDTH      8
 #define FONT_SCANLINES  16
+#define FONT_ASCENDER   12
 
-extern uint16_t fb_font_glyph(const wchar_t);
+extern uint16_t fb_font_glyph(const wchar_t, bool *);
 extern uint8_t fb_font[FONT_GLYPHS][FONT_SCANLINES];
 
Index: uspace/lib/draw/source.c
===================================================================
--- uspace/lib/draw/source.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/source.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -45,9 +45,9 @@
 	source->color = PIXEL(0, 0, 0, 0);
 	source->texture = NULL;
-	source->texture_tile = false;
+	source->texture_extend = PIXELMAP_EXTEND_TRANSPARENT_BLACK;
 
 	source->alpha = PIXEL(255, 0, 0, 0);
 	source->mask = NULL;
-	source->mask_tile = false;
+	source->mask_extend = PIXELMAP_EXTEND_TRANSPARENT_BLACK;
 }
 
@@ -73,8 +73,9 @@
 }
 
-void source_set_texture(source_t *source, surface_t *texture, bool tile)
+void source_set_texture(source_t *source, surface_t *texture,
+    pixelmap_extend_t extend)
 {
 	source->texture = texture;
-	source->texture_tile = tile;
+	source->texture_extend = extend;
 }
 
@@ -84,8 +85,9 @@
 }
 
-void source_set_mask(source_t *source, surface_t *mask, bool tile)
+void source_set_mask(source_t *source, surface_t *mask,
+    pixelmap_extend_t extend)
 {
 	source->mask = mask;
-	source->mask_tile = tile;
+	source->mask_extend = extend;
 }
 
@@ -95,5 +97,4 @@
 	    (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0)) &&
 	    (source->texture != NULL) &&
-	    (source->texture_tile == false) &&
 	    (transform_is_fast(&source->transform)));
 }
@@ -120,5 +121,5 @@
 		mask_pix = source->filter(
 		    surface_pixmap_access(source->mask),
-		    x, y, source->mask_tile);
+		    x, y, source->mask_extend);
 	} else {
 		mask_pix = source->alpha;
@@ -133,5 +134,5 @@
 		texture_pix = source->filter(
 		    surface_pixmap_access(source->texture),
-		    x, y, source->texture_tile);
+		    x, y, source->texture_extend);
 	} else {
 		texture_pix = source->color;
Index: uspace/lib/draw/source.h
===================================================================
--- uspace/lib/draw/source.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/draw/source.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -42,4 +42,5 @@
 #include <transform.h>
 #include <filter.h>
+#include <io/pixelmap.h>
 
 #include "surface.h"
@@ -51,9 +52,9 @@
 	pixel_t color;
 	surface_t *texture;
-	bool texture_tile;
+	pixelmap_extend_t texture_extend;
 
 	pixel_t alpha;
 	surface_t *mask;
-	bool mask_tile;
+	pixelmap_extend_t mask_extend;
 } source_t;
 
@@ -66,8 +67,8 @@
 
 extern void source_set_color(source_t *, pixel_t);
-extern void source_set_texture(source_t *, surface_t *, bool);
+extern void source_set_texture(source_t *, surface_t *, pixelmap_extend_t);
 
 extern void source_set_alpha(source_t *, pixel_t);
-extern void source_set_mask(source_t *, surface_t *, bool);
+extern void source_set_mask(source_t *, surface_t *, pixelmap_extend_t);
 
 extern bool source_is_fast(source_t *);
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/drv/generic/driver.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -951,7 +951,4 @@
 	driver = drv;
 	
-	/* Initialize interrupt module */
-	interrupt_init();
-	
 	/*
 	 * Register driver with device manager using generic handler for
Index: uspace/lib/drv/generic/interrupt.c
===================================================================
--- uspace/lib/drv/generic/interrupt.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/drv/generic/interrupt.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,20 +44,4 @@
 #include "private/driver.h"
 
-static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall);
-static interrupt_context_t *create_interrupt_context(void);
-static void delete_interrupt_context(interrupt_context_t *ctx);
-static void init_interrupt_context_list(interrupt_context_list_t *list);
-static void add_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx);
-static void remove_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx);
-static interrupt_context_t *find_interrupt_context_by_id(
-    interrupt_context_list_t *list, int id);
-static interrupt_context_t *find_interrupt_context(
-    interrupt_context_list_t *list, ddf_dev_t *dev, int irq);
-
-/** Interrupts */
-static interrupt_context_list_t interrupt_contexts;
-
 static irq_cmd_t default_cmds[] = {
 	{
@@ -73,132 +57,14 @@
 };
 
-void interrupt_init(void)
-{
-	/* Initialize the list of interrupt contexts. */
-	init_interrupt_context_list(&interrupt_contexts);
-	
-	/* Set generic interrupt handler. */
-	async_set_interrupt_received(driver_irq_handler);
-}
-
-static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)
-{
-	int id = (int)IPC_GET_IMETHOD(*icall);
-	interrupt_context_t *ctx;
-	
-	ctx = find_interrupt_context_by_id(&interrupt_contexts, id);
-	if (ctx != NULL && ctx->handler != NULL)
-		(*ctx->handler)(ctx->dev, iid, icall);
-}
-
-static interrupt_context_t *create_interrupt_context(void)
-{
-	interrupt_context_t *ctx;
-	
-	ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
-	if (ctx != NULL)
-		memset(ctx, 0, sizeof(interrupt_context_t));
-	
-	return ctx;
-}
-
-static void delete_interrupt_context(interrupt_context_t *ctx)
-{
-	if (ctx != NULL)
-		free(ctx);
-}
-
-static void init_interrupt_context_list(interrupt_context_list_t *list)
-{
-	memset(list, 0, sizeof(interrupt_context_list_t));
-	fibril_mutex_initialize(&list->mutex);
-	list_initialize(&list->contexts);
-}
-
-static void add_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx)
-{
-	fibril_mutex_lock(&list->mutex);
-	ctx->id = list->curr_id++;
-	list_append(&ctx->link, &list->contexts);
-	fibril_mutex_unlock(&list->mutex);
-}
-
-static void remove_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx)
-{
-	fibril_mutex_lock(&list->mutex);
-	list_remove(&ctx->link);
-	fibril_mutex_unlock(&list->mutex);
-}
-
-static interrupt_context_t *find_interrupt_context_by_id(
-    interrupt_context_list_t *list, int id)
-{
-	fibril_mutex_lock(&list->mutex);
-	
-	list_foreach(list->contexts, link, interrupt_context_t, ctx) {
-		if (ctx->id == id) {
-			fibril_mutex_unlock(&list->mutex);
-			return ctx;
-		}
-	}
-	
-	fibril_mutex_unlock(&list->mutex);
-	return NULL;
-}
-
-static interrupt_context_t *find_interrupt_context(
-    interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
-{
-	fibril_mutex_lock(&list->mutex);
-	
-	list_foreach(list->contexts, link, interrupt_context_t, ctx) {
-		if (ctx->irq == irq && ctx->dev == dev) {
-			fibril_mutex_unlock(&list->mutex);
-			return ctx;
-		}
-	}
-	
-	fibril_mutex_unlock(&list->mutex);
-	return NULL;
-}
-
-
 int register_interrupt_handler(ddf_dev_t *dev, int irq,
     interrupt_handler_t *handler, const irq_code_t *pseudocode)
 {
-	interrupt_context_t *ctx = create_interrupt_context();
-	
-	ctx->dev = dev;
-	ctx->irq = irq;
-	ctx->handler = handler;
-	
-	add_interrupt_context(&interrupt_contexts, ctx);
-	
-	if (pseudocode == NULL)
-		pseudocode = &default_pseudocode;
-	
-	int res = irq_register(irq, dev->handle, ctx->id, pseudocode);
-	if (res != EOK) {
-		remove_interrupt_context(&interrupt_contexts, ctx);
-		delete_interrupt_context(ctx);
-	}
-	
-	return res;
+	return async_irq_subscribe(irq, dev->handle,
+	    (async_notification_handler_t) handler, dev, pseudocode);
 }
 
 int unregister_interrupt_handler(ddf_dev_t *dev, int irq)
 {
-	interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts,
-	    dev, irq);
-	int res = irq_unregister(irq, dev->handle);
-	
-	if (ctx != NULL) {
-		remove_interrupt_context(&interrupt_contexts, ctx);
-		delete_interrupt_context(ctx);
-	}
-	
-	return res;
+	return async_irq_unsubscribe(irq, dev->handle);
 }
 
Index: uspace/lib/drv/include/ddf/interrupt.h
===================================================================
--- uspace/lib/drv/include/ddf/interrupt.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/drv/include/ddf/interrupt.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -49,21 +49,6 @@
  */
 
-typedef void interrupt_handler_t(ddf_dev_t *, ipc_callid_t, ipc_call_t *);
+typedef void interrupt_handler_t(ipc_callid_t, ipc_call_t *, ddf_dev_t *);
 
-typedef struct interrupt_context {
-	int id;
-	ddf_dev_t *dev;
-	int irq;
-	interrupt_handler_t *handler;
-	link_t link;
-} interrupt_context_t;
-
-typedef struct interrupt_context_list {
-	int curr_id;
-	list_t contexts;
-	fibril_mutex_t mutex;
-} interrupt_context_list_t;
-
-extern void interrupt_init(void);
 extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *,
     const irq_code_t *);
Index: uspace/lib/gui/button.c
===================================================================
--- uspace/lib/gui/button.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/gui/button.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,4 +38,6 @@
 #include <drawctx.h>
 #include <surface.h>
+#include <font/embedded.h>
+#include <errno.h>
 #include "common.h"
 #include "window.h"
@@ -76,5 +78,5 @@
 	sysarg_t cpt_width;
 	sysarg_t cpt_height;
-	font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
+	font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
 	
 	if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
@@ -83,5 +85,5 @@
 		
 		drawctx_set_source(&drawctx, &btn->text);
-		drawctx_set_font(&drawctx, &btn->font);
+		drawctx_set_font(&drawctx, btn->font);
 		
 		if (btn->caption)
@@ -96,5 +98,5 @@
 	widget_deinit(&btn->widget);
 	free(btn->caption);
-	font_release(&btn->font);
+	font_release(btn->font);
 }
 
@@ -171,9 +173,14 @@
 		btn->caption = str_dup(caption);
 	
-	font_init(&btn->font, FONT_DECODER_EMBEDDED, NULL, points);
+	int rc = embedded_font_create(&btn->font, points);
+	if (rc != EOK) {
+		free(btn->caption);
+		btn->caption = NULL;
+		return false;
+	}
 	
 	sysarg_t cpt_width;
 	sysarg_t cpt_height;
-	font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
+	font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
 	btn->widget.width_min = cpt_width + 10;
 	btn->widget.height_min = cpt_height + 10;
Index: uspace/lib/gui/button.h
===================================================================
--- uspace/lib/gui/button.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/gui/button.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -52,5 +52,5 @@
 	source_t text;
 	char *caption;
-	font_t font;
+	font_t *font;
 	signal_t clicked;
 } button_t;
Index: uspace/lib/gui/canvas.c
===================================================================
--- uspace/lib/gui/canvas.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/gui/canvas.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -58,5 +58,6 @@
 	source_init(&source);
 	source_set_transform(&source, transform);
-	source_set_texture(&source, canvas->surface, false);
+	source_set_texture(&source, canvas->surface,
+	    PIXELMAP_EXTEND_TRANSPARENT_BLACK);
 	
 	drawctx_t drawctx;
Index: uspace/lib/gui/label.c
===================================================================
--- uspace/lib/gui/label.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/gui/label.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,4 +38,6 @@
 #include <drawctx.h>
 #include <surface.h>
+#include <font/embedded.h>
+#include <errno.h>
 #include "window.h"
 #include "label.h"
@@ -58,5 +60,5 @@
 	sysarg_t cpt_width;
 	sysarg_t cpt_height;
-	font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
+	font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
 	
 	if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
@@ -65,5 +67,5 @@
 		
 		drawctx_set_source(&drawctx, &lbl->text);
-		drawctx_set_font(&drawctx, &lbl->font);
+		drawctx_set_font(&drawctx, lbl->font);
 		
 		if (lbl->caption)
@@ -84,5 +86,5 @@
 		sysarg_t cpt_width;
 		sysarg_t cpt_height;
-		font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
+		font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
 		
 		lbl->widget.width_min = cpt_width + 4;
@@ -99,5 +101,5 @@
 	widget_deinit(&lbl->widget);
 	free(lbl->caption);
-	font_release(&lbl->font);
+	font_release(lbl->font);
 }
 
@@ -161,9 +163,14 @@
 		lbl->caption = str_dup(caption);
 	
-	font_init(&lbl->font, FONT_DECODER_EMBEDDED, NULL, points);
+	int rc = embedded_font_create(&lbl->font, points);
+	if (rc != EOK) {
+		free(lbl->caption);
+		lbl->caption = NULL;
+		return false;
+	}
 	
 	sysarg_t cpt_width;
 	sysarg_t cpt_height;
-	font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
+	font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
 	
 	lbl->widget.width_min = cpt_width + 4;
Index: uspace/lib/gui/label.h
===================================================================
--- uspace/lib/gui/label.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/gui/label.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -51,5 +51,5 @@
 	source_t text;
 	char *caption;
-	font_t font;
+	font_t *font;
 	slot_t rewrite;
 } label_t;
Index: uspace/lib/gui/terminal.c
===================================================================
--- uspace/lib/gui/terminal.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/gui/terminal.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -104,14 +104,6 @@
 static void getterm(const char *svc, const char *app)
 {
-	char term[LOC_NAME_MAXLEN];
-	snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc);
-	
-	/* Wait for the terminal service to be ready */
-	service_id_t service_id;
-	int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);
-	if (rc != EOK)
-		return;
-	
-	task_spawnl(NULL, APP_GETTERM, APP_GETTERM, "-w", term, app, NULL);
+	task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
+	    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
 }
 
@@ -194,5 +186,5 @@
 	//        for full UTF-32 coverage.
 	
-	uint16_t glyph = fb_font_glyph(field->ch);
+	uint16_t glyph = fb_font_glyph(field->ch, NULL);
 	
 	for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
Index: uspace/lib/gui/window.c
===================================================================
--- uspace/lib/gui/window.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/gui/window.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -55,4 +55,5 @@
 #include <drawctx.h>
 #include <surface.h>
+#include <font/embedded.h>
 
 #include "common.h"
@@ -160,8 +161,12 @@
 	/* Window caption */
 	
-	font_t font;
-	font_init(&font, FONT_DECODER_EMBEDDED, NULL, 16);
-	
-	drawctx_set_font(&drawctx, &font);
+	font_t *font;
+	int rc = embedded_font_create(&font, 16);
+	if (rc != EOK) {
+		window_yield(widget->window);
+		return;
+	}
+	
+	drawctx_set_font(&drawctx, font);
 	source_set_color(&source, widget->window->is_focused ?
 	    color_caption_focus : color_caption_unfocus);
@@ -169,5 +174,5 @@
 	sysarg_t cpt_width;
 	sysarg_t cpt_height;
-	font_get_box(&font, widget->window->caption, &cpt_width, &cpt_height);
+	font_get_box(font, widget->window->caption, &cpt_width, &cpt_height);
 	
 	bool draw_title =
@@ -183,5 +188,5 @@
 	}
 	
-	font_release(&font);
+	font_release(font);
 	window_yield(widget->window);
 }
Index: uspace/lib/hound/src/client.c
===================================================================
--- uspace/lib/hound/src/client.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/hound/src/client.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -42,4 +42,5 @@
 #include <stdio.h>
 #include <libarch/types.h>
+#include <task.h>
 
 #include "protocol.h"
@@ -242,4 +243,6 @@
 		if (ret != EOK)
 			return ret;
+		if (count == 0)
+			return ENOENT;
 		target = tgt[0];
 	}
Index: pace/lib/math/arch/mips64/Makefile.inc
===================================================================
--- uspace/lib/math/arch/mips64/Makefile.inc	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,29 +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.
-#
-
-ARCH_SOURCES =
Index: pace/lib/math/arch/mips64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/mips64/include/libarch/math.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,72 +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 libmathmips64
- * @{
- */
-/** @file
- */
-
-#ifndef LIBMATH_mips64_MATH_H_
-#define LIBMATH_mips64_MATH_H_
-
-#include <mathtypes.h>
-#include <mod.h>
-#include <trunc.h>
-#include <trig.h>
-
-static inline double fmod(double dividend, double divisor)
-{
-	return double_mod(dividend, divisor);
-}
-
-static inline double trunc(double val)
-{
-	double_t arg;
-	arg.val = val;
-	
-	double_t ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
-}
-
-static inline double sin(double val)
-{
-	return double_sin(val);
-}
-
-static inline double cos(double val)
-{
-	return double_cos(val);
-}
-
-#endif
-
-/** @}
- */
Index: uspace/lib/nic/src/nic_driver.c
===================================================================
--- uspace/lib/nic/src/nic_driver.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/nic/src/nic_driver.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -47,6 +47,4 @@
 #include <ops/nic.h>
 #include <errno.h>
-
-#include <io/log.h>
 
 #include "nic_driver.h"
@@ -438,5 +436,4 @@
 		int rc = nic_ev_addr_changed(nic_data->client_session,
 		    address);
-		log_msg(LOG_DEFAULT, LVL_WARN, "rc=%d", rc);
 
 		if (rc != EOK) {
Index: uspace/lib/posix/include/posix/stdio.h
===================================================================
--- uspace/lib/posix/include/posix/stdio.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/posix/include/posix/stdio.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -107,4 +107,5 @@
 extern int snprintf(char *, size_t , const char *, ...) PRINTF_ATTRIBUTE(3, 4);
 #ifdef _GNU_SOURCE
+extern int vasprintf(char **, const char *, va_list);
 extern int asprintf(char **, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
 #endif
Index: uspace/lib/posix/include/posix/string.h
===================================================================
--- uspace/lib/posix/include/posix/string.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/posix/include/posix/string.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -64,7 +64,4 @@
  * forward declarations ought to be enough.
  */
-/* From str.h. */
-extern char * strtok_r(char *, const char *, char **);
-extern char * strtok(char *, const char *);
 
 /* From mem.h */
@@ -101,4 +98,9 @@
 extern char *__POSIX_DEF__(strstr)(const char *haystack, const char *needle);
 
+/* Tokenization functions. */
+extern char *__POSIX_DEF__(strtok_r)(char *, const char *, char **);
+extern char *__POSIX_DEF__(strtok)(char *, const char *);
+
+
 /* Collation Functions */
 extern int __POSIX_DEF__(strcoll)(const char *s1, const char *s2);
Index: uspace/lib/posix/source/string.c
===================================================================
--- uspace/lib/posix/source/string.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/posix/source/string.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -508,4 +508,57 @@
 	
 	return NULL;
+}
+
+/** Split string by delimiters.
+ *
+ * @param s             String to be tokenized. May not be NULL.
+ * @param delim		String with the delimiters.
+ * @return              Pointer to the prefix of @a s before the first
+ *                      delimiter character. NULL if no such prefix
+ *                      exists.
+ */
+char *posix_strtok(char *s, const char *delim)
+{
+	static char *next;
+
+	return posix_strtok_r(s, delim, &next);
+}
+
+
+/** Split string by delimiters.
+ *
+ * @param s             String to be tokenized. May not be NULL.
+ * @param delim		String with the delimiters.
+ * @param next		Variable which will receive the pointer to the
+ *                      continuation of the string following the first
+ *                      occurrence of any of the delimiter characters.
+ *                      May be NULL.
+ * @return              Pointer to the prefix of @a s before the first
+ *                      delimiter character. NULL if no such prefix
+ *                      exists.
+ */
+char *posix_strtok_r(char *s, const char *delim, char **next)
+{
+	char *start, *end;
+
+	if (s == NULL)
+		s = *next;
+
+	/* Skip over leading delimiters. */
+	while (*s && (posix_strchr(delim, *s) != NULL)) ++s;
+	start = s;
+
+	/* Skip over token characters. */
+	while (*s && (posix_strchr(delim, *s) == NULL)) ++s;
+	end = s;
+	*next = (*s ? s + 1 : s);
+
+	if (start == end) {
+		return NULL;	/* No more tokens. */
+	}
+
+	/* Overwrite delimiter with NULL terminator. */
+	*end = '\0';
+	return start;
 }
 
Index: uspace/lib/posix/source/sys/wait.c
===================================================================
--- uspace/lib/posix/source/sys/wait.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/posix/source/sys/wait.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -100,5 +100,5 @@
 	int retval;
 	
-	int rc = task_wait((task_id_t) pid, &texit, &retval);
+	int rc = task_wait_task_id((task_id_t) pid, &texit, &retval);
 	
 	if (rc < 0) {
Index: uspace/lib/scsi/include/scsi/mmc.h
===================================================================
--- uspace/lib/scsi/include/scsi/mmc.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/lib/scsi/include/scsi/mmc.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2014 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 libscsi
+ * @{
+ */
+/**
+ * @file SCSI Multi-Media Commands.
+ */
+
+#ifndef LIBSCSI_MMC_H_
+#define LIBSCSI_MMC_H_
+
+#include <stdint.h>
+
+/** SCSI command codes defined in SCSI-MMC */
+enum scsi_cmd_mmc {
+	SCSI_CMD_READ_TOC	= 0x43
+};
+
+/** SCSI Read TOC/PMA/ATIP command.
+ *
+ * Note: For SFF 8020 the command must be padded to 12 bytes.
+ */
+typedef struct {
+	/** Operation code (SCSI_CMD_READ_TOC) */
+	uint8_t op_code;
+	/** Reserved, MSF, Reserved */
+	uint8_t msf;
+	/** Reserved, Format */
+	uint8_t format;
+	/** Reserved */
+	uint8_t reserved_3;
+	/** Reserved */
+	uint8_t reserved_4;
+	/** Reserved */
+	uint8_t reserved_5;
+	/** Track/Session Number */
+	uint8_t track_sess_no;
+	/** Allocation Length */
+	uint16_t alloc_len;
+	/** Control */
+	uint8_t control;
+} __attribute__((packed)) scsi_cdb_read_toc_t;
+
+/** TOC Track Descriptor */
+typedef struct {
+	/** Reserved */
+	uint8_t reserved0;
+	/** ADR, Control */
+	uint8_t adr_control;
+	/** Track Number */
+	uint8_t track_no;
+	/** Reserved */
+	uint8_t reserved3;
+	/** Track Start Address */
+	uint32_t start_addr;
+} __attribute__((packed)) scsi_toc_track_desc_t;
+
+/** Read TOC response format 00001b: Multi-session Information
+ *
+ * Returned for Read TOC command with Format 0001b
+ */
+typedef struct {
+	/** TOC Data Length */
+	uint16_t toc_len;
+	/** First Complete Session Number */
+	uint8_t first_sess;
+	/** Last Complete Session Number */
+	uint8_t last_sess;
+	/** TOC Track Descriptor for first track in last complete session */
+	scsi_toc_track_desc_t ftrack_lsess;
+} __attribute__((packed)) scsi_toc_multisess_data_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/scsi/include/scsi/sbc.h
===================================================================
--- uspace/lib/scsi/include/scsi/sbc.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/scsi/include/scsi/sbc.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -50,4 +50,7 @@
 	SCSI_CMD_READ_CAPACITY_16	= 0x9e,
 
+	SCSI_CMD_SYNC_CACHE_10		= 0x35,
+	SCSI_CMD_SYNC_CACHE_16		= 0x91,
+
 	SCSI_CMD_WRITE_6		= 0x0a,
 	SCSI_CMD_WRITE_10		= 0x2a,
@@ -131,4 +134,36 @@
 } scsi_read_capacity_10_data_t;
 
+/** SCSI Synchronize Cache (10) command */
+typedef struct {
+	/** Operation code (SCSI_CMD_SYNC_CACHE_10) */
+	uint8_t op_code;
+	/** Reserved, Sync_NV, Immed, Reserved */
+	uint8_t flags;
+	/** Logical block address */
+	uint32_t lba;
+	/** Reserved, Group Number */
+	uint8_t group_no;
+	/** Number of Logical Blocks */
+	uint16_t numlb;
+	/** Control */
+	uint8_t control;
+} __attribute__((packed)) scsi_cdb_sync_cache_10_t;
+
+/** SCSI Synchronize Cache (16) command */
+typedef struct {
+	/** Operation code (SCSI_CMD_SYNC_CACHE_16) */
+	uint8_t op_code;
+	/** Reserved, Sync_NV, Immed, Reserved */
+	uint8_t flags;
+	/** Logical block address */
+	uint64_t lba;
+	/** Number of Logical Blocks */
+	uint32_t numlb;
+	/** Reserved, Group Number */
+	uint8_t group_no;
+	/** Control */
+	uint8_t control;
+} __attribute__((packed)) scsi_cdb_sync_cache_16_t;
+
 /** SCSI Write (10) command */
 typedef struct {
Index: uspace/lib/scsi/include/scsi/spc.h
===================================================================
--- uspace/lib/scsi/include/scsi/spc.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/scsi/include/scsi/spc.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -46,5 +46,9 @@
 };
 
-/** SCSI Inquiry command */
+/** SCSI Inquiry command
+ *
+ * Note: for SFF 8020 the command must be zero-padded to 12 bytes
+ * and alloc_len must be <= 0xff.
+ */
 typedef struct {
 	/** Operation code (SCSI_CMD_INQUIRY) */
Index: uspace/lib/softrend/filter.c
===================================================================
--- uspace/lib/softrend/filter.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/softrend/filter.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2012 Petr Koupy
+ * Copyright (c) 2014 Martin Sucha
  * All rights reserved.
  *
@@ -35,25 +36,83 @@
 
 #include "filter.h"
+#include <io/pixel.h>
 
-pixel_t filter_nearest(pixelmap_t *pixmap, double x, double y, bool tile)
+
+static long round(double val)
 {
-	long _x = x > 0 ? (long) (x + 0.5) : (long) (x - 0.5);
-	long _y = y > 0 ? (long) (y + 0.5) : (long) (y - 0.5);
-
-	if (tile) {
-		_x %= pixmap->width;
-		_y %= pixmap->height;
-	}
-
-	return pixelmap_get_pixel(pixmap, (sysarg_t) _x, (sysarg_t) _y);
+	return val > 0 ? (long) (val + 0.5) : (long) (val - 0.5);
 }
 
-pixel_t filter_bilinear(pixelmap_t *pixmap, double x, double y, bool tile)
+static long floor(double val)
 {
-	// TODO
-	return 0;
+	long lval = (long) val;
+	if (val < 0 && lval != val)
+		return lval - 1;
+	return lval;
 }
 
-pixel_t filter_bicubic(pixelmap_t *pixmap, double x, double y, bool tile)
+static long ceil(double val)
+{
+	long lval = (long) val;
+	if (val > 0 && lval != val)
+		return lval + 1;
+	return lval;
+}
+
+
+static inline pixel_t blend_pixels(size_t count, float *weights,
+    pixel_t *pixels)
+{
+	float alpha = 0, red = 0, green = 0, blue = 0;
+	for (size_t index = 0; index < count; index++) {
+		alpha += weights[index] * ALPHA(pixels[index]);
+		red   += weights[index] *   RED(pixels[index]);
+		green += weights[index] * GREEN(pixels[index]);
+		blue  += weights[index] *  BLUE(pixels[index]);
+	}
+	
+	return PIXEL((uint8_t) alpha, (uint8_t) red, (uint8_t) green,
+	    (uint8_t) blue);
+}
+
+pixel_t filter_nearest(pixelmap_t *pixmap, double x, double y,
+    pixelmap_extend_t extend)
+{
+	return pixelmap_get_extended_pixel(pixmap, round(x), round(y), extend);
+}
+
+pixel_t filter_bilinear(pixelmap_t *pixmap, double x, double y,
+    pixelmap_extend_t extend)
+{
+	long x1 = floor(x);
+	long x2 = ceil(x);
+	long y1 = floor(y);
+	long y2 = ceil(y);
+	
+	if (y1 == y2 && x1 == x2) {
+		return pixelmap_get_extended_pixel(pixmap,
+		    (sysarg_t) x1, (sysarg_t) y1, extend);
+	}
+	
+	double x_delta = x - x1;
+	double y_delta = y - y1;
+	
+	pixel_t pixels[4];
+	pixels[0] = pixelmap_get_extended_pixel(pixmap, x1, y1, extend);
+	pixels[1] = pixelmap_get_extended_pixel(pixmap, x2, y1, extend);
+	pixels[2] = pixelmap_get_extended_pixel(pixmap, x1, y2, extend);
+	pixels[3] = pixelmap_get_extended_pixel(pixmap, x2, y2, extend);
+	
+	float weights[4];
+	weights[0] = (1 - x_delta) * (1 - y_delta);
+	weights[1] = (    x_delta) * (1 - y_delta);
+	weights[2] = (1 - x_delta) * (    y_delta);
+	weights[3] = (    x_delta) * (    y_delta);
+	
+	return blend_pixels(4, weights, pixels);
+}
+
+pixel_t filter_bicubic(pixelmap_t *pixmap, double x, double y,
+    pixelmap_extend_t extend)
 {
 	// TODO
Index: uspace/lib/softrend/filter.h
===================================================================
--- uspace/lib/softrend/filter.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/lib/softrend/filter.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,9 +40,9 @@
 #include <io/pixelmap.h>
 
-typedef pixel_t (*filter_t)(pixelmap_t *, double, double, bool);
+typedef pixel_t (*filter_t)(pixelmap_t *, double, double, pixelmap_extend_t);
 
-extern pixel_t filter_nearest(pixelmap_t *, double, double, bool);
-extern pixel_t filter_bilinear(pixelmap_t *, double, double, bool);
-extern pixel_t filter_bicubic(pixelmap_t *, double, double, bool);
+extern pixel_t filter_nearest(pixelmap_t *, double, double, pixelmap_extend_t);
+extern pixel_t filter_bilinear(pixelmap_t *, double, double, pixelmap_extend_t);
+extern pixel_t filter_bicubic(pixelmap_t *, double, double, pixelmap_extend_t);
 
 #endif
Index: uspace/srv/audio/hound/main.c
===================================================================
--- uspace/srv/audio/hound/main.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/audio/hound/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -43,4 +43,5 @@
 #include <hound/server.h>
 #include <hound/protocol.h>
+#include <task.h>
 
 #include "hound.h"
Index: uspace/srv/bd/sata_bd/sata_bd.c
===================================================================
--- uspace/srv/bd/sata_bd/sata_bd.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/bd/sata_bd/sata_bd.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -45,4 +45,5 @@
 #include <loc.h>
 #include <macros.h>
+#include <task.h>
 
 #include <ahci_iface.h>
Index: uspace/srv/devman/driver.c
===================================================================
--- uspace/srv/devman/driver.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/devman/driver.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,4 +40,5 @@
 #include <str_error.h>
 #include <stdio.h>
+#include <task.h>
 
 #include "dev.h"
@@ -290,5 +291,5 @@
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "start_driver(drv=\"%s\")", drv->name);
 	
-	rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL);
+	rc = task_spawnl(NULL, NULL, drv->binary_path, drv->binary_path, NULL);
 	if (rc != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.",
Index: uspace/srv/fs/cdfs/Makefile
===================================================================
--- uspace/srv/fs/cdfs/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/fs/cdfs/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -29,5 +29,6 @@
 USPACE_PREFIX = ../../..
 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a
-EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX)
+EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) \
+    -I$(LIBSCSI_PREFIX)/include
 BINARY = cdfs
 
Index: uspace/srv/fs/cdfs/cdfs_ops.c
===================================================================
--- uspace/srv/fs/cdfs/cdfs_ops.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/fs/cdfs/cdfs_ops.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -48,4 +48,5 @@
 #include <errno.h>
 #include <block.h>
+#include <scsi/mmc.h>
 #include <str.h>
 #include <byteorder.h>
@@ -1035,10 +1036,13 @@
 			altroot = 0;
 	} else {
-		/* Read TOC and find the last session */
-		toc_block_t *toc = block_get_toc(service_id, 1);
-		if ((toc != NULL) && (uint16_t_be2host(toc->size) == 10)) {
-			altroot = uint32_t_be2host(toc->first_lba);
-			free(toc);
-		}
+		/*
+		 * Read TOC multisession information and get the start address
+		 * of the first track in the last session
+		 */
+		scsi_toc_multisess_data_t toc;
+
+		rc = block_read_toc(service_id, 1, &toc, sizeof(toc));
+		if (rc == EOK && (uint16_t_be2host(toc.toc_len) == 10))
+			altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr);
 	}
 	
Index: uspace/srv/hid/compositor/compositor.c
===================================================================
--- uspace/srv/hid/compositor/compositor.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/compositor/compositor.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -56,9 +56,9 @@
 #include <loc.h>
 
-#include <event.h>
 #include <io/keycode.h>
 #include <io/mode.h>
 #include <io/visualizer.h>
 #include <io/window.h>
+#include <io/console.h>
 
 #include <transform.h>
@@ -84,4 +84,6 @@
 static sysarg_t coord_origin;
 static pixel_t bg_color;
+static filter_t filter = filter_bilinear;
+static unsigned int filter_index = 1;
 
 typedef struct {
@@ -144,5 +146,8 @@
 /** Input server proxy */
 static input_t *input;
-
+static bool active = false;
+
+static int comp_active(input_t *);
+static int comp_deactive(input_t *);
 static int comp_key_press(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
 static int comp_mouse_move(input_t *, int, int);
@@ -151,4 +156,6 @@
 
 static input_ev_ops_t input_ev_ops = {
+	.active = comp_active,
+	.deactive = comp_deactive,
 	.key = comp_key_press,
 	.move = comp_mouse_move,
@@ -156,6 +163,4 @@
 	.button = comp_mouse_button
 };
-
-static void input_disconnect(void);
 
 static pointer_t *input_pointer(input_t *input)
@@ -230,5 +235,5 @@
 static void window_destroy(window_t *win)
 {
-	if (win && atomic_get(&win->ref_cnt) == 0) {
+	if ((win) && (atomic_get(&win->ref_cnt) == 0)) {
 		while (!list_empty(&win->queue.list)) {
 			window_event_t *event = (window_event_t *) list_first(&win->queue.list);
@@ -236,8 +241,8 @@
 			free(event);
 		}
-
-		if (win->surface) {
+		
+		if (win->surface)
 			surface_destroy(win->surface);
-		}
+		
 		free(win);
 	}
@@ -251,21 +256,21 @@
 	transform_invert(&win_trans);
 	transform_apply_affine(&win_trans, &x, &y);
-
-	/* Since client coordinate origin is (0, 0), it is necessary to check
+	
+	/*
+	 * Since client coordinate origin is (0, 0), it is necessary to check
 	 * coordinates to avoid underflow. Moreover, it is convenient to also
 	 * check against provided upper limits to determine whether the converted
-	 * coordinates are within the client window.  */
-	if (x < 0 || y < 0) {
+	 * coordinates are within the client window.
+	 */
+	if ((x < 0) || (y < 0))
 		return false;
-	} else {
-		(*x_out) = (sysarg_t) (x + 0.5);
-		(*y_out) = (sysarg_t) (y + 0.5);
-
-		if ((*x_out) >= x_lim || (*y_out) >= y_lim) {
-			return false;
-		} else {
-			return true;
-		}
-	}
+	
+	(*x_out) = (sysarg_t) (x + 0.5);
+	(*y_out) = (sysarg_t) (y + 0.5);
+	
+	if (((*x_out) >= x_lim) || ((*y_out) >= y_lim))
+		return false;
+	
+	return true;
 }
 
@@ -277,6 +282,8 @@
 	transform_apply_affine(&win_trans, &x, &y);
 	
-	/* It is assumed that compositor coordinate origin is chosen in such way,
-	 * that underflow/overflow here would be unlikely. */
+	/*
+	 * It is assumed that compositor coordinate origin is chosen in such way,
+	 * that underflow/overflow here would be unlikely.
+	 */
 	(*x_out) = (sysarg_t) (x + 0.5);
 	(*y_out) = (sysarg_t) (y + 0.5);
@@ -403,5 +410,5 @@
 
 			source_init(&source);
-			source_set_filter(&source, filter_nearest);
+			source_set_filter(&source, filter);
 			drawctx_init(&context, vp->surface);
 			drawctx_set_compose(&context, compose_over);
@@ -436,6 +443,7 @@
 					transform_translate(&transform, -pos.x, -pos.y);
 
-					source_set_transform(&source, transform);				
-					source_set_texture(&source, win->surface, false);
+					source_set_transform(&source, transform);
+					source_set_texture(&source, win->surface,
+					    PIXELMAP_EXTEND_TRANSPARENT_SIDES);
 					source_set_alpha(&source, PIXEL(win->opacity, 0, 0, 0));
 
@@ -565,12 +573,14 @@
 
 	/* Notify visualizers about updated regions. */
-	list_foreach(viewport_list, link, viewport_t, vp) {
-		sysarg_t x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp;
-		surface_get_damaged_region(vp->surface, &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp);
-		surface_reset_damaged_region(vp->surface);
-		visualizer_update_damaged_region(
-		    vp->sess, x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp, 0, 0);
-	}
-
+	if (active) {
+		list_foreach(viewport_list, link, viewport_t, vp) {
+			sysarg_t x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp;
+			surface_get_damaged_region(vp->surface, &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp);
+			surface_reset_damaged_region(vp->surface);
+			visualizer_update_damaged_region(vp->sess,
+			    x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp, 0, 0);
+		}
+	}
+	
 	fibril_mutex_unlock(&viewport_list_mtx);
 }
@@ -588,4 +598,5 @@
 		return;
 	}
+	
 	int rc = async_data_read_finalize(callid, event, len);
 	if (rc != EOK) {
@@ -594,6 +605,6 @@
 		return;
 	}
+	
 	async_answer_0(iid, EOK);
-	
 	free(event);
 }
@@ -606,5 +617,5 @@
 	double height = IPC_GET_ARG4(*icall);
 
-	if (width == 0 || height == 0) {
+	if ((width == 0) || (height == 0)) {
 		comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
 	} else {
@@ -855,5 +866,4 @@
 
 	comp_damage(x, y, width, height);
-
 	async_answer_0(iid, EOK);
 }
@@ -861,5 +871,5 @@
 static void comp_window_close_request(window_t *win, ipc_callid_t iid, ipc_call_t *icall)
 {
-    window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
+	window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
 	if (event == NULL) {
 		async_answer_0(iid, ENOMEM);
@@ -1001,6 +1011,8 @@
 				break;
 			case WINDOW_CLOSE:
-				/* Postpone the closing until the phone is hung up to cover
-				 * the case when the client is killed abruptly. */
+				/*
+				 * Postpone the closing until the phone is hung up to cover
+				 * the case when the client is killed abruptly.
+				 */
 				async_answer_0(callid, EOK);
 				break;
@@ -1017,5 +1029,4 @@
 static void comp_mode_change(viewport_t *vp, ipc_callid_t iid, ipc_call_t *icall)
 {
-	int rc;
 	sysarg_t mode_idx = IPC_GET_ARG2(*icall);
 	fibril_mutex_lock(&viewport_list_mtx);
@@ -1023,5 +1034,5 @@
 	/* Retrieve the mode that shall be set. */
 	vslmode_t new_mode;
-	rc = visualizer_get_mode(vp->sess, &new_mode, mode_idx);
+	int rc = visualizer_get_mode(vp->sess, &new_mode, mode_idx);
 	if (rc != EOK) {
 		fibril_mutex_unlock(&viewport_list_mtx);
@@ -1041,5 +1052,5 @@
 	/* Try to set the mode and share out the surface. */
 	rc = visualizer_set_mode(vp->sess,
-		new_mode.index, new_mode.version, surface_direct_access(new_surface));
+	    new_mode.index, new_mode.version, surface_direct_access(new_surface));
 	if (rc != EOK) {
 		surface_destroy(new_surface);
@@ -1071,39 +1082,42 @@
 }
 
+#if 0
+static void comp_shutdown(void)
+{
+	loc_service_unregister(winreg_id);
+	input_disconnect();
+	
+	/* Close all clients and their windows. */
+	fibril_mutex_lock(&window_list_mtx);
+	list_foreach(window_list, link, window_t, win) {
+		window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
+		if (event) {
+			link_initialize(&event->link);
+			event->type = WINDOW_CLOSE;
+			prodcons_produce(&win->queue, &event->link);
+		}
+	}
+	fibril_mutex_unlock(&window_list_mtx);
+	
+	async_answer_0(iid, EOK);
+	
+	/* All fibrils of the compositor will terminate soon. */
+}
+#endif
+
 static void comp_visualizer_disconnect(viewport_t *vp, ipc_callid_t iid, ipc_call_t *icall)
 {
 	/* Release viewport resources. */
 	fibril_mutex_lock(&viewport_list_mtx);
+	
 	list_remove(&vp->link);
 	viewport_destroy(vp);
-
-	/* Terminate compositor if there are no more viewports. */
-	if (list_empty(&viewport_list)) {
-		fibril_mutex_unlock(&viewport_list_mtx);
-		loc_service_unregister(winreg_id);
-		input_disconnect();
-
-		/* Close all clients and their windows. */
-		fibril_mutex_lock(&window_list_mtx);
-		list_foreach(window_list, link, window_t, win) {
-			window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
-			if (event) {
-				link_initialize(&event->link);
-				event->type = WINDOW_CLOSE;
-				prodcons_produce(&win->queue, &event->link);
-			}
-		}
-		fibril_mutex_unlock(&window_list_mtx);
-
-		async_answer_0(iid, EOK);
-
-		/* All fibrils of the compositor will terminate soon. */
-	} else {
-		fibril_mutex_unlock(&viewport_list_mtx);
-		async_answer_0(iid, EOK);
-
-		comp_restrict_pointers();
-		comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
-	}
+	
+	fibril_mutex_unlock(&viewport_list_mtx);
+	
+	async_answer_0(iid, EOK);
+	
+	comp_restrict_pointers();
+	comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
 }
 
@@ -1120,7 +1134,6 @@
 	fibril_mutex_unlock(&viewport_list_mtx);
 
-	if (!vp) {
+	if (!vp)
 		return;
-	}
 
 	/* Ignore parameters, the connection is already opened. */
@@ -1223,5 +1236,5 @@
 	/* Try to set the mode and share out the surface. */
 	rc = visualizer_set_mode(vp->sess,
-		vp->mode.index, vp->mode.version, surface_direct_access(vp->surface));
+	    vp->mode.index, vp->mode.version, surface_direct_access(vp->surface));
 	if (rc != EOK) {
 		printf("%s: Unable to set mode (%s)\n", NAME, str_error(rc));
@@ -1233,6 +1246,8 @@
 	if (claimed)
 		visualizer_yield(vp->sess);
+	
 	if (vp->sess != NULL)
 		async_hangup(vp->sess);
+	
 	free(vp);
 	free(vsl_name);
@@ -1775,4 +1790,18 @@
 }
 
+static int comp_active(input_t *input)
+{
+	active = true;
+	comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
+	
+	return EOK;
+}
+
+static int comp_deactive(input_t *input)
+{
+	active = false;
+	return EOK;
+}
+
 static int comp_key_press(input_t *input, kbd_event_type_t type, keycode_t key,
     keymod_t mods, wchar_t c)
@@ -1792,10 +1821,11 @@
 	    key == KC_O || key == KC_P);
 	bool kconsole_switch = (mods & KM_ALT) && (key == KC_M);
-
-	bool filter = (type == KEY_RELEASE) && (win_transform || win_resize ||
+	bool filter_switch = (mods & KM_ALT) && (key == KC_Y);
+
+	bool key_filter = (type == KEY_RELEASE) && (win_transform || win_resize ||
 	    win_opacity || win_close || win_switch || viewport_move ||
-	    viewport_change || kconsole_switch);
-
-	if (filter) {
+	    viewport_change || kconsole_switch || filter_switch);
+
+	if (key_filter) {
 		/* no-op */
 	} else if (win_transform) {
@@ -2063,5 +2093,17 @@
 		fibril_mutex_unlock(&viewport_list_mtx);
 	} else if (kconsole_switch) {
-		__SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE);
+		if (console_kcon())
+			active = false;
+	} else if (filter_switch) {
+		filter_index++;
+		if (filter_index > 1)
+			filter_index = 0;
+		if (filter_index == 0) {
+			filter = filter_nearest;
+		}
+		else {
+			filter = filter_bilinear;
+		}
+		comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
 	} else {
 		window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
@@ -2132,28 +2174,21 @@
 }
 
-static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
-{
-	comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
-}
-
-static int discover_viewports(void)
-{
+static void discover_viewports(void)
+{
+	fibril_mutex_lock(&discovery_mtx);
+	
 	/* Create viewports and connect them to visualizers. */
 	category_id_t cat_id;
 	int rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING);
-	if (rc != EOK) {
-		printf("%s: Failed to get visualizer category.\n", NAME);
-		return -1;
-	}
+	if (rc != EOK)
+		goto ret;
 	
 	service_id_t *svcs;
 	size_t svcs_cnt = 0;
 	rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt);
-	if (rc != EOK || svcs_cnt == 0) {
-		printf("%s: Failed to get visualizer category services.\n", NAME);
-		return -1;
-	}
-
-	fibril_mutex_lock(&viewport_list_mtx);	
+	if (rc != EOK)
+		goto ret;
+	
+	fibril_mutex_lock(&viewport_list_mtx);
 	for (size_t i = 0; i < svcs_cnt; ++i) {
 		bool exists = false;
@@ -2174,14 +2209,14 @@
 	fibril_mutex_unlock(&viewport_list_mtx);
 	
-	/* TODO damage only newly added viewports */
-	comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
-	return EOK;
+	if (!list_empty(&viewport_list))
+		input_activate(input);
+	
+ret:
+	fibril_mutex_unlock(&discovery_mtx);
 }
 
 static void category_change_cb(void)
 {
-	fibril_mutex_lock(&discovery_mtx);
 	discover_viewports();
-	fibril_mutex_unlock(&discovery_mtx);
 }
 
@@ -2196,16 +2231,9 @@
 	/* Register compositor server. */
 	async_set_client_connection(client_connection);
+	
 	int rc = loc_server_register(NAME);
 	if (rc != EOK) {
 		printf("%s: Unable to register server (%s)\n", NAME, str_error(rc));
 		return -1;
-	}
-	
-	/* Register interrupt handler to switch back from kconsole. */
-	async_set_interrupt_received(interrupt_received);
-	rc = event_subscribe(EVENT_KCONSOLE, 0);
-	if (rc != EOK) {
-		printf("%s: Failed to register kconsole notifications (%s)\n",
-		    NAME, str_error(rc));
 	}
 	
@@ -2229,5 +2257,5 @@
 		return -1;
 	}
-
+	
 	/* Establish input bidirectional connection. */
 	rc = input_connect(input_svc);
@@ -2236,5 +2264,5 @@
 		return rc;
 	}
-
+	
 	rc = loc_register_cat_change_cb(category_change_cb);
 	if (rc != EOK) {
@@ -2242,21 +2270,10 @@
 		input_disconnect();
 		return rc;
-	}	
-
-	rc = discover_viewports();
-	if (rc != EOK) {
-		input_disconnect();
-		return rc;
-	}
-	
-	if (list_empty(&viewport_list)) {
-		printf("%s: Failed to get viewports.\n", NAME);
-		input_disconnect();
-		return -1;
-	}
-
+	}
+	
+	discover_viewports();
+	
 	comp_restrict_pointers();
 	comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
-	
 	
 	return EOK;
Index: uspace/srv/hid/console/console.c
===================================================================
--- uspace/srv/hid/console/console.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/console/console.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -41,5 +41,4 @@
 #include <str_error.h>
 #include <loc.h>
-#include <event.h>
 #include <io/con_srv.h>
 #include <io/kbd_event.h>
@@ -84,4 +83,5 @@
 /** Input server proxy */
 static input_t *input;
+static bool active = false;
 
 /** Session to the output server */
@@ -98,8 +98,8 @@
 static FIBRIL_MUTEX_INITIALIZE(switch_mtx);
 
-static console_t *prev_console = &consoles[0];
 static console_t *active_console = &consoles[0];
-static console_t *kernel_console = &consoles[KERNEL_CONSOLE];
-
+
+static int input_ev_active(input_t *);
+static int input_ev_deactive(input_t *);
 static int input_ev_key(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
 static int input_ev_move(input_t *, int, int);
@@ -108,4 +108,6 @@
 
 static input_ev_ops_t input_ev_ops = {
+	.active = input_ev_active,
+	.deactive = input_ev_deactive,
 	.key = input_ev_key,
 	.move = input_ev_move,
@@ -159,5 +161,5 @@
 	fibril_mutex_lock(&cons->mtx);
 	
-	if ((cons == active_console) && (active_console != kernel_console)) {
+	if ((active) && (cons == active_console)) {
 		output_update(output_sess, cons->fbid);
 		output_cursor_update(output_sess, cons->fbid);
@@ -173,5 +175,5 @@
 	fibril_mutex_lock(&cons->mtx);
 	
-	if ((cons == active_console) && (active_console != kernel_console))
+	if ((active) && (cons == active_console))
 		output_cursor_update(output_sess, cons->fbid);
 	
@@ -185,5 +187,5 @@
 	fibril_mutex_lock(&cons->mtx);
 	
-	if ((cons == active_console) && (active_console != kernel_console)) {
+	if ((active) && (cons == active_console)) {
 		output_damage(output_sess, cons->fbid, 0, 0, cons->cols,
 		    cons->rows);
@@ -195,6 +197,22 @@
 }
 
-static void cons_switch(console_t *cons)
-{
+static void cons_switch(unsigned int index)
+{
+	/*
+	 * The first undefined index is reserved
+	 * for switching to the kernel console.
+	 */
+	if (index == CONSOLE_COUNT) {
+		if (console_kcon())
+			active = false;
+		
+		return;
+	}
+	
+	if (index > CONSOLE_COUNT)
+		return;
+	
+	console_t *cons = &consoles[index];
+	
 	fibril_mutex_lock(&switch_mtx);
 	
@@ -204,17 +222,4 @@
 	}
 	
-	if (cons == kernel_console) {
-		output_yield(output_sess);
-		if (!console_kcon()) {
-			output_claim(output_sess);
-			fibril_mutex_unlock(&switch_mtx);
-			return;
-		}
-	}
-	
-	if (active_console == kernel_console)
-		output_claim(output_sess);
-	
-	prev_console = active_console;
 	active_console = cons;
 	
@@ -224,17 +229,19 @@
 }
 
-static console_t *cons_get_active_uspace(void)
-{
-	fibril_mutex_lock(&switch_mtx);
-	
-	console_t *active_uspace = active_console;
-	if (active_uspace == kernel_console)
-		active_uspace = prev_console;
-	
-	assert(active_uspace != kernel_console);
-	
-	fibril_mutex_unlock(&switch_mtx);
-	
-	return active_uspace;
+static int input_ev_active(input_t *input)
+{
+	active = true;
+	output_claim(output_sess);
+	cons_damage(active_console);
+	
+	return EOK;
+}
+
+static int input_ev_deactive(input_t *input)
+{
+	active = false;
+	output_yield(output_sess);
+	
+	return EOK;
 }
 
@@ -242,7 +249,7 @@
     keymod_t mods, wchar_t c)
 {
-	if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) &&
+	if ((key >= KC_F1) && (key <= KC_F1 + CONSOLE_COUNT) &&
 	    ((mods & KM_CTRL) == 0)) {
-		cons_switch(&consoles[key - KC_F1]);
+		cons_switch(key - KC_F1);
 	} else {
 		/* Got key press/release event */
@@ -259,13 +266,5 @@
 		event->c = c;
 		
-		/*
-		 * Kernel console does not read events
-		 * from us, so we will redirect them
-		 * to the (last) active userspace console
-		 * if necessary.
-		 */
-		console_t *target_console = cons_get_active_uspace();
-		
-		prodcons_produce(&target_console->input_pc,
+		prodcons_produce(&active_console->input_pc,
 		    &event->link);
 	}
@@ -377,5 +376,5 @@
 		}
 	}
-
+	
 	return size;
 }
@@ -388,4 +387,5 @@
 	while (off < size)
 		cons_write_char(cons, str_decode(data, &off, size));
+	
 	return size;
 }
@@ -498,4 +498,5 @@
 	event->type = CEV_KEY;
 	event->ev.key = *kevent;
+	
 	free(kevent);
 	return EOK;
@@ -507,7 +508,4 @@
 	
 	for (size_t i = 0; i < CONSOLE_COUNT; i++) {
-		if (i == KERNEL_CONSOLE)
-			continue;
-		
 		if (consoles[i].dsid == (service_id_t) IPC_GET_ARG1(*icall)) {
 			cons = &consoles[i];
@@ -526,5 +524,4 @@
 	con_conn(iid, icall, &cons->srvs);
 }
-
 
 static int input_connect(const char *svc)
@@ -555,9 +552,4 @@
 	
 	return EOK;
-}
-
-static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
-{
-	cons_switch(prev_console);
 }
 
@@ -583,8 +575,6 @@
 static bool console_srv_init(char *input_svc, char *output_svc)
 {
-	int rc;
-	
 	/* Connect to input service */
-	rc = input_connect(input_svc);
+	int rc = input_connect(input_svc);
 	if (rc != EOK)
 		return false;
@@ -610,54 +600,49 @@
 	output_get_caps(output_sess, &ccaps);
 	
-	/* Inititalize consoles */
-	for (size_t i = 0; i < CONSOLE_COUNT; i++) {
-		consoles[i].index = i;
-		atomic_set(&consoles[i].refcnt, 0);
-		fibril_mutex_initialize(&consoles[i].mtx);
-		prodcons_initialize(&consoles[i].input_pc);
-		consoles[i].char_remains_len = 0;
-		
-		if (i == KERNEL_CONSOLE)
-			continue;
-		
-		consoles[i].cols = cols;
-		consoles[i].rows = rows;
-		consoles[i].ccaps = ccaps;
-		consoles[i].frontbuf =
-		    chargrid_create(cols, rows, CHARGRID_FLAG_SHARED);
-		
-		if (consoles[i].frontbuf == NULL) {
-			printf("%s: Unable to allocate frontbuffer %zu\n", NAME, i);
-			return false;
+	/*
+	 * Inititalize consoles only if there are
+	 * actually some output devices.
+	 */
+	if (ccaps != 0) {
+		for (size_t i = 0; i < CONSOLE_COUNT; i++) {
+			consoles[i].index = i;
+			atomic_set(&consoles[i].refcnt, 0);
+			fibril_mutex_initialize(&consoles[i].mtx);
+			prodcons_initialize(&consoles[i].input_pc);
+			consoles[i].char_remains_len = 0;
+			
+			consoles[i].cols = cols;
+			consoles[i].rows = rows;
+			consoles[i].ccaps = ccaps;
+			consoles[i].frontbuf =
+			    chargrid_create(cols, rows, CHARGRID_FLAG_SHARED);
+			
+			if (consoles[i].frontbuf == NULL) {
+				printf("%s: Unable to allocate frontbuffer %zu\n", NAME, i);
+				return false;
+			}
+			
+			consoles[i].fbid = output_frontbuf_create(output_sess,
+			    consoles[i].frontbuf);
+			if (consoles[i].fbid == 0) {
+				printf("%s: Unable to create frontbuffer %zu\n", NAME, i);
+				return false;
+			}
+			
+			con_srvs_init(&consoles[i].srvs);
+			consoles[i].srvs.ops = &con_ops;
+			consoles[i].srvs.sarg = &consoles[i];
+			
+			char vc[LOC_NAME_MAXLEN + 1];
+			snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
+			
+			if (loc_service_register(vc, &consoles[i].dsid) != EOK) {
+				printf("%s: Unable to register device %s\n", NAME, vc);
+				return false;
+			}
 		}
 		
-		consoles[i].fbid = output_frontbuf_create(output_sess,
-		    consoles[i].frontbuf);
-		if (consoles[i].fbid == 0) {
-			printf("%s: Unable to create frontbuffer %zu\n", NAME, i);
-			return false;
-		}
-		
-		con_srvs_init(&consoles[i].srvs);
-		consoles[i].srvs.ops = &con_ops;
-		consoles[i].srvs.sarg = &consoles[i];
-		
-		char vc[LOC_NAME_MAXLEN + 1];
-		snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
-		
-		if (loc_service_register(vc, &consoles[i].dsid) != EOK) {
-			printf("%s: Unable to register device %s\n", NAME, vc);
-			return false;
-		}
-	}
-	
-	cons_damage(active_console);
-	
-	/* Receive kernel notifications */
-	async_set_interrupt_received(interrupt_received);
-	rc = event_subscribe(EVENT_KCONSOLE, 0);
-	if (rc != EOK)
-		printf("%s: Failed to register kconsole notifications (%s)\n",
-		    NAME, str_error(rc));
+		input_activate(input);
+	}
 	
 	return true;
Index: uspace/srv/hid/console/console.h
===================================================================
--- uspace/srv/hid/console/console.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/console/console.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,6 +36,5 @@
 #define CONSOLE_CONSOLE_H__
 
-#define CONSOLE_COUNT   12
-#define KERNEL_CONSOLE  11
+#define CONSOLE_COUNT   11
 
 #endif
Index: uspace/srv/hid/input/Makefile
===================================================================
--- uspace/srv/hid/input/Makefile	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -42,5 +42,4 @@
 	port/niagara.c \
 	port/ns16550.c \
-	port/pl050.c \
 	port/ski.c \
 	proto/adb.c \
@@ -48,5 +47,4 @@
 	ctl/apple.c \
 	ctl/kbdev.c \
-	ctl/pc.c \
 	ctl/stty.c \
 	ctl/sun.c \
Index: pace/srv/hid/input/ctl/pc.c
===================================================================
--- uspace/srv/hid/input/ctl/pc.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,285 +1,0 @@
-/*
- * Copyright (c) 2011 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 kbd_ctl
- * @ingroup input
- * @{
- */
-/**
- * @file
- * @brief PC keyboard controller driver.
- */
-
-#include <io/console.h>
-#include <io/keycode.h>
-#include "../gsp.h"
-#include "../kbd.h"
-#include "../kbd_port.h"
-#include "../kbd_ctl.h"
-
-static void pc_ctl_parse(sysarg_t);
-static int pc_ctl_init(kbd_dev_t *);
-static void pc_ctl_set_ind(kbd_dev_t *, unsigned int);
-
-kbd_ctl_ops_t pc_ctl = {
-	.parse = pc_ctl_parse,
-	.init = pc_ctl_init,
-	.set_ind = pc_ctl_set_ind
-};
-
-enum dec_state {
-	ds_s,
-	ds_e
-};
-
-enum special_code {
-	SC_ACK = 0xfa,
-	SC_NAK = 0xfe
-};
-
-enum lock_ind_bits {
-	LI_SCROLL	= 0x01,
-	LI_NUM		= 0x02,
-	LI_CAPS		= 0x04
-};
-
-enum kbd_command {
-	KBD_CMD_SET_LEDS = 0xed
-};
-
-static enum dec_state ds;
-static kbd_dev_t *kbd_dev;
-
-static int scanmap_simple[] = {
-
-	[0x29] = KC_BACKTICK,
-
-	[0x02] = KC_1,
-	[0x03] = KC_2,
-	[0x04] = KC_3,
-	[0x05] = KC_4,
-	[0x06] = KC_5,
-	[0x07] = KC_6,
-	[0x08] = KC_7,
-	[0x09] = KC_8,
-	[0x0a] = KC_9,
-	[0x0b] = KC_0,
-
-	[0x0c] = KC_MINUS,
-	[0x0d] = KC_EQUALS,
-	[0x0e] = KC_BACKSPACE,
-
-	[0x0f] = KC_TAB,
-
-	[0x10] = KC_Q,
-	[0x11] = KC_W,
-	[0x12] = KC_E,
-	[0x13] = KC_R,
-	[0x14] = KC_T,
-	[0x15] = KC_Y,
-	[0x16] = KC_U,
-	[0x17] = KC_I,
-	[0x18] = KC_O,
-	[0x19] = KC_P,
-
-	[0x1a] = KC_LBRACKET,
-	[0x1b] = KC_RBRACKET,
-
-	[0x3a] = KC_CAPS_LOCK,
-
-	[0x1e] = KC_A,
-	[0x1f] = KC_S,
-	[0x20] = KC_D,
-	[0x21] = KC_F,
-	[0x22] = KC_G,
-	[0x23] = KC_H,
-	[0x24] = KC_J,
-	[0x25] = KC_K,
-	[0x26] = KC_L,
-
-	[0x27] = KC_SEMICOLON,
-	[0x28] = KC_QUOTE,
-	[0x2b] = KC_BACKSLASH,
-
-	[0x2a] = KC_LSHIFT,
-
-	[0x2c] = KC_Z,
-	[0x2d] = KC_X,
-	[0x2e] = KC_C,
-	[0x2f] = KC_V,
-	[0x30] = KC_B,
-	[0x31] = KC_N,
-	[0x32] = KC_M,
-
-	[0x33] = KC_COMMA,
-	[0x34] = KC_PERIOD,
-	[0x35] = KC_SLASH,
-
-	[0x36] = KC_RSHIFT,
-
-	[0x1d] = KC_LCTRL,
-	[0x38] = KC_LALT,
-	[0x39] = KC_SPACE,
-
-	[0x01] = KC_ESCAPE,
-
-	[0x3b] = KC_F1,
-	[0x3c] = KC_F2,
-	[0x3d] = KC_F3,
-	[0x3e] = KC_F4,
-	[0x3f] = KC_F5,
-	[0x40] = KC_F6,
-	[0x41] = KC_F7,
-
-	[0x42] = KC_F8,
-	[0x43] = KC_F9,
-	[0x44] = KC_F10,
-
-	[0x57] = KC_F11,
-	[0x58] = KC_F12,
-
-	[0x46] = KC_SCROLL_LOCK,
-
-	[0x1c] = KC_ENTER,
-
-	[0x45] = KC_NUM_LOCK,
-	[0x37] = KC_NTIMES,
-	[0x4a] = KC_NMINUS,
-	[0x4e] = KC_NPLUS,
-	[0x47] = KC_N7,
-	[0x48] = KC_N8,
-	[0x49] = KC_N9,
-	[0x4b] = KC_N4,
-	[0x4c] = KC_N5,
-	[0x4d] = KC_N6,
-	[0x4f] = KC_N1,
-	[0x50] = KC_N2,
-	[0x51] = KC_N3,
-	[0x52] = KC_N0,
-	[0x53] = KC_NPERIOD
-};
-
-static int scanmap_e0[] = {
-	[0x38] = KC_RALT,
-	[0x1d] = KC_RSHIFT,
-
-	[0x37] = KC_PRTSCR,
-
-	[0x52] = KC_INSERT,
-	[0x47] = KC_HOME,
-	[0x49] = KC_PAGE_UP,
-
-	[0x53] = KC_DELETE,
-	[0x4f] = KC_END,
-	[0x51] = KC_PAGE_DOWN,
-
-	[0x48] = KC_UP,
-	[0x4b] = KC_LEFT,
-	[0x50] = KC_DOWN,
-	[0x4d] = KC_RIGHT,
-
-	[0x35] = KC_NSLASH,
-	[0x1c] = KC_NENTER
-};
-
-static int pc_ctl_init(kbd_dev_t *kdev)
-{
-	kbd_dev = kdev;
-	ds = ds_s;
-	return 0;
-}
-
-static void pc_ctl_parse(sysarg_t scancode)
-{
-	kbd_event_type_t type;
-	unsigned int key;
-	int *map;
-	size_t map_length;
-
-	/*
-	 * ACK/NAK are returned as response to us sending a command.
-	 * We are not interested in them.
-	 */
-	if (scancode == SC_ACK || scancode == SC_NAK)
-		return;
-
-	if (scancode == 0xe0) {
-		ds = ds_e;
-		return;
-	}
-
-	switch (ds) {
-	case ds_s:
-		map = scanmap_simple;
-		map_length = sizeof(scanmap_simple) / sizeof(int);
-		break;
-	case ds_e:
-		map = scanmap_e0;
-		map_length = sizeof(scanmap_e0) / sizeof(int);
-		break;
-	default:
-		map = NULL;
-		map_length = 0;
-	}
-
-	ds = ds_s;
-
-	if (scancode & 0x80) {
-		scancode &= ~0x80;
-		type = KEY_RELEASE;
-	} else {
-		type = KEY_PRESS;
-	}
-
-	if ((size_t) scancode >= map_length)
-		return;
-
-	key = map[scancode];
-	if (key != 0)
-		kbd_push_event(kbd_dev, type, key);
-}
-
-static void pc_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
-{
-	uint8_t b;
-
-	b = 0;
-	if ((mods & KM_CAPS_LOCK) != 0)
-		b = b | LI_CAPS;
-	if ((mods & KM_NUM_LOCK) != 0)
-		b = b | LI_NUM;
-	if ((mods & KM_SCROLL_LOCK) != 0)
-		b = b | LI_SCROLL;
-
-	(*kbd_dev->port_ops->write)(KBD_CMD_SET_LEDS);
-	(*kbd_dev->port_ops->write)(b);
-}
-
-/**
- * @}
- */ 
Index: uspace/srv/hid/input/input.c
===================================================================
--- uspace/srv/hid/input/input.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/input.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -54,4 +54,5 @@
 #include <io/keycode.h>
 #include <loc.h>
+#include <str_error.h>
 #include "layout.h"
 #include "kbd.h"
@@ -62,4 +63,7 @@
 #include "input.h"
 
+bool irc_service = false;
+async_sess_t *irc_sess = NULL;
+
 #define NUM_LAYOUTS  4
 
@@ -71,8 +75,18 @@
 };
 
-static void kbd_devs_yield(void);
-static void kbd_devs_reclaim(void);
-
-async_sess_t *client_sess = NULL;
+typedef struct {
+	/** Link into the list of clients */
+	link_t link;
+	
+	/** Indicate whether the client is active */
+	bool active;
+	
+	/** Client callback session */
+	async_sess_t *sess;
+} client_t;
+
+/** List of clients */
+static list_t clients;
+static client_t *active_client = NULL;
 
 /** List of keyboard devices */
@@ -82,8 +96,28 @@
 static list_t mouse_devs;
 
-bool irc_service = false;
-async_sess_t *irc_sess = NULL;
-
 static FIBRIL_MUTEX_INITIALIZE(discovery_lock);
+
+static void *client_data_create(void)
+{
+	client_t *client = (client_t *) calloc(1, sizeof(client_t));
+	if (client == NULL)
+		return NULL;
+	
+	link_initialize(&client->link);
+	client->active = false;
+	client->sess = NULL;
+	
+	list_append(&client->link, &clients);
+	
+	return client;
+}
+
+static void client_data_destroy(void *data)
+{
+	client_t *client = (client_t *) data;
+	
+	list_remove(&client->link);
+	free(client);
+}
 
 void kbd_push_data(kbd_dev_t *kdev, sysarg_t data)
@@ -103,11 +137,24 @@
 	
 	switch (key) {
-	case KC_LCTRL: mod_mask = KM_LCTRL; break;
-	case KC_RCTRL: mod_mask = KM_RCTRL; break;
-	case KC_LSHIFT: mod_mask = KM_LSHIFT; break;
-	case KC_RSHIFT: mod_mask = KM_RSHIFT; break;
-	case KC_LALT: mod_mask = KM_LALT; break;
-	case KC_RALT: mod_mask = KM_RALT; break;
-	default: mod_mask = 0; break;
+	case KC_LCTRL:
+		mod_mask = KM_LCTRL;
+		break;
+	case KC_RCTRL:
+		mod_mask = KM_RCTRL;
+		break;
+	case KC_LSHIFT:
+		mod_mask = KM_LSHIFT;
+		break;
+	case KC_RSHIFT:
+		mod_mask = KM_RSHIFT;
+		break;
+	case KC_LALT:
+		mod_mask = KM_LALT;
+		break;
+	case KC_RALT:
+		mod_mask = KM_RALT;
+		break;
+	default:
+		mod_mask = 0;
 	}
 	
@@ -120,8 +167,15 @@
 	
 	switch (key) {
-	case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break;
-	case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break;
-	case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break;
-	default: mod_mask = 0; break;
+	case KC_CAPS_LOCK:
+		mod_mask = KM_CAPS_LOCK;
+		break;
+	case KC_NUM_LOCK:
+		mod_mask = KM_NUM_LOCK;
+		break;
+	case KC_SCROLL_LOCK:
+		mod_mask = KM_SCROLL_LOCK;
+		break;
+	default:
+		mod_mask = 0;
 	}
 	
@@ -143,6 +197,8 @@
 	}
 	
-	if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) &&
-	    key == KC_F1) {
+	// TODO: More elegant layout switching
+	
+	if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
+	    (key == KC_F1)) {
 		layout_destroy(kdev->active_layout);
 		kdev->active_layout = layout_create(layout[0]);
@@ -150,6 +206,6 @@
 	}
 	
-	if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) &&
-	    key == KC_F2) {
+	if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
+	    (key == KC_F2)) {
 		layout_destroy(kdev->active_layout);
 		kdev->active_layout = layout_create(layout[1]);
@@ -157,6 +213,6 @@
 	}
 	
-	if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) &&
-	    key == KC_F3) {
+	if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
+	    (key == KC_F3)) {
 		layout_destroy(kdev->active_layout);
 		kdev->active_layout = layout_create(layout[2]);
@@ -164,6 +220,6 @@
 	}
 	
-	if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) &&
-	    key == KC_F4) {
+	if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
+	    (key == KC_F4)) {
 		layout_destroy(kdev->active_layout);
 		kdev->active_layout = layout_create(layout[3]);
@@ -177,34 +233,50 @@
 	ev.c = layout_parse_ev(kdev->active_layout, &ev);
 	
-	async_exch_t *exch = async_exchange_begin(client_sess);
-	async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c);
-	async_exchange_end(exch);
-}
-
-/** Mouse pointer has moved. */
+	list_foreach(clients, link, client_t, client) {
+		if (client->active) {
+			async_exch_t *exch = async_exchange_begin(client->sess);
+			async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c);
+			async_exchange_end(exch);
+		}
+	}
+}
+
+/** Mouse pointer has moved (relative mode). */
 void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy, int dz)
 {
-	async_exch_t *exch = async_exchange_begin(client_sess);
-	if (dx || dy)
-		async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
-	if (dz) {
-		// TODO: Implement proper wheel support
-		keycode_t code = dz > 0 ? KC_UP : KC_DOWN;
-		for (int i = 0; i < 3; ++i) {
-			async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0);
-		}
-		async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0);
-	}
-	async_exchange_end(exch);
-}
-
-/** Mouse pointer has moved in absolute mode. */
+	list_foreach(clients, link, client_t, client) {
+		if (client->active) {
+			async_exch_t *exch = async_exchange_begin(client->sess);
+			
+			if ((dx) || (dy))
+				async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
+			
+			if (dz) {
+				// TODO: Implement proper wheel support
+				keycode_t code = dz > 0 ? KC_UP : KC_DOWN;
+				
+				for (unsigned int i = 0; i < 3; i++)
+					async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0);
+				
+				async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0);
+			}
+			
+			async_exchange_end(exch);
+		}
+	}
+}
+
+/** Mouse pointer has moved (absolute mode). */
 void mouse_push_event_abs_move(mouse_dev_t *mdev, unsigned int x, unsigned int y,
     unsigned int max_x, unsigned int max_y)
 {
-	if (max_x && max_y) {
-		async_exch_t *exch = async_exchange_begin(client_sess);
-		async_msg_4(exch, INPUT_EVENT_ABS_MOVE, x, y, max_x, max_y);
-		async_exchange_end(exch);
+	list_foreach(clients, link, client_t, client) {
+		if (client->active) {
+			if ((max_x) && (max_y)) {
+				async_exch_t *exch = async_exchange_begin(client->sess);
+				async_msg_4(exch, INPUT_EVENT_ABS_MOVE, x, y, max_x, max_y);
+				async_exchange_end(exch);
+			}
+		}
 	}
 }
@@ -213,11 +285,38 @@
 void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press)
 {
-	async_exch_t *exch = async_exchange_begin(client_sess);
-	async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press);
-	async_exchange_end(exch);
-}
-
+	list_foreach(clients, link, client_t, client) {
+		if (client->active) {
+			async_exch_t *exch = async_exchange_begin(client->sess);
+			async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press);
+			async_exchange_end(exch);
+		}
+	}
+}
+
+/** Arbitrate client actiovation */
+static void client_arbitration(client_t *req)
+{
+	/* Mutual exclusion of active clients */
+	list_foreach(clients, link, client_t, client)
+		client->active = (client == req);
+	
+	/* Notify clients about the arbitration */
+	list_foreach(clients, link, client_t, client) {
+		async_exch_t *exch = async_exchange_begin(client->sess);
+		async_msg_0(exch, client->active ?
+		    INPUT_EVENT_ACTIVE : INPUT_EVENT_DEACTIVE);
+		async_exchange_end(exch);
+	}
+}
+
+/** New client connection */
 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
+	client_t *client = (client_t *) async_get_client_data();
+	if (client == NULL) {
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
 	async_answer_0(iid, EOK);
 	
@@ -227,7 +326,7 @@
 		
 		if (!IPC_GET_IMETHOD(call)) {
-			if (client_sess != NULL) {
-				async_hangup(client_sess);
-				client_sess = NULL;
+			if (client->sess != NULL) {
+				async_hangup(client->sess);
+				client->sess = NULL;
 			}
 			
@@ -239,6 +338,6 @@
 		    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
 		if (sess != NULL) {
-			if (client_sess == NULL) {
-				client_sess = sess;
+			if (client->sess == NULL) {
+				client->sess = sess;
 				async_answer_0(callid, EOK);
 			} else
@@ -246,10 +345,7 @@
 		} else {
 			switch (IPC_GET_IMETHOD(call)) {
-			case INPUT_YIELD:
-				kbd_devs_yield();
-				async_answer_0(callid, EOK);
-				break;
-			case INPUT_RECLAIM:
-				kbd_devs_reclaim();
+			case INPUT_ACTIVATE:
+				active_client = client;
+				client_arbitration(client);
 				async_answer_0(callid, EOK);
 				break;
@@ -261,4 +357,16 @@
 }
 
+static void kconsole_event_handler(ipc_callid_t callid, ipc_call_t *call,
+    void *arg)
+{
+	if (IPC_GET_ARG1(*call)) {
+		/* Kernel console activated */
+		client_arbitration(NULL);
+	} else {
+		/* Kernel console deactivated */
+		client_arbitration(active_client);
+	}
+}
+
 static kbd_dev_t *kbd_dev_new(void)
 {
@@ -270,5 +378,5 @@
 	}
 	
-	link_initialize(&kdev->kbd_devs);
+	link_initialize(&kdev->link);
 	
 	kdev->mods = KM_NUM_LOCK;
@@ -288,5 +396,5 @@
 	}
 	
-	link_initialize(&mdev->mouse_devs);
+	link_initialize(&mdev->link);
 	
 	return mdev;
@@ -314,5 +422,5 @@
 	}
 	
-	list_append(&kdev->kbd_devs, &kbd_devs);
+	list_append(&kdev->link, &kbd_devs);
 	return;
 	
@@ -342,5 +450,5 @@
 	}
 	
-	list_append(&mdev->mouse_devs, &mouse_devs);
+	list_append(&mdev->link, &mouse_devs);
 	return;
 	
@@ -351,5 +459,5 @@
 /** Add new kbdev device.
  *
- * @param service_id	Service ID of the keyboard device
+ * @param service_id Service ID of the keyboard device
  *
  */
@@ -375,5 +483,5 @@
 	}
 	
-	list_append(&kdev->kbd_devs, &kbd_devs);
+	list_append(&kdev->link, &kbd_devs);
 	*kdevp = kdev;
 	return EOK;
@@ -388,5 +496,5 @@
 /** Add new mousedev device.
  *
- * @param service_id	Service ID of the mouse device
+ * @param service_id Service ID of the mouse device
  *
  */
@@ -412,5 +520,5 @@
 	}
 	
-	list_append(&mdev->mouse_devs, &mouse_devs);
+	list_append(&mdev->link, &mouse_devs);
 	*mdevp = mdev;
 	return EOK;
@@ -430,7 +538,4 @@
 #if defined(UARCH_arm32) && defined(MACHINE_gta02)
 	kbd_add_dev(&chardev_port, &stty_ctl);
-#endif
-#if defined(UARCH_arm32) && defined(MACHINE_integratorcp)
-	kbd_add_dev(&pl050_port, &pc_ctl);
 #endif
 #if defined(MACHINE_ski)
@@ -467,24 +572,4 @@
 }
 
-static void kbd_devs_yield(void)
-{
-	/* For each keyboard device */
-	list_foreach(kbd_devs, kbd_devs, kbd_dev_t, kdev) {
-		/* Yield port */
-		if (kdev->port_ops != NULL)
-			(*kdev->port_ops->yield)();
-	}
-}
-
-static void kbd_devs_reclaim(void)
-{
-	/* For each keyboard device */
-	list_foreach(kbd_devs, kbd_devs, kbd_dev_t, kdev) {
-		/* Reclaim port */
-		if (kdev->port_ops != NULL)
-			(*kdev->port_ops->reclaim)();
-	}
-}
-
 static int dev_check_new_kbdevs(void)
 {
@@ -515,5 +600,5 @@
 		
 		/* Determine whether we already know this device. */
-		list_foreach(kbd_devs, kbd_devs, kbd_dev_t, kdev) {
+		list_foreach(kbd_devs, link, kbd_dev_t, kdev) {
 			if (kdev->svc_id == svcs[i]) {
 				already_known = true;
@@ -566,5 +651,5 @@
 		
 		/* Determine whether we already know this device. */
-		list_foreach(mouse_devs, mouse_devs, mouse_dev_t, mdev) {
+		list_foreach(mouse_devs, link, mouse_dev_t, mdev) {
 			if (mdev->svc_id == svcs[i]) {
 				already_known = true;
@@ -620,7 +705,5 @@
 static int input_start_dev_discovery(void)
 {
-	int rc;
-
-	rc = loc_register_cat_change_cb(cat_change_cb);
+	int rc = loc_register_cat_change_cb(cat_change_cb);
 	if (rc != EOK) {
 		printf("%s: Failed registering callback for device discovery. "
@@ -628,5 +711,5 @@
 		return rc;
 	}
-
+	
 	return dev_check_new();
 }
@@ -648,4 +731,5 @@
 	sysarg_t obio;
 	
+	list_initialize(&clients);
 	list_initialize(&kbd_devs);
 	list_initialize(&mouse_devs);
@@ -667,5 +751,8 @@
 	
 	/* Register driver */
+	async_set_client_data_constructor(client_data_create);
+	async_set_client_data_destructor(client_data_destroy);
 	async_set_client_connection(client_connection);
+	
 	int rc = loc_server_register(NAME);
 	if (rc != EOK) {
@@ -680,4 +767,10 @@
 		return rc;
 	}
+	
+	/* Receive kernel notifications */
+	rc = async_event_subscribe(EVENT_KCONSOLE, kconsole_event_handler, NULL);
+	if (rc != EOK)
+		printf("%s: Failed to register kconsole notifications (%s)\n",
+		    NAME, str_error(rc));
 	
 	/* Start looking for new input devices */
Index: uspace/srv/hid/input/kbd.h
===================================================================
--- uspace/srv/hid/input/kbd.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/kbd.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -48,5 +48,5 @@
 typedef struct kbd_dev {
 	/** Link to kbd_devs list */
-	link_t kbd_devs;
+	link_t link;
 
 	/** Service ID (only for kbdev devices) */
Index: uspace/srv/hid/input/kbd_ctl.h
===================================================================
--- uspace/srv/hid/input/kbd_ctl.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/kbd_ctl.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -50,5 +50,4 @@
 extern kbd_ctl_ops_t apple_ctl;
 extern kbd_ctl_ops_t kbdev_ctl;
-extern kbd_ctl_ops_t pc_ctl;
 extern kbd_ctl_ops_t stty_ctl;
 extern kbd_ctl_ops_t sun_ctl;
Index: uspace/srv/hid/input/kbd_port.h
===================================================================
--- uspace/srv/hid/input/kbd_port.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/kbd_port.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,6 +44,4 @@
 typedef struct kbd_port_ops {
 	int (*init)(struct kbd_dev *);
-	void (*yield)(void);
-	void (*reclaim)(void);
 	void (*write)(uint8_t);
 } kbd_port_ops_t;
@@ -54,5 +52,4 @@
 extern kbd_port_ops_t niagara_port;
 extern kbd_port_ops_t ns16550_port;
-extern kbd_port_ops_t pl050_port;
 extern kbd_port_ops_t ski_port;
 
Index: uspace/srv/hid/input/mouse.h
===================================================================
--- uspace/srv/hid/input/mouse.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/mouse.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -46,5 +46,5 @@
 typedef struct mouse_dev {
 	/** Link to mouse_devs list */
-	link_t mouse_devs;
+	link_t link;
 	
 	/** Service ID (only for mousedev devices) */
Index: uspace/srv/hid/input/mouse_port.h
===================================================================
--- uspace/srv/hid/input/mouse_port.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/mouse_port.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,6 +44,4 @@
 typedef struct mouse_port_ops {
 	int (*init)(struct mouse_dev *);
-	void (*yield)(void);
-	void (*reclaim)(void);
 	void (*write)(uint8_t);
 } mouse_port_ops_t;
Index: uspace/srv/hid/input/port/adb.c
===================================================================
--- uspace/srv/hid/input/port/adb.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/port/adb.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -49,12 +49,8 @@
 
 static int adb_port_init(kbd_dev_t *);
-static void adb_port_yield(void);
-static void adb_port_reclaim(void);
-static void adb_port_write(uint8_t data);
+static void adb_port_write(uint8_t);
 
 kbd_port_ops_t adb_port = {
 	.init = adb_port_init,
-	.yield = adb_port_yield,
-	.reclaim = adb_port_reclaim,
 	.write = adb_port_write
 };
@@ -95,12 +91,4 @@
 	
 	return EOK;
-}
-
-static void adb_port_yield(void)
-{
-}
-
-static void adb_port_reclaim(void)
-{
 }
 
Index: uspace/srv/hid/input/port/adb_mouse.c
===================================================================
--- uspace/srv/hid/input/port/adb_mouse.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/port/adb_mouse.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -109,12 +109,4 @@
 }
 
-static void adb_port_yield(void)
-{
-}
-
-static void adb_port_reclaim(void)
-{
-}
-
 static void adb_port_write(uint8_t data)
 {
@@ -123,6 +115,4 @@
 mouse_port_ops_t adb_mouse_port = {
 	.init = adb_port_init,
-	.yield = adb_port_yield,
-	.reclaim = adb_port_reclaim,
 	.write = adb_port_write
 };
Index: uspace/srv/hid/input/port/chardev.c
===================================================================
--- uspace/srv/hid/input/port/chardev.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/port/chardev.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -47,12 +47,8 @@
 
 static int chardev_port_init(kbd_dev_t *);
-static void chardev_port_yield(void);
-static void chardev_port_reclaim(void);
 static void chardev_port_write(uint8_t data);
 
 kbd_port_ops_t chardev_port = {
 	.init = chardev_port_init,
-	.yield = chardev_port_yield,
-	.reclaim = chardev_port_reclaim,
 	.write = chardev_port_write
 };
@@ -115,12 +111,4 @@
 }
 
-static void chardev_port_yield(void)
-{
-}
-
-static void chardev_port_reclaim(void)
-{
-}
-
 static void chardev_port_write(uint8_t data)
 {
Index: uspace/srv/hid/input/port/msim.c
===================================================================
--- uspace/srv/hid/input/port/msim.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/port/msim.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,12 +44,8 @@
 
 static int msim_port_init(kbd_dev_t *);
-static void msim_port_yield(void);
-static void msim_port_reclaim(void);
 static void msim_port_write(uint8_t data);
 
 kbd_port_ops_t msim_port = {
 	.init = msim_port_init,
-	.yield = msim_port_yield,
-	.reclaim = msim_port_reclaim,
 	.write = msim_port_write
 };
@@ -82,5 +78,8 @@
 };
 
-static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call);
+static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call, void *arg)
+{
+	kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
+}
 
 static int msim_port_init(kbd_dev_t *kdev)
@@ -98,16 +97,8 @@
 	msim_ranges[0].base = paddr;
 	msim_cmds[0].addr = (void *) paddr;
-	async_set_interrupt_received(msim_irq_handler);
-	irq_register(inr, device_assign_devno(), 0, &msim_kbd);
+	async_irq_subscribe(inr, device_assign_devno(), msim_irq_handler, NULL,
+	    &msim_kbd);
 	
 	return 0;
-}
-
-static void msim_port_yield(void)
-{
-}
-
-static void msim_port_reclaim(void)
-{
 }
 
@@ -117,9 +108,4 @@
 }
 
-static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call)
-{
-	kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
-}
-
 /** @}
  */
Index: uspace/srv/hid/input/port/niagara.c
===================================================================
--- uspace/srv/hid/input/port/niagara.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/port/niagara.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -48,12 +48,8 @@
 
 static int niagara_port_init(kbd_dev_t *);
-static void niagara_port_yield(void);
-static void niagara_port_reclaim(void);
 static void niagara_port_write(uint8_t data);
 
 kbd_port_ops_t niagara_port = {
 	.init = niagara_port_init,
-	.yield = niagara_port_yield,
-	.reclaim = niagara_port_reclaim,
 	.write = niagara_port_write
 };
@@ -79,5 +75,4 @@
 static input_buffer_t input_buffer = (input_buffer_t) AS_AREA_ANY;
 
-static volatile bool polling_disabled = false;
 static void niagara_thread_impl(void *arg);
 
@@ -110,14 +105,4 @@
 }
 
-static void niagara_port_yield(void)
-{
-	polling_disabled = true;
-}
-
-static void niagara_port_reclaim(void)
-{
-	polling_disabled = false;
-}
-
 static void niagara_port_write(uint8_t data)
 {
@@ -127,5 +112,5 @@
 /**
  * Called regularly by the polling thread. Reads codes of all the
- * pressed keys from the buffer. 
+ * pressed keys from the buffer.
  */
 static void niagara_key_pressed(void)
@@ -149,6 +134,5 @@
 
 	while (1) {
-		if (polling_disabled == false)
-			niagara_key_pressed();
+		niagara_key_pressed();
 		usleep(POLL_INTERVAL);
 	}
Index: uspace/srv/hid/input/port/ns16550.c
===================================================================
--- uspace/srv/hid/input/port/ns16550.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/port/ns16550.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -46,12 +46,8 @@
 
 static int ns16550_port_init(kbd_dev_t *);
-static void ns16550_port_yield(void);
-static void ns16550_port_reclaim(void);
 static void ns16550_port_write(uint8_t data);
 
 kbd_port_ops_t ns16550_port = {
 	.init = ns16550_port_init,
-	.yield = ns16550_port_yield,
-	.reclaim = ns16550_port_reclaim,
 	.write = ns16550_port_write
 };
@@ -111,14 +107,21 @@
 };
 
-static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call);
+static uintptr_t ns16550_physical;
+static kbd_dev_t *kbd_dev;
+static sysarg_t inr;
 
-static uintptr_t ns16550_physical;
-
-static kbd_dev_t *kbd_dev;
+static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call, void *arg)
+{
+	kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
+	
+	if (irc_service) {
+		async_exch_t *exch = async_exchange_begin(irc_sess);
+		async_msg_1(exch, IRC_CLEAR_INTERRUPT, inr);
+		async_exchange_end(exch);
+	}
+}
 
 static int ns16550_port_init(kbd_dev_t *kdev)
 {
-	void *vaddr;
-	
 	kbd_dev = kdev;
 	
@@ -132,5 +135,4 @@
 		return -1;
 	
-	sysarg_t inr;
 	if (sysinfo_get_value("kbd.inr", &inr) != EOK)
 		return -1;
@@ -140,16 +142,9 @@
 	ns16550_kbd.cmds[3].addr = (void *) (ns16550_physical + RBR_REG);
 	
-	async_set_interrupt_received(ns16550_irq_handler);
-	irq_register(inr, device_assign_devno(), inr, &ns16550_kbd);
+	async_irq_subscribe(inr, device_assign_devno(), ns16550_irq_handler, NULL,
+	    &ns16550_kbd);
 	
+	void *vaddr;
 	return pio_enable((void *) ns16550_physical, 8, &vaddr);
-}
-
-static void ns16550_port_yield(void)
-{
-}
-
-static void ns16550_port_reclaim(void)
-{
 }
 
@@ -159,15 +154,4 @@
 }
 
-static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call)
-{
-	kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
-	
-	if (irc_service) {
-		async_exch_t *exch = async_exchange_begin(irc_sess);
-		async_msg_1(exch, IRC_CLEAR_INTERRUPT, IPC_GET_IMETHOD(*call));
-		async_exchange_end(exch);
-	}
-}
-
 /**
  * @}
Index: pace/srv/hid/input/port/pl050.c
===================================================================
--- uspace/srv/hid/input/port/pl050.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ 	(revision )
@@ -1,151 +1,0 @@
-/*
- * Copyright (c) 2009 Vineeth Pillai
- * Copyright (c) 2011 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 kbd_port
- * @ingroup kbd
- * @{
- */ 
-/** @file
- * @brief pl050 port driver.
- */
-
-#include <ddi.h>
-#include <async.h>
-#include <unistd.h>
-#include <sysinfo.h>
-#include <stdio.h>
-#include <errno.h>
-#include "../kbd_port.h"
-#include "../kbd.h"
-
-static int pl050_port_init(kbd_dev_t *);
-static void pl050_port_yield(void);
-static void pl050_port_reclaim(void);
-static void pl050_port_write(uint8_t data);
-
-kbd_port_ops_t pl050_port = {
-	.init = pl050_port_init,
-	.yield = pl050_port_yield,
-	.reclaim = pl050_port_reclaim,
-	.write = pl050_port_write
-};
-
-static kbd_dev_t *kbd_dev;
-
-#define PL050_STAT	4
-#define PL050_DATA	8
-
-#define PL050_STAT_RXFULL  (1 << 4)
-
-static irq_pio_range_t pl050_ranges[] = {
-	{
-		.base = 0,
-		.size = 9, 
-	}
-};
-
-static irq_cmd_t pl050_cmds[] = {
-	{
-		.cmd = CMD_PIO_READ_8,
-		.addr = NULL,
-		.dstarg = 1
-	},
-	{
-		.cmd = CMD_AND,
-		.value = PL050_STAT_RXFULL,
-		.srcarg = 1,
-		.dstarg = 3
-	},
-	{
-		.cmd = CMD_PREDICATE,
-		.value = 2,
-		.srcarg = 3
-	},
-	{
-		.cmd = CMD_PIO_READ_8,
-		.addr = NULL,  /* Will be patched in run-time */
-		.dstarg = 2
-	},
-	{
-		.cmd = CMD_ACCEPT
-	}
-};
-
-static irq_code_t pl050_kbd = {
-	sizeof(pl050_ranges) / sizeof(irq_pio_range_t),
-	pl050_ranges,
-	sizeof(pl050_cmds) / sizeof(irq_cmd_t),
-	pl050_cmds
-};
-
-static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call);
-
-static int pl050_port_init(kbd_dev_t *kdev)
-{
-	kbd_dev = kdev;
-	
-	sysarg_t addr;
-	if (sysinfo_get_value("kbd.address.physical", &addr) != EOK)
-		return -1;
-	
-	pl050_kbd.ranges[0].base = addr;
-	pl050_kbd.cmds[0].addr = (void *) addr + PL050_STAT;
-	pl050_kbd.cmds[3].addr = (void *) addr + PL050_DATA;
-	
-	sysarg_t inr;
-	if (sysinfo_get_value("kbd.inr", &inr) != EOK)
-		return -1;
-	
-	async_set_interrupt_received(pl050_irq_handler);
-	irq_register(inr, device_assign_devno(), 0, &pl050_kbd);
-	
-	return 0;
-}
-
-static void pl050_port_yield(void)
-{
-}
-
-static void pl050_port_reclaim(void)
-{
-}
-
-static void pl050_port_write(uint8_t data)
-{
-	(void) data;
-}
-
-static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call)
-{
-	kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
-}
-
-/**
- * @}
- */
Index: uspace/srv/hid/input/port/ski.c
===================================================================
--- uspace/srv/hid/input/port/ski.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/input/port/ski.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -45,12 +45,8 @@
 
 static int ski_port_init(kbd_dev_t *);
-static void ski_port_yield(void);
-static void ski_port_reclaim(void);
 static void ski_port_write(uint8_t data);
 
 kbd_port_ops_t ski_port = {
 	.init = ski_port_init,
-	.yield = ski_port_yield,
-	.reclaim = ski_port_reclaim,
 	.write = ski_port_write
 };
@@ -64,6 +60,4 @@
 static void ski_thread_impl(void *arg);
 static int32_t ski_getchar(void);
-
-static volatile bool polling_disabled = false;
 
 /** Initialize Ski port driver. */
@@ -83,14 +77,4 @@
 }
 
-static void ski_port_yield(void)
-{
-	polling_disabled = true;
-}
-
-static void ski_port_reclaim(void)
-{
-	polling_disabled = false;
-}
-
 static void ski_port_write(uint8_t data)
 {
@@ -105,8 +89,9 @@
 
 	while (1) {
-		while (polling_disabled == false) {
+		while (1) {
 			c = ski_getchar();
 			if (c == 0)
 				break;
+			
 			kbd_push_data(kbd_dev, c);
 		}
Index: uspace/srv/hid/isdv4_tablet/main.c
===================================================================
--- uspace/srv/hid/isdv4_tablet/main.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/isdv4_tablet/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -36,4 +36,5 @@
 #include <ipc/mouseev.h>
 #include <inttypes.h>
+#include <task.h>
 
 #include "isdv4.h"
Index: uspace/srv/hid/output/output.c
===================================================================
--- uspace/srv/hid/output/output.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/output/output.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -432,5 +432,4 @@
 				srv_set_rgb_color(callid, &call);
 				break;
-			
 			case OUTPUT_UPDATE:
 				srv_update(callid, &call);
Index: uspace/srv/hid/remcons/remcons.c
===================================================================
--- uspace/srv/hid/remcons/remcons.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/remcons/remcons.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,5 +40,4 @@
 #include <str_error.h>
 #include <loc.h>
-#include <event.h>
 #include <io/keycode.h>
 #include <align.h>
@@ -225,14 +224,13 @@
 {
 	telnet_user_t *user = arg;
-	int rc;
-
-	char term[LOC_NAME_MAXLEN];
-	snprintf(term, LOC_NAME_MAXLEN, "%s/%s", "/loc", user->service_name);
-
+	
 	task_id_t task;
-	rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, "-w", term, APP_SHELL, NULL);
-	if (rc != EOK) {
-		telnet_user_error(user, "Spawning `%s -w %s %s' failed: %s.",
-		    APP_GETTERM, term, APP_SHELL, str_error(rc));
+	task_wait_t wait;
+	int rc = task_spawnl(&task, &wait, APP_GETTERM, APP_GETTERM, user->service_name,
+	    "/loc", "--msg", "--", APP_SHELL, NULL);
+	if (rc != EOK) {
+		telnet_user_error(user, "Spawning `%s %s /loc --msg -- %s' "
+		    "failed: %s.", APP_GETTERM, user->service_name, APP_SHELL,
+		    str_error(rc));
 		fibril_mutex_lock(&user->guard);
 		user->task_finished = true;
@@ -249,5 +247,5 @@
 	task_exit_t task_exit;
 	int task_retval;
-	task_wait(task, &task_exit, &task_retval);
+	task_wait(&wait, &task_exit, &task_retval);
 	telnet_user_log(user, "%s terminated %s, exit code %d.", APP_GETTERM,
 	    task_exit == TASK_EXIT_NORMAL ? "normally" : "unexpectedly",
Index: uspace/srv/hid/remcons/user.c
===================================================================
--- uspace/srv/hid/remcons/user.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/remcons/user.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,5 +38,4 @@
 #include <str_error.h>
 #include <loc.h>
-#include <event.h>
 #include <io/keycode.h>
 #include <align.h>
Index: uspace/srv/hid/rfb/main.c
===================================================================
--- uspace/srv/hid/rfb/main.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/rfb/main.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -35,4 +35,5 @@
 #include <inttypes.h>
 #include <io/log.h>
+#include <task.h>
 
 #include <abi/fb/visuals.h>
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -72,5 +72,5 @@
 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall,
     void *arg);
-static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call);
+static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call, void *);
 static void s3c24xx_ts_pen_down(s3c24xx_ts_t *ts);
 static void s3c24xx_ts_pen_up(s3c24xx_ts_t *ts);
@@ -138,6 +138,6 @@
 	    (void *) ts->paddr, inr);
 
-	async_set_interrupt_received(s3c24xx_ts_irq_handler);
-	irq_register(inr, device_assign_devno(), 0, &ts_irq_code);
+	async_irq_subscribe(inr, device_assign_devno(), s3c24xx_ts_irq_handler,
+	    NULL, &ts_irq_code);
 
 	s3c24xx_ts_wait_for_int_mode(ts, updn_down);
@@ -204,5 +204,6 @@
 
 /** Handle touchscreen interrupt */
-static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call)
+static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call,
+    void *arg)
 {
 	ts_updn_t updn;
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -55,5 +55,5 @@
 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
 static int cuda_init(void);
-static void cuda_irq_handler(ipc_callid_t iid, ipc_call_t *call);
+static void cuda_irq_handler(ipc_callid_t iid, ipc_call_t *call, void *arg);
 
 static void cuda_irq_listen(void);
@@ -282,6 +282,6 @@
 	cuda_irq_code.ranges[0].base = (uintptr_t) instance->cuda_physical;
 	cuda_irq_code.cmds[0].addr = (void *) &((cuda_t *) instance->cuda_physical)->ifr;
-	async_set_interrupt_received(cuda_irq_handler);
-	irq_register(10, device_assign_devno(), 0, &cuda_irq_code);
+	async_irq_subscribe(10, device_assign_devno(), cuda_irq_handler, NULL,
+	    &cuda_irq_code);
 
 	/* Enable SR interrupt. */
@@ -295,5 +295,5 @@
 }
 
-static void cuda_irq_handler(ipc_callid_t iid, ipc_call_t *call)
+static void cuda_irq_handler(ipc_callid_t iid, ipc_call_t *call, void *arg)
 {
 	uint8_t rbuf[CUDA_RCV_BUF_SIZE];
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -68,9 +68,8 @@
 static s3c24xx_uart_t *uart;
 
-static void s3c24xx_uart_connection(ipc_callid_t iid, ipc_call_t *icall,
-    void *arg);
-static void s3c24xx_uart_irq_handler(ipc_callid_t iid, ipc_call_t *call);
-static int s3c24xx_uart_init(s3c24xx_uart_t *uart);
-static void s3c24xx_uart_sendb(s3c24xx_uart_t *uart, uint8_t byte);
+static void s3c24xx_uart_connection(ipc_callid_t, ipc_call_t *, void *);
+static void s3c24xx_uart_irq_handler(ipc_callid_t, ipc_call_t *, void *);
+static int s3c24xx_uart_init(s3c24xx_uart_t *);
+static void s3c24xx_uart_sendb(s3c24xx_uart_t *, uint8_t);
 
 int main(int argc, char *argv[])
@@ -150,7 +149,10 @@
 }
 
-static void s3c24xx_uart_irq_handler(ipc_callid_t iid, ipc_call_t *call)
-{
-	(void) iid; (void) call;
+static void s3c24xx_uart_irq_handler(ipc_callid_t iid, ipc_call_t *call,
+    void *arg)
+{
+	(void) iid;
+	(void) call;
+	(void) arg;
 
 	while ((pio_read_32(&uart->io->ufstat) & S3C24XX_UFSTAT_RX_COUNT) != 0) {
@@ -192,7 +194,6 @@
 	    (void *) uart->paddr, inr);
 
-	async_set_interrupt_received(s3c24xx_uart_irq_handler);
-
-	irq_register(inr, device_assign_devno(), 0, &uart_irq_code);
+	async_irq_subscribe(inr, device_assign_devno(), s3c24xx_uart_irq_handler,
+	    NULL, &uart_irq_code);
 
 	/* Enable FIFO, Tx trigger level: empty, Rx trigger level: 1 byte. */
Index: uspace/srv/hw/irc/icp-ic/Makefile
===================================================================
--- uspace/srv/hw/irc/icp-ic/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/srv/hw/irc/icp-ic/Makefile	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2014 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.
+#
+
+USPACE_PREFIX = ../../../..
+BINARY = icp-ic
+
+SOURCES = \
+	icp-ic.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/hw/irc/icp-ic/icp-ic.c
===================================================================
--- uspace/srv/hw/irc/icp-ic/icp-ic.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/srv/hw/irc/icp-ic/icp-ic.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2014 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 icp-ic
+ * @{
+ */
+
+/**
+ * @file icp-ic.c
+ * @brief IntegratorCP interrupt controller driver.
+ */
+
+#include <async.h>
+#include <bitops.h>
+#include <ddi.h>
+#include <errno.h>
+#include <io/log.h>
+#include <ipc/services.h>
+#include <ipc/irc.h>
+#include <ns.h>
+#include <sysinfo.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <str.h>
+
+#include "icp-ic_hw.h"
+
+#define NAME  "icp-ic"
+
+enum {
+	icp_pic_base = 0x14000000,
+	icpic_max_irq = 32
+};
+
+static icpic_regs_t *icpic_regs;
+
+static int icpic_enable_irq(sysarg_t irq)
+{
+	if (irq > icpic_max_irq)
+		return EINVAL;
+
+	log_msg(LOG_DEFAULT, LVL_NOTE, "Enable IRQ %d", irq);
+
+	pio_write_32(&icpic_regs->irq_enableset, BIT_V(uint32_t, irq));
+	return EOK;
+}
+
+/** Handle one connection to i8259.
+ *
+ * @param iid   Hash of the request that opened the connection.
+ * @param icall Call data of the request that opened the connection.
+ * @param arg	Local argument.
+ */
+static void icpic_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	ipc_callid_t callid;
+	ipc_call_t call;
+
+	/*
+	 * Answer the first IPC_M_CONNECT_ME_TO call.
+	 */
+	async_answer_0(iid, EOK);
+
+	while (true) {
+		callid = async_get_call(&call);
+
+		if (!IPC_GET_IMETHOD(call)) {
+			/* The other side has hung up. */
+			async_answer_0(callid, EOK);
+			return;
+		}
+
+		switch (IPC_GET_IMETHOD(call)) {
+		case IRC_ENABLE_INTERRUPT:
+			async_answer_0(callid,
+			    icpic_enable_irq(IPC_GET_ARG1(call)));
+			break;
+		case IRC_CLEAR_INTERRUPT:
+			/* Noop */
+			async_answer_0(callid, EOK);
+			break;
+		default:
+			async_answer_0(callid, EINVAL);
+			break;
+		}
+	}
+}
+
+static int icpic_init(void)
+{
+	char *platform = NULL;
+	char *pstr = NULL;
+	size_t platform_size;
+	void *regs;
+	int rc;
+
+	platform = sysinfo_get_data("platform", &platform_size);
+	if (platform == NULL) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "Error getting platform type.");
+		rc = ENOENT;
+		goto error;
+	}
+
+	pstr = str_ndup(platform, platform_size);
+	if (pstr == NULL) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory.");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	if (str_cmp(pstr, "integratorcp") != 0) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "Platform '%s' is not 'integratorcp'.",
+
+		    pstr);
+		rc = ENOENT;
+		goto error;
+	}
+
+	rc = pio_enable((void *)icp_pic_base, sizeof(icpic_regs_t), &regs);
+	if (rc != EOK) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "Error enabling PIO");
+		goto error;
+	}
+
+	icpic_regs = (icpic_regs_t *)regs;
+
+	async_set_client_connection(icpic_connection);
+	service_register(SERVICE_IRC);
+
+	free(platform);
+	free(pstr);
+	return EOK;
+error:
+	free(platform);
+	free(pstr);
+	return rc;
+}
+
+int main(int argc, char **argv)
+{
+	int rc;
+
+	printf("%s: HelenOS IntegratorCP interrupt controller driver\n", NAME);
+
+	rc = log_init(NAME);
+	if (rc != EOK) {
+		printf(NAME ": Error connecting logging service.");
+		return 1;
+	}
+
+	if (icpic_init() != EOK)
+		return -1;
+
+	log_msg(LOG_DEFAULT, LVL_NOTE, "%s: Accepting connections\n", NAME);
+	task_retval(0);
+	async_manager();
+
+	/* Not reached */
+	return 0;
+}
+
+/**
+ * @}
+ */
Index: uspace/srv/hw/irc/icp-ic/icp-ic_hw.h
===================================================================
--- uspace/srv/hw/irc/icp-ic/icp-ic_hw.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
+++ uspace/srv/hw/irc/icp-ic/icp-ic_hw.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014 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 pl050
+ * @{
+ */
+/** @file ARM PrimeCell PS2 Keyboard/Mouse Interface (PL050) registers
+ */
+
+#ifndef ICP_IC_HW_H
+#define ICP_IC_HW_H
+
+#include <ddi.h>
+#include <sys/types.h>
+
+typedef struct {
+	ioport32_t irq_status;
+	ioport32_t irq_rawstat;
+	ioport32_t irq_enableset;
+	ioport32_t irq_enableclr;
+	ioport32_t int_softset;
+	ioport32_t int_softclr;
+	ioport32_t fiq_status;
+	ioport32_t fiq_rawstat;
+	ioport32_t fiq_enableset;
+	ioport32_t fiq_enableclr;
+} icpic_regs_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/klog/klog.c
===================================================================
--- uspace/srv/klog/klog.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/klog/klog.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,5 +40,4 @@
 #include <as.h>
 #include <ddi.h>
-#include <event.h>
 #include <errno.h>
 #include <str_error.h>
@@ -193,5 +192,6 @@
  *
  */
-static void notification_received(ipc_callid_t callid, ipc_call_t *call)
+static void klog_notification_received(ipc_callid_t callid, ipc_call_t *call,
+    void *arg)
 {
 	/*
@@ -205,5 +205,5 @@
 	producer();
 	
-	event_unmask(EVENT_KLOG);
+	async_event_unmask(EVENT_KLOG);
 	fibril_mutex_unlock(&mtx);
 }
@@ -229,6 +229,5 @@
 	
 	prodcons_initialize(&pc);
-	async_set_interrupt_received(notification_received);
-	rc = event_subscribe(EVENT_KLOG, 0);
+	rc = async_event_subscribe(EVENT_KLOG, klog_notification_received, NULL);
 	if (rc != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR,
@@ -245,5 +244,5 @@
 	
 	fibril_add_ready(fid);
-	event_unmask(EVENT_KLOG);
+	async_event_unmask(EVENT_KLOG);
 	
 	fibril_mutex_lock(&mtx);
Index: uspace/srv/net/ethip/ethip.c
===================================================================
--- uspace/srv/net/ethip/ethip.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/net/ethip/ethip.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,4 +44,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <task.h>
 #include "arp.h"
 #include "ethip.h"
@@ -58,4 +59,5 @@
 static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu);
 static int ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac);
+static int ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac);
 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr);
 static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr);
@@ -70,4 +72,5 @@
 	.get_mtu = ethip_get_mtu,
 	.get_mac48 = ethip_get_mac48,
+	.set_mac48 = ethip_set_mac48,
 	.addr_add = ethip_addr_add,
 	.addr_remove = ethip_addr_remove
@@ -283,4 +286,14 @@
 }
 
+static int ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac)
+{
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_set_mac48()");
+	
+	ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
+	addr48(*mac, nic->mac_addr);
+	
+	return EOK;
+}
+
 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr)
 {
Index: uspace/srv/net/ethip/ethip_nic.c
===================================================================
--- uspace/srv/net/ethip/ethip_nic.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/net/ethip/ethip_nic.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -245,4 +245,12 @@
 	    addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
 
+	memcpy(&nic->mac_addr, addr, sizeof(nic->mac_addr));
+
+	rc = iplink_ev_change_addr(&nic->iplink, &nic->mac_addr);
+	if (rc != EOK) {
+		log_msg(LOG_DEFAULT, LVL_DEBUG, "iplink_ev_change_addr() failed");
+		return;
+	}
+
 	free(addr);
 	async_answer_0(callid, EOK);
@@ -309,5 +317,5 @@
 			break;
 		default:
-			log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: %d", (int) IPC_GET_IMETHOD(call));
+			log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: %" PRIun, IPC_GET_IMETHOD(call));
 			async_answer_0(callid, ENOTSUP);
 		}
Index: uspace/srv/net/inetsrv/inet_link.c
===================================================================
--- uspace/srv/net/inetsrv/inet_link.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/net/inetsrv/inet_link.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -55,8 +55,10 @@
 
 static int inet_iplink_recv(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
+static int inet_iplink_change_addr(iplink_t *, addr48_t);
 static inet_link_t *inet_link_get_by_id_locked(sysarg_t);
 
 static iplink_ev_ops_t inet_iplink_ev_ops = {
-	.recv = inet_iplink_recv
+	.recv = inet_iplink_recv,
+	.change_addr = inet_iplink_change_addr,
 };
 
@@ -110,4 +112,18 @@
 	
 	return rc;
+}
+
+static int inet_iplink_change_addr(iplink_t *iplink, addr48_t mac)
+{
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_iplink_change_addr(): "
+	    "new addr=%02x:%02x:%02x:%02x:%02x:%02x",
+	    mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+	list_foreach(inet_links, link_list, inet_link_t, ilink) {
+		if (ilink->sess == iplink->sess)
+			memcpy(&ilink->mac, mac, sizeof(addr48_t));
+	}
+
+	return EOK;
 }
 
Index: uspace/srv/net/inetsrv/inetsrv.c
===================================================================
--- uspace/srv/net/inetsrv/inetsrv.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/net/inetsrv/inetsrv.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -46,4 +46,5 @@
 #include <stdlib.h>
 #include <sys/types.h>
+#include <task.h>
 #include "addrobj.h"
 #include "icmp.h"
Index: uspace/srv/net/loopip/loopip.c
===================================================================
--- uspace/srv/net/loopip/loopip.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/net/loopip/loopip.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -44,4 +44,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <task.h>
 
 #define NAME  "loopip"
Index: uspace/srv/net/nconfsrv/nconfsrv.c
===================================================================
--- uspace/srv/net/nconfsrv/nconfsrv.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/net/nconfsrv/nconfsrv.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -48,4 +48,5 @@
 #include <stdlib.h>
 #include <sys/types.h>
+#include <task.h>
 #include "iplink.h"
 #include "nconfsrv.h"
Index: uspace/srv/net/slip/slip.c
===================================================================
--- uspace/srv/net/slip/slip.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/net/slip/slip.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -43,4 +43,5 @@
 #include <io/log.h>
 #include <errno.h>
+#include <task.h>
 
 #define NAME		"slip"
Index: uspace/srv/ns/ns.c
===================================================================
--- uspace/srv/ns/ns.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/ns/ns.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -66,5 +66,4 @@
 	while (true) {
 		process_pending_conn();
-		process_pending_wait();
 		
 		ipc_call_t call;
Index: uspace/srv/ns/task.c
===================================================================
--- uspace/srv/ns/task.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/ns/task.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,14 +40,8 @@
 #include <macros.h>
 #include <malloc.h>
+#include <types/task.h>
 #include "task.h"
 #include "ns.h"
 
-
-/* TODO:
- *
- * As there is currently no convention that each task has to be waited
- * for, the NS can leak memory because of the zombie tasks.
- *
- */
 
 /** Task hash table item. */
@@ -195,5 +189,4 @@
 		}
 		
-		hash_table_remove(&task_hash_table, &pr->id);
 		list_remove(&pr->link);
 		free(pr);
@@ -204,8 +197,4 @@
 void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid)
 {
-	sysarg_t retval;
-	task_exit_t texit;
-	bool remove = false;
-	
 	ht_link_t *link = hash_table_find(&task_hash_table, &id);
 	hashed_task_t *ht = (link != NULL) ?
@@ -218,30 +207,24 @@
 	}
 	
-	if (!ht->finished) {
-		/* Add to pending list */
-		pending_wait_t *pr =
-		    (pending_wait_t *) malloc(sizeof(pending_wait_t));
-		if (!pr) {
-			retval = ENOMEM;
-			goto out;
-		}
-		
-		link_initialize(&pr->link);
-		pr->id = id;
-		pr->callid = callid;
-		list_append(&pr->link, &pending_wait);
+	if (ht->finished) {
+		task_exit_t texit = ht->have_rval ? TASK_EXIT_NORMAL :
+		    TASK_EXIT_UNEXPECTED;
+		ipc_answer_2(callid, EOK, texit, ht->retval);
 		return;
 	}
 	
-	remove = true;
-	retval = EOK;
-	
-out:
-	if (!(callid & IPC_CALLID_NOTIFICATION)) {
-		texit = ht->have_rval ? TASK_EXIT_NORMAL : TASK_EXIT_UNEXPECTED;
-		ipc_answer_2(callid, retval, texit, ht->retval);
-	}
-	if (remove)
-		hash_table_remove_item(&task_hash_table, link);
+	/* Add to pending list */
+	pending_wait_t *pr =
+	    (pending_wait_t *) malloc(sizeof(pending_wait_t));
+	if (!pr) {
+		if (!(callid & IPC_CALLID_NOTIFICATION))
+			ipc_answer_0(callid, ENOMEM);
+		return;
+	}
+	
+	link_initialize(&pr->link);
+	pr->id = id;
+	pr->callid = callid;
+	list_append(&pr->link, &pending_wait);
 }
 
@@ -314,4 +297,6 @@
 	ht->retval = IPC_GET_ARG1(*call);
 	
+	process_pending_wait();
+	
 	return EOK;
 }
@@ -336,4 +321,7 @@
 	ht->finished = true;
 	
+	process_pending_wait();
+	hash_table_remove(&task_hash_table, &id);
+	
 	return EOK;
 }
Index: uspace/srv/ns/task.h
===================================================================
--- uspace/srv/ns/task.h	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/ns/task.h	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -35,5 +35,5 @@
 
 #include <ipc/common.h>
-#include <task.h>
+#include <abi/proc/task.h>
 
 extern int task_init(void);
Index: uspace/srv/taskmon/taskmon.c
===================================================================
--- uspace/srv/taskmon/taskmon.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/taskmon/taskmon.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -40,5 +40,4 @@
 #include <sys/typefmt.h>
 #include <task.h>
-#include <event.h>
 #include <ipc/corecfg.h>
 #include <loc.h>
@@ -53,5 +52,5 @@
 static void corecfg_client_conn(ipc_callid_t , ipc_call_t *, void *);
 
-static void fault_event(ipc_callid_t callid, ipc_call_t *call)
+static void fault_event(ipc_callid_t callid, ipc_call_t *call, void *arg)
 {
 	const char *fname;
@@ -83,9 +82,9 @@
 
 		printf(NAME ": Executing %s -c %s -t %s\n", fname, dump_fname, s_taskid);
-		rc = task_spawnl(NULL, fname, fname, "-c", dump_fname, "-t", s_taskid,
+		rc = task_spawnl(NULL, NULL, fname, fname, "-c", dump_fname, "-t", s_taskid,
 		    NULL);
 	} else {
 		printf(NAME ": Executing %s -t %s\n", fname, s_taskid);
-		rc = task_spawnl(NULL, fname, fname, "-t", s_taskid, NULL);
+		rc = task_spawnl(NULL, NULL, fname, fname, "-t", s_taskid, NULL);
 	}
 
@@ -143,5 +142,5 @@
 	write_core_files = false;
 #endif
-	if (event_subscribe(EVENT_FAULT, 0) != EOK) {
+	if (async_event_subscribe(EVENT_FAULT, fault_event, NULL) != EOK) {
 		printf("%s: Error registering fault notifications.\n", NAME);
 		return -1;
@@ -165,5 +164,4 @@
 	}
 	
-	async_set_interrupt_received(fault_event);
 	task_retval(0);
 	async_manager();
Index: uspace/srv/vfs/vfs.c
===================================================================
--- uspace/srv/vfs/vfs.c	(revision de16f892e37393d27d9d32f487cc511dc31bbd38)
+++ uspace/srv/vfs/vfs.c	(revision 089901ee8ce49168ea8f8adca63057de93de5f95)
@@ -38,6 +38,4 @@
 #include <vfs/vfs.h>
 #include <ipc/services.h>
-#include <abi/ipc/event.h>
-#include <event.h>
 #include <ns.h>
 #include <async.h>
@@ -53,8 +51,4 @@
 #define NAME  "vfs"
 
-enum {
-	VFS_TASK_STATE_CHANGE
-};
-
 static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
@@ -145,17 +139,11 @@
 }
 
-static void notification_received(ipc_callid_t callid, ipc_call_t *call)
+static void notification_handler(ipc_callid_t callid, ipc_call_t *call, void *arg)
 {
-	switch (IPC_GET_IMETHOD(*call)) {
-	case VFS_TASK_STATE_CHANGE:
-		if (IPC_GET_ARG1(*call) == VFS_PASS_HANDLE)
-			vfs_pass_handle(
-			    (task_id_t) MERGE_LOUP32(IPC_GET_ARG4(*call),
-			    IPC_GET_ARG5(*call)), call->in_task_id,
-			    (int) IPC_GET_ARG2(*call));
-		break;
-	default:
-		break;
-	}
+	if (IPC_GET_ARG1(*call) == VFS_PASS_HANDLE)
+		vfs_pass_handle(
+		    (task_id_t) MERGE_LOUP32(IPC_GET_ARG4(*call),
+		    IPC_GET_ARG5(*call)), call->in_task_id,
+		    (int) IPC_GET_ARG2(*call));
 }
 
@@ -196,8 +184,8 @@
 
 	/*
-	 * Set notification handler and subscribe to notifications.
-	 */
-	async_set_interrupt_received(notification_received);
-	event_task_subscribe(EVENT_TASK_STATE_CHANGE, VFS_TASK_STATE_CHANGE);
+	 * Subscribe to notifications.
+	 */
+	async_event_task_subscribe(EVENT_TASK_STATE_CHANGE, notification_handler,
+	    NULL);
 	
 	/*
