Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ HelenOS.config	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -63,7 +63,6 @@
 % Machine type
 @ "gta02" GTA02 / Neo FreeRunner
+@ "testarm" GXEmul Testarm
 @ "integratorcp" Integratorcp
-@ "beagleboardxm" BeagleBoard-xM
-@ "beaglebone" BeagleBone
 ! [PLATFORM=arm32] MACHINE (choice)
 
@@ -87,32 +86,4 @@
 ! [PLATFORM=sparc64&MACHINE=generic] PROCESSOR (choice)
 
-% CPU type
-@ "cortex_a8" ARM Cortex A-8
-! [PLATFORM=arm32&(MACHINE=beagleboardxm|MACHINE=beaglebone)] PROCESSOR (choice)
-
-% CPU type
-@ "arm920t" ARM920T
-! [PLATFORM=arm32&MACHINE=gta02] PROCESSOR (choice)
-
-% CPU type
-@ "arm926ej_s" ARM926EJ-S
-! [PLATFORM=arm32&MACHINE=integratorcp] PROCESSOR (choice)
-
-
-# Add more ARMv4 CPUs
-% CPU arch
-@ "armv4" ARMv4
-! [PLATFORM=arm32&(PROCESSOR=arm920t)] PROCESSOR_ARCH (choice)
-
-# Add more ARMv5 CPUs
-% CPU arch
-@ "armv5" ARMv5
-! [PLATFORM=arm32&(PROCESSOR=arm926ej_s)] PROCESSOR_ARCH (choice)
-
-# Add more ARMv7-A CPUs
-% CPU arch
-@ "armv7_a" ARMv7-A
-! [PLATFORM=arm32&(PROCESSOR=cortex_a8)] PROCESSOR_ARCH (choice)
-
 % RAM disk format
 @ "tmpfs" TMPFS image
@@ -363,11 +334,4 @@
 ! [PLATFORM=mips32&(MACHINE=lgxemul|MACHINE=bgxemul)] CONFIG_FPU (y)
 
-## armv7 made fpu hardware compulsory
-% FPU support
-! [PLATFORM=arm32&PROCESSOR_ARCH=armv7_a] CONFIG_FPU (y)
-
-% FPU support
-! [PLATFORM=arm32&MACHINE=integratorcp] CONFIG_FPU (y)
-
 
 ## Kernel features options
@@ -431,5 +395,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=arm32&MACHINE=testarm)|PLATFORM=amd64|PLATFORM=mips32|PLATFORM=mips64|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_HID_IN (choice)
 
 % Input device class
@@ -442,5 +406,5 @@
 % Output device class
 @ "generic" Monitor or serial line
-! [PLATFORM=arm32&(MACHINE=gta02|MACHINE=integratorcp|MACHINE=beagleboardxm|MACHINE=beaglebone)] CONFIG_HID_OUT (choice)
+! [PLATFORM=arm32&(MACHINE=gta02|MACHINE=integratorcp)] CONFIG_HID_OUT (choice)
 
 % Output device class
@@ -456,4 +420,11 @@
 ! [PLATFORM=mips32&(MACHINE=bgxemul|MACHINE=lgxemul)] CONFIG_HID_OUT (choice)
 
+% Output device class
+@ "generic" Monitor or serial line
+@ "monitor" Monitor
+@ "serial" Serial line
+@ "none" No output device
+! [PLATFORM=arm32&MACHINE=testarm] CONFIG_HID_OUT (choice)
+
 % PC keyboard support
 ! [CONFIG_HID_IN=generic&(PLATFORM=ia32|PLATFORM=amd64)] CONFIG_PC_KBD (y/n)
@@ -471,4 +442,10 @@
 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&(PLATFORM=mips32|PLATFORM=mips64)] CONFIG_MIPS_PRN (y/n)
 
+% Support for GXemul keyboard
+! [CONFIG_HID_IN=generic&PLATFORM=arm32&MACHINE=testarm] CONFIG_ARM_KBD (y/n)
+
+% Support for GXemul printer
+! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=testarm] CONFIG_ARM_PRN (y/n)
+
 % Support for VIA CUDA controller
 ! [CONFIG_HID_IN=generic&PLATFORM=ppc32] CONFIG_VIA_CUDA (y/n)
@@ -489,13 +466,4 @@
 ! [PLATFORM=arm32&MACHINE=gta02] CONFIG_S3C24XX_IRQC (y)
 
-% Support for TI AM335x on-chip UART
-! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=beaglebone] CONFIG_AM335X_UART (y/n)
-
-% Support for TI AM335x timers support
-! [PLATFORM=arm32&MACHINE=beaglebone] CONFIG_AM335X_TIMERS (y)
-
-% Support for TI AMDM37x on-chip UART
-! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=beagleboardxm] CONFIG_AMDM37X_UART (y/n)
-
 % Support for i8042 controller
 ! [CONFIG_PC_KBD=y] CONFIG_I8042 (y)
@@ -517,5 +485,5 @@
 
 % Serial line input module
-! [CONFIG_DSRLNIN=y|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=arm32&MACHINE=integratorcp&CONFIG_ARM926_UART=y)|(PLATFORM=arm32&MACHINE=beaglebone&CONFIG_AM335X_UART=y)|(PLATFORM=arm32&MACHINE=beagleboardxm&CONFIG_AMDM37X_UART=y)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)] CONFIG_SRLN (y)
+! [CONFIG_DSRLNIN=y|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=arm32&MACHINE=integratorcp&CONFIG_ARM926_UART=y)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)] CONFIG_SRLN (y)
 
 % EGA support
@@ -553,5 +521,5 @@
 @ "1920x1080"
 @ "1920x1200"
-! [(PLATFORM=ia32|PLATFORM=amd64|MACHINE=beagleboardxm)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_BFB_MODE (choice)
+! [(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_BFB_MODE (choice)
 
 % Default framebuffer depth
@@ -559,5 +527,5 @@
 @ "16"
 @ "24"
-! [(PLATFORM=ia32|PLATFORM=amd64|MACHINE=beagleboardxm)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_BFB_BPP (choice)
+! [(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_BFB_BPP (choice)
 
 % Start AP processors by the loader
@@ -627,10 +595,2 @@
 @ "efi" GRUB for UEFI
 ! [PLATFORM=ia32|PLATFORM=amd64] GRUB_ARCH (choice)
-
-% uImage OS type
-@ "2" NetBSD stage 2 boot loader
-! [PLATFORM=arm32&(MACHINE=beagleboardxm|MACHINE=beaglebone)] UIMAGE_OS (choice)
-
-% uImage OS type
-@ "5" Linux kernel
-! [PLATFORM=arm32&MACHINE!=beagleboardxm&MACHINE!=beaglebone] UIMAGE_OS (choice)
Index: abi/include/abi/bool.h
===================================================================
--- abi/include/abi/bool.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ abi/include/abi/bool.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 #define ABI_BOOL_H_
 
-#define bool _Bool
+typedef uint8_t bool;
 
 #endif
Index: i/include/abi/klog.h
===================================================================
--- abi/include/abi/klog.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2012 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 generic
- * @{
- */
-/** @file
- */
-
-#ifndef ABI_KLOG_H_
-#define ABI_KLOG_H_
-
-enum {
-	KLOG_UNKNOW,
-	KLOG_WRITE,
-	KLOG_UPDATE,
-	KLOG_COMMAND
-};
-
-#endif
-
-/** @}
- */
Index: abi/include/abi/mm/as.h
===================================================================
--- abi/include/abi/mm/as.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ abi/include/abi/mm/as.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,10 +37,8 @@
 
 /** Address space area flags. */
-#define AS_AREA_READ         0x01
-#define AS_AREA_WRITE        0x02
-#define AS_AREA_EXEC         0x04
-#define AS_AREA_CACHEABLE    0x08
-#define AS_AREA_GUARD        0x10
-#define AS_AREA_LATE_RESERVE 0x20
+#define AS_AREA_READ       1
+#define AS_AREA_WRITE      2
+#define AS_AREA_EXEC       4
+#define AS_AREA_CACHEABLE  8
 
 /** Address space area info exported to uspace. */
Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/Makefile.common	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -109,4 +109,5 @@
 	$(USPACE_PATH)/srv/fs/exfat/exfat \
 	$(USPACE_PATH)/srv/fs/udf/udf \
+	$(USPACE_PATH)/srv/fs/ext2fs/ext2fs \
 	$(USPACE_PATH)/srv/fs/ext4fs/ext4fs \
 	$(USPACE_PATH)/srv/hid/remcons/remcons \
@@ -166,4 +167,5 @@
 	$(USPACE_PATH)/app/dload/dload \
 	$(USPACE_PATH)/app/edit/edit \
+	$(USPACE_PATH)/app/ext2info/ext2info \
 	$(USPACE_PATH)/app/inet/inet \
 	$(USPACE_PATH)/app/kill/kill \
Index: boot/Makefile.uboot
===================================================================
--- boot/Makefile.uboot	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/Makefile.uboot	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 
 $(POST_OUTPUT): $(BIN_OUTPUT)
-	$(MKUIMAGE) -name "$(IMAGE_NAME)" -laddr $(LADDR) -saddr $(SADDR) -ostype $(UIMAGE_OS) $< $@
+	$(MKUIMAGE) -name "$(IMAGE_NAME)" -laddr 0x30008000 -saddr 0x30008000 $< $@
 
 clean:
Index: boot/arch/arm32/Makefile.inc
===================================================================
--- boot/arch/arm32/Makefile.inc	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/Makefile.inc	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -30,14 +30,4 @@
 	BOOT_OUTPUT = image.boot
 	POST_OUTPUT = $(ROOT_PATH)/uImage.bin
-	LADDR = 0x30008000
-	SADDR = 0x30008000
-	POSTBUILD = Makefile.uboot
-endif
-
-ifeq ($(MACHINE), $(filter $(MACHINE),beagleboardxm beaglebone))
-	BOOT_OUTPUT = image.boot
-	POST_OUTPUT = $(ROOT_PATH)/uImage.bin
-	LADDR = 0x80000000
-	SADDR = 0x80000000
 	POSTBUILD = Makefile.uboot
 endif
@@ -49,22 +39,12 @@
 BITS = 32
 ENDIANESS = LE
-EXTRA_CFLAGS = -march=$(subst _,-,$(PROCESSOR_ARCH)) -mno-unaligned-access
+EXTRA_CFLAGS = -march=armv4
 
-ifeq ($(MACHINE), gta02)
 RD_SRVS_ESSENTIAL += \
 	$(USPACE_PATH)/srv/hid/s3c24xx_ts/s3c24xx_ts \
-	$(USPACE_PATH)/srv/hw/char/s3c24xx_uart/s3c24ser
-endif
+	$(USPACE_PATH)/srv/hw/char/s3c24xx_uart/s3c24xx_uart
 
-RD_DRVS += \
-	infrastructure/rootamdm37x \
-	fb/amdm37x_dispc \
-	bus/usb/ehci \
-	bus/usb/ohci \
-	bus/usb/usbflbk \
-	bus/usb/usbhub \
-	bus/usb/usbhid \
-	bus/usb/usbmast \
-	bus/usb/usbmid
+RD_SRVS_NON_ESSENTIAL += \
+	$(USPACE_PATH)/srv/bd/gxe_bd/gxe_bd
 
 SOURCES = \
Index: boot/arch/arm32/_link.ld.in
===================================================================
--- boot/arch/arm32/_link.ld.in	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/_link.ld.in	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -11,5 +11,4 @@
 	. = BOOT_BASE + 0x8000;
 	.data : {
-		bdata_start = .;
 		*(BOOTPT);      /* bootstrap page table */
 		*(BOOTSTACK);   /* bootstrap stack */
@@ -25,6 +24,5 @@
 [[COMPONENTS]]
 	}
-	bdata_end = .;
-
+	
 	/DISCARD/ : {
 		*(.gnu.*);
Index: boot/arch/arm32/include/arch.h
===================================================================
--- boot/arch/arm32/include/arch.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/include/arch.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,8 +42,4 @@
 #ifdef MACHINE_gta02
 #define BOOT_BASE	0x30008000
-#elif defined MACHINE_beagleboardxm
-#define BOOT_BASE	0x80000000
-#elif defined MACHINE_beaglebone
-#define BOOT_BASE       0x80000000
 #else
 #define BOOT_BASE	0x00000000
@@ -52,18 +48,9 @@
 #define BOOT_OFFSET	(BOOT_BASE + 0xa00000)
 
-#ifdef MACHINE_beagleboardxm
-	#define PA_OFFSET 0
-#elif defined MACHINE_beaglebone
-	#define PA_OFFSET 0
+#ifndef __ASM__
+	#define PA2KA(addr)  (((uintptr_t) (addr)) + 0x80000000)
 #else
-	#define PA_OFFSET 0x80000000
+	#define PA2KA(addr)  ((addr) + 0x80000000)
 #endif
-
-#ifndef __ASM__
-	#define PA2KA(addr)  (((uintptr_t) (addr)) + PA_OFFSET)
-#else
-	#define PA2KA(addr)  ((addr) + PA_OFFSET)
-#endif
-
 
 #endif
Index: boot/arch/arm32/include/main.h
===================================================================
--- boot/arch/arm32/include/main.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/include/main.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,25 +40,4 @@
 /** Address where characters to be printed are expected. */
 
-
-/** BeagleBoard-xM UART register address
- *
- * This is UART3 of AM/DM37x CPU
- */
-#define BBXM_SCONS_THR          0x49020000
-#define BBXM_SCONS_SSR          0x49020044
-
-/* Check this bit before writing (tx fifo full) */
-#define BBXM_THR_FULL           0x00000001
-
-/** Beaglebone UART register addresses
- *
- * This is UART0 of AM335x CPU
- */
-#define BBONE_SCONS_THR         0x44E09000
-#define BBONE_SCONS_SSR         0x44E09044
-
-/** Check this bit before writing (tx fifo full) */
-#define BBONE_TXFIFO_FULL       0x00000001
-
 /** GTA02 serial console UART register addresses.
  *
@@ -72,4 +51,7 @@
 
 
+/** GXemul testarm serial console output register */
+#define TESTARM_SCONS_ADDR	0x10000000
+
 /** IntegratorCP serial console output register */
 #define ICP_SCONS_ADDR		0x16000000
Index: boot/arch/arm32/include/mm.h
===================================================================
--- boot/arch/arm32/include/mm.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/include/mm.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -47,25 +47,7 @@
 /** Describe "section" page table entry (one-level paging with 1 MB sized pages). */
 #define PTE_DESCRIPTOR_SECTION  0x02
-/** Shift of memory address in section descriptor */
-#define PTE_SECTION_SHIFT  20
 
 /** Page table access rights: user - no access, kernel - read/write. */
 #define PTE_AP_USER_NO_KERNEL_RW  0x01
-
-/** Start of memory mapped I/O area for GTA02 */
-#define GTA02_IOMEM_START  0x48000000
-/** End of memory mapped I/O area for GTA02 */
-#define GTA02_IOMEM_END  0x60000000
-
-/** Start of ram memory on BBxM */
-#define BBXM_RAM_START   0x80000000
-/** Start of ram memory on BBxM */
-#define BBXM_RAM_END   0xc0000000
-
-/** Start of ram memory on AM335x */
-#define AM335x_RAM_START   0x80000000
-/** End of ram memory on AM335x */
-#define AM335x_RAM_END     0xC0000000
-
 
 /* Page table level 0 entry - "section" format is used
@@ -76,14 +58,9 @@
 	unsigned int bufferable : 1;
 	unsigned int cacheable : 1;
-	unsigned int xn : 1;
+	unsigned int impl_specific : 1;
 	unsigned int domain : 4;
 	unsigned int should_be_zero_1 : 1;
-	unsigned int access_permission_0 : 2;
-	unsigned int tex : 3;
-	unsigned int access_permission_1 : 1;
-	unsigned int shareable : 1;
-	unsigned int non_global : 1;
-	unsigned int should_be_zero_2 : 1;
-	unsigned int non_secure : 1;
+	unsigned int access_permission : 2;
+	unsigned int should_be_zero_2 : 8;
 	unsigned int section_base_addr : 12;
 } __attribute__((packed)) pte_level0_section_t;
Index: boot/arch/arm32/src/asm.S
===================================================================
--- boot/arch/arm32/src/asm.S	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/src/asm.S	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -60,40 +60,3 @@
 	# before passing control to the copied code.
 	#
-
-	#
-	# r0 is kernel entry point
-	# r1 is pointer to the bootinfo structure
-
-#define CP15_C1_IC		12
-#define CP15_C1_BP		11
-#define CP15_C1_DC		2
-	# Disable I-cache and D-cache before the kernel is started.
-	mrc	p15, 0, r4, c1, c0, 0
-	bic	r4, r4, #(1 << CP15_C1_DC)
-	bic	r4, r4, #(1 << CP15_C1_IC)
-	bic	r4, r4, #(1 << CP15_C1_BP)
-	mcr	p15, 0, r4, c1, c0, 0
-
-	
-	#Wait for the operations to complete
-#ifdef PROCESSOR_ARCH_armv7_a
-	dsb
-#else
-	#cp15 dsb, r4 is ignored (should be zero)
-	mcr p15, 0, r4, c7, c10, 4
-#endif
-	
-	# Clean ICache and BPredictors, r4 ignored (SBZ)
-	mcr p15, 0, r4, c7, c5, 0
-	nop
-
-	#Wait for the operations to complete
-#ifdef PROCESSOR_ARCH_armv7_a
-	isb
-	nop
-#else
-	# cp15 isb
-	mcr p15, 0, r4, c7, c5, 4
-	nop
-#endif
 	mov pc, r0
Index: boot/arch/arm32/src/main.c
===================================================================
--- boot/arch/arm32/src/main.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/src/main.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -50,48 +50,11 @@
 #define TOP2ADDR(top)  (((void *) PA2KA(BOOT_OFFSET)) + (top))
 
-extern void *bdata_start;
-extern void *bdata_end;
-
-
-static inline void invalidate_icache(void)
-{
-	/* ICIALLU Invalidate entire ICache */
-	asm volatile ("mov r0, #0\n" "mcr p15, 0, r0, c7, c5, 0\n" ::: "r0" );
-}
-
-static inline void invalidate_dcache(void *address, size_t size)
-{
-	const uintptr_t addr = (uintptr_t)address;
-	/* DCIMVAC - invalidate by address to the point of coherence */
-	for (uintptr_t a = addr; a < addr + size; a += 4) {
-		asm volatile ("mcr p15, 0, %[a], c7, c6, 1\n" :: [a]"r"(a) : );
-	}
-}
-
-static inline void clean_dcache_poc(void *address, size_t size)
-{
-	const uintptr_t addr = (uintptr_t)address;
-	/* DCCMVAC - clean by address to the point of coherence */
-	for (uintptr_t a = addr; a < addr + size; a += 4) {
-		asm volatile ("mcr p15, 0, %[a], c7, c10, 1\n" :: [a]"r"(a) : );
-	}
-}
-
 static bootinfo_t bootinfo;
 
 void bootstrap(void)
 {
-	/* Make sure  we run in memory code when caches are enabled,
-	 * make sure we read memory data too. This part is ARMv7 specific as
-	 * ARMv7 no longer invalidates caches on restart.
-	 * See chapter B2.2.2 of ARM Architecture Reference Manual p. B2-1263*/
-	invalidate_icache();
-	invalidate_dcache(&bdata_start, &bdata_end - &bdata_start);
-
-	/* Enable MMU and caches */
 	mmu_start();
 	version_print();
 	
-	printf("Boot data: %p -> %p\n", &bdata_start, &bdata_end);
 	printf("\nMemory statistics\n");
 	printf(" %p|%p: bootstrap stack\n", &boot_stack, &boot_stack);
@@ -101,10 +64,9 @@
 	    (void *) PA2KA(BOOT_OFFSET), (void *) BOOT_OFFSET);
 	
-	for (size_t i = 0; i < COMPONENTS; i++) {
+	size_t i;
+	for (i = 0; i < COMPONENTS; i++)
 		printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start,
 		    components[i].start, components[i].name, components[i].inflated,
 		    components[i].size);
-		invalidate_dcache(components[i].start, components[i].size);
-	}
 	
 	void *dest[COMPONENTS];
@@ -112,5 +74,5 @@
 	size_t cnt = 0;
 	bootinfo.cnt = 0;
-	for (size_t i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
+	for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
 		top = ALIGN_UP(top, PAGE_SIZE);
 		
@@ -132,5 +94,5 @@
 	printf("\nInflating components ... ");
 	
-	for (size_t i = cnt; i > 0; i--) {
+	for (i = cnt; i > 0; i--) {
 		void *tail = components[i - 1].start + components[i - 1].size;
 		if (tail >= dest[i - 1]) {
@@ -144,14 +106,14 @@
 		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\n", components[i - 1].name, err);
 			halt();
 		}
-		clean_dcache_poc(dest[i - 1], components[i - 1].inflated);
 	}
 	
 	printf(".\n");
 	
-	printf("Booting the kernel...\n");
+	printf("Booting the kernel... \n");
 	jump_to_kernel((void *) PA2KA(BOOT_OFFSET), &bootinfo);
 }
Index: boot/arch/arm32/src/mm.c
===================================================================
--- boot/arch/arm32/src/mm.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/src/mm.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,45 +38,4 @@
 #include <arch/mm.h>
 
-/** Disable the MMU */
-static void disable_paging(void)
-{
-	asm volatile (
-		"mrc p15, 0, r0, c1, c0, 0\n"
-		"bic r0, r0, #1\n"
-		"mcr p15, 0, r0, c1, c0, 0\n"
-		::: "r0"
-	);
-}
-
-/** Check if caching can be enabled for a given memory section.
- *
- * Memory areas used for I/O are excluded from caching.
- * At the moment caching is enabled only on GTA02.
- *
- * @param section	The section number.
- *
- * @return	1 if the given section can be mapped as cacheable, 0 otherwise.
-*/
-static inline int section_cacheable(pfn_t section)
-{
-#ifdef MACHINE_gta02
-	unsigned long address = section << PTE_SECTION_SHIFT;
-
-	if (address >= GTA02_IOMEM_START && address < GTA02_IOMEM_END)
-		return 0;
-	else
-		return 1;
-#elif defined MACHINE_beagleboardxm
-	const unsigned long address = section << PTE_SECTION_SHIFT;
-	if (address >= BBXM_RAM_START && address < BBXM_RAM_END)
-		return 1;
-#elif defined MACHINE_beaglebone
-	const unsigned long address = section << PTE_SECTION_SHIFT;
-	if (address >= AM335x_RAM_START && address < AM335x_RAM_END)
-		return 1;
-#endif
-	return 0;
-}
-
 /** Initialize "section" page table entry.
  *
@@ -95,16 +54,11 @@
 {
 	pte->descriptor_type = PTE_DESCRIPTOR_SECTION;
-	pte->bufferable = 1;
-	pte->cacheable = section_cacheable(frame);
-	pte->xn = 0;
+	pte->bufferable = 0;
+	pte->cacheable = 0;
+	pte->impl_specific = 0;
 	pte->domain = 0;
 	pte->should_be_zero_1 = 0;
-	pte->access_permission_0 = PTE_AP_USER_NO_KERNEL_RW;
-	pte->tex = 0;
-	pte->access_permission_1 = 0;
-	pte->shareable = 0;
-	pte->non_global = 0;
+	pte->access_permission = PTE_AP_USER_NO_KERNEL_RW;
 	pte->should_be_zero_2 = 0;
-	pte->non_secure = 0;
 	pte->section_base_addr = frame;
 }
@@ -113,9 +67,17 @@
 static void init_boot_pt(void)
 {
-	const pfn_t split_page = PTL0_ENTRIES;
+	pfn_t split_page = 0x800;
+	
 	/* Create 1:1 virtual-physical mapping (in lower 2 GB). */
 	pfn_t page;
 	for (page = 0; page < split_page; page++)
 		init_ptl0_section(&boot_pt[page], page);
+	
+	/*
+	 * Create 1:1 virtual-physical mapping in kernel space
+	 * (upper 2 GB), physical addresses start from 0.
+	 */
+	for (page = split_page; page < PTL0_ENTRIES; page++)
+		init_ptl0_section(&boot_pt[page], page - split_page);
 	
 	asm volatile (
@@ -133,23 +95,14 @@
 		/* Behave as a client of domains */
 		"ldr r0, =0x55555555\n"
-		"mcr p15, 0, r0, c3, c0, 0\n"
-
+		"mcr p15, 0, r0, c3, c0, 0\n" 
+		
 		/* Current settings */
 		"mrc p15, 0, r0, c1, c0, 0\n"
 		
-		/* Enable ICache, DCache, BPredictors and MMU,
-		 * we disable caches before jumping to kernel
-		 * so this is safe for all archs.
-		 */
-		"ldr r1, =0x00001805\n"
+		/* Mask to enable paging */
+		"ldr r1, =0x00000001\n"
+		"orr r0, r0, r1\n"
 		
-		"orr r0, r0, r1\n"
-
-		/* Invalidate the TLB content before turning on the MMU.
-		 * ARMv7-A Reference manual, B3.10.3
-		 */
-		"mcr p15, 0, r0, c8, c7, 0\n"
-		
-		/* Store settings, enable the MMU */
+		/* Store settings */
 		"mcr p15, 0, r0, c1, c0, 0\n"
 		::: "r0", "r1"
@@ -159,5 +112,4 @@
 /** Start the MMU - initialize page table and enable paging. */
 void mmu_start() {
-	disable_paging();
 	init_boot_pt();
 	enable_paging();
Index: boot/arch/arm32/src/putchar.c
===================================================================
--- boot/arch/arm32/src/putchar.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/arm32/src/putchar.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,48 +41,4 @@
 #include <str.h>
 
-#ifdef MACHINE_beaglebone
-
-/** Send a byte to the am335x serial console.
- *
- * @param byte		Byte to send.
- */
-static void scons_sendb_bbone(uint8_t byte)
-{
-	volatile uint32_t *thr =
-		(volatile uint32_t *) BBONE_SCONS_THR;
-	volatile uint32_t *ssr =
-		(volatile uint32_t *) BBONE_SCONS_SSR;
-
-	/* Wait until transmitter is empty */
-	while (*ssr & BBONE_TXFIFO_FULL);
-
-	/* Transmit byte */
-	*thr = (uint32_t) byte;
-}
-
-#endif
-
-#ifdef MACHINE_beagleboardxm
-
-/** Send a byte to the amdm37x serial console.
- *
- * @param byte		Byte to send.
- */
-static void scons_sendb_bbxm(uint8_t byte)
-{
-	volatile uint32_t *thr =
-	    (volatile uint32_t *)BBXM_SCONS_THR;
-	volatile uint32_t *ssr =
-	    (volatile uint32_t *)BBXM_SCONS_SSR;
-
-	/* Wait until transmitter is empty. */
-	while ((*ssr & BBXM_THR_FULL) == 1) ;
-
-	/* Transmit byte. */
-	*thr = (uint32_t) byte;
-}
-
-#endif
-
 #ifdef MACHINE_gta02
 
@@ -109,4 +65,17 @@
 #endif
 
+#ifdef MACHINE_testarm
+
+/** Send a byte to the GXemul testarm serial console.
+ *
+ * @param byte		Byte to send.
+ */
+static void scons_sendb_testarm(uint8_t byte)
+{
+	*((volatile uint8_t *) TESTARM_SCONS_ADDR) = byte;
+}
+
+#endif
+
 #ifdef MACHINE_integratorcp
 
@@ -128,12 +97,9 @@
 static void scons_sendb(uint8_t byte)
 {
-#ifdef MACHINE_beaglebone
-	scons_sendb_bbone(byte);
-#endif
-#ifdef MACHINE_beagleboardxm
-	scons_sendb_bbxm(byte);
-#endif
 #ifdef MACHINE_gta02
 	scons_sendb_gta02(byte);
+#endif
+#ifdef MACHINE_testarm
+	scons_sendb_testarm(byte);
 #endif
 #ifdef MACHINE_integratorcp
Index: boot/arch/ia64/src/main.c
===================================================================
--- boot/arch/ia64/src/main.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ boot/arch/ia64/src/main.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -48,5 +48,5 @@
 
 #define DEFAULT_MEMORY_BASE		0x4000000ULL
-#define DEFAULT_MEMORY_SIZE		(256 * 1024 * 1024)
+#define DEFAULT_MEMORY_SIZE		0x4000000ULL
 #define DEFAULT_LEGACY_IO_BASE		0x00000FFFFC000000ULL
 #define DEFAULT_LEGACY_IO_SIZE		0x4000000ULL
Index: contrib/conf/arm32-gx.sh
===================================================================
--- contrib/conf/arm32-gx.sh	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ contrib/conf/arm32-gx.sh	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+gxemul $@ -E testarm -X image.boot
Index: contrib/conf/arm32-qe.sh
===================================================================
--- contrib/conf/arm32-qe.sh	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ contrib/conf/arm32-qe.sh	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-qemu-system-arm $@ -M integratorcp --kernel image.boot -serial stdio
+qemu-system-arm $@ -M integratorcp --kernel image.boot
Index: contrib/conf/ski.conf
===================================================================
--- contrib/conf/ski.conf	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ contrib/conf/ski.conf	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,1 +1,1 @@
-load image.boot
+load HelenOS/image.boot
Index: defaults/arm32/GXemul/Makefile.config
===================================================================
--- defaults/arm32/GXemul/Makefile.config	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ defaults/arm32/GXemul/Makefile.config	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,2 @@
+# Machine type
+MACHINE = testarm
Index: faults/arm32/beagleboardxm/Makefile.config
===================================================================
--- defaults/arm32/beagleboardxm/Makefile.config	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,11 +1,0 @@
-# Machine type
-MACHINE = beagleboardxm
-
-# RAM disk format
-RDFMT = fat
-
-#framebuffer
-CONFIG_FB = y
-
-CONFIG_BFB_MODE = 1024x768
-CONFIG_BFB_BPP = 24
Index: faults/arm32/beaglebone/Makefile.config
===================================================================
--- defaults/arm32/beaglebone/Makefile.config	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,8 +1,0 @@
-# Machine type
-MACHINE = beaglebone
-
-# RAM disk format
-RDFMT = fat
-
-#framebuffer
-CONFIG_FB = n
Index: defaults/arm32/gta02/Makefile.config
===================================================================
--- defaults/arm32/gta02/Makefile.config	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ defaults/arm32/gta02/Makefile.config	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -3,3 +3,3 @@
 
 # RAM disk format
-RDFMT = fat
+RDFMT = tmpfs
Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/amd64/Makefile.inc	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,5 +33,24 @@
 
 FPU_NO_CFLAGS = -mno-sse -mno-sse2
-CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
+
+#
+# FIXME:
+#
+# The -fno-optimize-sibling-calls should be removed as soon as a bug
+# in GCC concerning the "large" memory model and tail call optimization
+# is fixed.
+#
+# When GCC generates a code for tail call, instead of generating ..
+#
+#   jmp *fnc
+#
+# it generates an assembly code with an illegal immediate prefix:
+#
+#   jmp *$fnc
+#
+# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48385 for reference.
+#
+
+CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer -fno-optimize-sibling-calls
 GCC_CFLAGS += $(CMN1)
 ICC_CFLAGS += $(CMN1)
@@ -76,5 +95,6 @@
 	arch/$(KARCH)/src/proc/thread.c \
 	arch/$(KARCH)/src/userspace.c \
-	arch/$(KARCH)/src/syscall.c
+	arch/$(KARCH)/src/syscall.c \
+	arch/$(KARCH)/src/debugger.c
 
 ifeq ($(CONFIG_SMP),y)
Index: kernel/arch/amd64/include/arch/debugger.h
===================================================================
--- kernel/arch/amd64/include/arch/debugger.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ kernel/arch/amd64/include/arch/debugger.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,57 @@
+/*
+ * 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 amd64debug
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_amd64_DEBUGGER_H_
+#define KERN_amd64_DEBUGGER_H_
+
+#include <typedefs.h>
+
+#define BKPOINTS_MAX  4
+
+/* Flags that are passed to breakpoint_add function */
+#define BKPOINT_INSTR       0x1U
+#define BKPOINT_WRITE       0x2U
+#define BKPOINT_READ_WRITE  0x4U
+
+#define BKPOINT_CHECK_ZERO  0x8U
+
+
+extern void debugger_init(void);
+extern int breakpoint_add(const void *, const unsigned int, int);
+extern void breakpoint_del(int);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/amd64/include/arch/istate.h
===================================================================
--- kernel/arch/amd64/include/arch/istate.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/amd64/include/arch/istate.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -66,10 +66,8 @@
 } istate_t;
 
-#define RPL_USER	3
-
 /** Return true if exception happened while in userspace */
 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
 {
-	return (istate->cs & RPL_USER) == RPL_USER;
+	return !(istate->rip & UINT64_C(0x8000000000000000));
 }
 
Index: kernel/arch/amd64/src/amd64.c
===================================================================
--- kernel/arch/amd64/src/amd64.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/amd64/src/amd64.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -43,4 +43,5 @@
 #include <arch/bios/bios.h>
 #include <arch/boot/boot.h>
+#include <arch/debugger.h>
 #include <arch/drivers/i8254.h>
 #include <arch/drivers/i8259.h>
@@ -160,4 +161,6 @@
 #endif
 		
+		/* Enable debugger */
+		debugger_init();
 		/* Merge all memory zones to 1 big zone */
 		zone_merge_all();
Index: kernel/arch/amd64/src/debugger.c
===================================================================
--- kernel/arch/amd64/src/debugger.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ kernel/arch/amd64/src/debugger.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,421 @@
+/*
+ * 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 amd64debug
+ * @{
+ */
+/** @file
+ */
+
+#include <arch/debugger.h>
+#include <console/kconsole.h>
+#include <console/cmd.h>
+#include <print.h>
+#include <panic.h>
+#include <interrupt.h>
+#include <arch/asm.h>
+#include <arch/cpu.h>
+#include <debug.h>
+#include <func.h>
+#include <smp/ipi.h>
+#include <symtab.h>
+
+#ifdef __64_BITS__
+	#define getip(x)  ((x)->rip)
+#endif
+
+#ifdef __32_BITS__
+	#define getip(x)  ((x)->eip)
+#endif
+
+typedef struct  {
+	uintptr_t address;   /**< Breakpoint address */
+	unsigned int flags;  /**< Flags regarding breakpoint */
+	size_t counter;      /**< How many times the exception occured */
+} bpinfo_t;
+
+static bpinfo_t breakpoints[BKPOINTS_MAX];
+IRQ_SPINLOCK_STATIC_INITIALIZE(bkpoint_lock);
+
+#ifdef CONFIG_KCONSOLE
+
+static int cmd_print_breakpoints(cmd_arg_t *);
+static int cmd_del_breakpoint(cmd_arg_t *);
+static int cmd_add_breakpoint(cmd_arg_t *);
+
+static cmd_info_t bkpts_info = {
+	.name = "bkpts",
+	.description = "Print breakpoint table.",
+	.func = cmd_print_breakpoints,
+	.argc = 0,
+};
+
+static cmd_arg_t del_argv = {
+	.type = ARG_TYPE_INT
+};
+
+static cmd_info_t delbkpt_info = {
+	.name = "delbkpt",
+	.description = "Delete breakpoint.",
+	.func = cmd_del_breakpoint,
+	.argc = 1,
+	.argv = &del_argv
+};
+
+static cmd_arg_t add_argv = {
+	.type = ARG_TYPE_INT
+};
+
+static cmd_info_t addbkpt_info = {
+	.name = "addbkpt",
+	.description = "Add breakpoint.",
+	.func = cmd_add_breakpoint,
+	.argc = 1,
+	.argv = &add_argv
+};
+
+static cmd_arg_t addw_argv = {
+	.type = ARG_TYPE_INT
+};
+
+static cmd_info_t addwatchp_info = {
+	.name = "addwatchp",
+	.description = "Add write watchpoint.",
+	.func = cmd_add_breakpoint,
+	.argc = 1,
+	.argv = &addw_argv
+};
+
+#endif /* CONFIG_KCONSOLE */
+
+/** Setup DR register according to table
+ *
+ */
+static void setup_dr(int curidx)
+{
+	ASSERT(curidx >= 0);
+	
+	bpinfo_t *cur = &breakpoints[curidx];
+	unsigned int flags = breakpoints[curidx].flags;
+	
+	/* Disable breakpoint in DR7 */
+	sysarg_t dr7 = read_dr7();
+	dr7 &= ~(0x02U << (curidx * 2));
+	
+	/* Setup DR register */
+	if (cur->address) {
+		/* Set breakpoint to debug registers */
+		switch (curidx) {
+		case 0:
+			write_dr0(cur->address);
+			break;
+		case 1:
+			write_dr1(cur->address);
+			break;
+		case 2:
+			write_dr2(cur->address);
+			break;
+		case 3:
+			write_dr3(cur->address);
+			break;
+		}
+		
+		/* Set type to requested breakpoint & length*/
+		dr7 &= ~(0x03U << (16 + 4 * curidx));
+		dr7 &= ~(0x03U << (18 + 4 * curidx));
+		
+		if (!(flags & BKPOINT_INSTR)) {
+#ifdef __32_BITS__
+			dr7 |= ((sysarg_t) 0x03U) << (18 + 4 * curidx);
+#endif
+			
+#ifdef __64_BITS__
+			dr7 |= ((sysarg_t) 0x02U) << (18 + 4 * curidx);
+#endif
+			
+			if ((flags & BKPOINT_WRITE))
+				dr7 |= ((sysarg_t) 0x01U) << (16 + 4 * curidx);
+			else if ((flags & BKPOINT_READ_WRITE))
+				dr7 |= ((sysarg_t) 0x03U) << (16 + 4 * curidx);
+		}
+		
+		/* Enable global breakpoint */
+		dr7 |= 0x02U << (curidx * 2);
+		
+		write_dr7(dr7);
+	}
+}
+
+/** Enable hardware breakpoint
+ *
+ * @param where Address of HW breakpoint
+ * @param flags Type of breakpoint (EXECUTE, WRITE)
+ *
+ * @return Debug slot on success, -1 - no available HW breakpoint
+ *
+ */
+int breakpoint_add(const void *where, const unsigned int flags, int curidx)
+{
+	ASSERT(flags & (BKPOINT_INSTR | BKPOINT_WRITE | BKPOINT_READ_WRITE));
+	
+	irq_spinlock_lock(&bkpoint_lock, true);
+	
+	if (curidx == -1) {
+		/* Find free space in slots */
+		unsigned int i;
+		for (i = 0; i < BKPOINTS_MAX; i++) {
+			if (!breakpoints[i].address) {
+				curidx = i;
+				break;
+			}
+		}
+		
+		if (curidx == -1) {
+			/* Too many breakpoints */
+			irq_spinlock_unlock(&bkpoint_lock, true);
+			return -1;
+		}
+	}
+	
+	bpinfo_t *cur = &breakpoints[curidx];
+	
+	cur->address = (uintptr_t) where;
+	cur->flags = flags;
+	cur->counter = 0;
+	
+	setup_dr(curidx);
+	
+	irq_spinlock_unlock(&bkpoint_lock, true);
+	
+	/* Send IPI */
+//	ipi_broadcast(VECTOR_DEBUG_IPI);
+	
+	return curidx;
+}
+
+static void handle_exception(int slot, istate_t *istate)
+{
+	ASSERT(slot >= 0);
+	ASSERT(breakpoints[slot].address);
+	
+	/* Handle zero checker */
+	if (!(breakpoints[slot].flags & BKPOINT_INSTR)) {
+		if ((breakpoints[slot].flags & BKPOINT_CHECK_ZERO)) {
+			if (*((sysarg_t *) breakpoints[slot].address) != 0)
+				return;
+			
+			printf("*** Found ZERO on address %p (slot %d) ***\n",
+			    (void *) breakpoints[slot].address, slot);
+		} else {
+			printf("Data watchpoint - new data: %#" PRIxn "\n",
+			    *((sysarg_t *) breakpoints[slot].address));
+		}
+	}
+	
+	printf("Reached breakpoint %d:%p (%s)\n", slot,
+	    (void *) getip(istate), symtab_fmt_name_lookup(getip(istate)));
+	
+#ifdef CONFIG_KCONSOLE
+	atomic_set(&haltstate, 1);
+	kconsole("debug", "Debug console ready.\n", false);
+	atomic_set(&haltstate, 0);
+#endif
+}
+
+void breakpoint_del(int slot)
+{
+	ASSERT(slot >= 0);
+	
+	irq_spinlock_lock(&bkpoint_lock, true);
+	
+	bpinfo_t *cur = &breakpoints[slot];
+	if (!cur->address) {
+		irq_spinlock_unlock(&bkpoint_lock, true);
+		return;
+	}
+	
+	cur->address = (uintptr_t) NULL;
+	
+	setup_dr(slot);
+	
+	irq_spinlock_unlock(&bkpoint_lock, true);
+//	ipi_broadcast(VECTOR_DEBUG_IPI);
+}
+
+static void debug_exception(unsigned int n __attribute__((unused)), istate_t *istate)
+{
+	/* Set RF to restart the instruction  */
+#ifdef __64_BITS__
+	istate->rflags |= RFLAGS_RF;
+#endif
+	
+#ifdef __32_BITS__
+	istate->eflags |= EFLAGS_RF;
+#endif
+	
+	sysarg_t dr6 = read_dr6();
+	
+	unsigned int i;
+	for (i = 0; i < BKPOINTS_MAX; i++) {
+		if (dr6 & (1 << i)) {
+			dr6 &= ~ (1 << i);
+			write_dr6(dr6);
+			
+			handle_exception(i, istate);
+		}
+	}
+}
+
+#ifdef CONFIG_SMP
+static void debug_ipi(unsigned int n __attribute__((unused)),
+    istate_t *istate __attribute__((unused)))
+{
+	irq_spinlock_lock(&bkpoint_lock, false);
+	
+	unsigned int i;
+	for (i = 0; i < BKPOINTS_MAX; i++)
+		setup_dr(i);
+	
+	irq_spinlock_unlock(&bkpoint_lock, false);
+}
+#endif /* CONFIG_SMP */
+
+/** Initialize debugger
+ *
+ */
+void debugger_init()
+{
+	unsigned int i;
+	for (i = 0; i < BKPOINTS_MAX; i++)
+		breakpoints[i].address = (uintptr_t) NULL;
+	
+#ifdef CONFIG_KCONSOLE
+	cmd_initialize(&bkpts_info);
+	if (!cmd_register(&bkpts_info))
+		printf("Cannot register command %s\n", bkpts_info.name);
+	
+	cmd_initialize(&delbkpt_info);
+	if (!cmd_register(&delbkpt_info))
+		printf("Cannot register command %s\n", delbkpt_info.name);
+	
+	cmd_initialize(&addbkpt_info);
+	if (!cmd_register(&addbkpt_info))
+		printf("Cannot register command %s\n", addbkpt_info.name);
+	
+	cmd_initialize(&addwatchp_info);
+	if (!cmd_register(&addwatchp_info))
+		printf("Cannot register command %s\n", addwatchp_info.name);
+#endif /* CONFIG_KCONSOLE */
+	
+	exc_register(VECTOR_DEBUG, "debugger", true,
+	    debug_exception);
+	
+#ifdef CONFIG_SMP
+	exc_register(VECTOR_DEBUG_IPI, "debugger_smp", true,
+	    debug_ipi);
+#endif /* CONFIG_SMP */
+}
+
+#ifdef CONFIG_KCONSOLE
+/** Print table of active breakpoints
+ *
+ */
+int cmd_print_breakpoints(cmd_arg_t *argv __attribute__((unused)))
+{
+#ifdef __32_BITS__
+	printf("[nr] [count] [address ] [in symbol\n");
+#endif
+	
+#ifdef __64_BITS__
+	printf("[nr] [count] [address         ] [in symbol\n");
+#endif
+	
+	unsigned int i;
+	for (i = 0; i < BKPOINTS_MAX; i++) {
+		if (breakpoints[i].address) {
+			const char *symbol = symtab_fmt_name_lookup(
+			    breakpoints[i].address);
+			
+#ifdef __32_BITS__
+			printf("%-4u %7zu %p %s\n", i,
+			    breakpoints[i].counter, (void *) breakpoints[i].address,
+			    symbol);
+#endif
+			
+#ifdef __64_BITS__
+			printf("%-4u %7zu %p %s\n", i,
+			    breakpoints[i].counter, (void *) breakpoints[i].address,
+			    symbol);
+#endif
+		}
+	}
+	
+	return 1;
+}
+
+/** Remove breakpoint from table
+ *
+ */
+int cmd_del_breakpoint(cmd_arg_t *argv)
+{
+	sysarg_t bpno = argv->intval;
+	if (bpno > BKPOINTS_MAX) {
+		printf("Invalid breakpoint number.\n");
+		return 0;
+	}
+	
+	breakpoint_del(argv->intval);
+	return 1;
+}
+
+/** Add new breakpoint to table
+ *
+ */
+static int cmd_add_breakpoint(cmd_arg_t *argv)
+{
+	unsigned int flags;
+	if (argv == &add_argv)
+		flags = BKPOINT_INSTR;
+	else
+		flags = BKPOINT_WRITE;
+	
+	printf("Adding breakpoint on address: %p\n",
+	    (void *) argv->intval);
+	
+	int id = breakpoint_add((void *) argv->intval, flags, -1);
+	if (id < 0)
+		printf("Add breakpoint failed.\n");
+	else
+		printf("Added breakpoint %d.\n", id);
+	
+	return 1;
+}
+#endif /* CONFIG_KCONSOLE */
+
+/** @}
+ */
Index: kernel/arch/amd64/src/fpu_context.c
===================================================================
--- kernel/arch/amd64/src/fpu_context.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/amd64/src/fpu_context.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -57,6 +57,4 @@
 {
 	/* TODO: Zero all SSE, MMX etc. registers */
-	/* Default value of SCR register is 0x1f80,
-	 * it masks all FPU exceptions*/
 	asm volatile (
 		"fninit\n"
Index: kernel/arch/amd64/src/mm/page.c
===================================================================
--- kernel/arch/amd64/src/mm/page.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/amd64/src/mm/page.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -92,5 +92,8 @@
 		access = PF_ACCESS_READ;
 	
-	as_page_fault(page, access, istate);
+	if (as_page_fault(page, access, istate) == AS_PF_FAULT) {
+		fault_if_from_uspace(istate, "Page fault: %p.", (void *) page);
+		panic_memtrap(istate, access, page, NULL);
+	}
 }
 
Index: kernel/arch/arm32/Makefile.inc
===================================================================
--- kernel/arch/arm32/Makefile.inc	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/Makefile.inc	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,11 +33,5 @@
 ATSIGN = %
 
-GCC_CFLAGS += -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR_ARCH)) -mno-unaligned-access
-
-ifeq ($(CONFIG_FPU),y)
-# This is necessary to allow vmsr insn and fpexc manipulation
-# Use vfp32 to allow context save/restore of d16-d31 regs.
-AFLAGS += -mfloat-abi=hard -mfpu=vfp3
-endif
+GCC_CFLAGS += -march=armv4 -fno-omit-frame-pointer -mapcs-frame
 
 BITS = 32
@@ -68,11 +62,10 @@
 	arch/$(KARCH)/src/ras.c
 
-ifeq ($(CONFIG_FPU),y)
-	ARCH_SOURCES +=	arch/$(KARCH)/src/fpu_context.c
-	ARCH_SOURCES +=	arch/$(KARCH)/src/fpu.s
+ifeq ($(MACHINE),gta02)
+	ARCH_SOURCES += arch/$(KARCH)/src/mach/gta02/gta02.c
 endif
 
-ifeq ($(MACHINE),gta02)
-	ARCH_SOURCES += arch/$(KARCH)/src/mach/gta02/gta02.c
+ifeq ($(MACHINE),testarm)
+	ARCH_SOURCES += arch/$(KARCH)/src/mach/testarm/testarm.c
 endif
 
@@ -81,12 +74,4 @@
 endif
 
-ifeq ($(MACHINE),beagleboardxm)
-	ARCH_SOURCES += arch/$(KARCH)/src/mach/beagleboardxm/beagleboardxm.c
-endif
-
-ifeq ($(MACHINE),beaglebone)
-        ARCH_SOURCES += arch/$(KARCH)/src/mach/beaglebone/beaglebone.c
-endif
-
 ifeq ($(CONFIG_PL050),y)
 	ARCH_SOURCES += genarch/src/drivers/pl050/pl050.c
Index: kernel/arch/arm32/_link.ld.in
===================================================================
--- kernel/arch/arm32/_link.ld.in	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/_link.ld.in	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -9,8 +9,4 @@
 #ifdef MACHINE_gta02
 #define KERNEL_LOAD_ADDRESS 0xb0a08000
-#elif defined MACHINE_beagleboardxm
-#define KERNEL_LOAD_ADDRESS 0x80a00000
-#elif defined MACHINE_beaglebone
-#define KERNEL_LOAD_ADDRESS 0x80a00000
 #else
 #define KERNEL_LOAD_ADDRESS 0x80a00000
Index: kernel/arch/arm32/include/arch/asm.h
===================================================================
--- kernel/arch/arm32/include/arch/asm.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/asm.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -43,23 +43,7 @@
 #include <trace.h>
 
-/** CPU specific way to sleep cpu.
- *
- * ARMv7 introduced wait for event and wait for interrupt (wfe/wfi).
- * ARM920T has custom coprocessor action to do the same. See ARM920T Technical
- * Reference Manual ch 4.9 p. 4-23 (103 in the PDF)
- * ARM926EJ-S uses the same coprocessor instruction as ARM920T. See ARM926EJ-S
- * chapter 2.3.8 p.2-22 (52 in the PDF)
- *
- * @note Although mcr p15, 0, R0, c7, c0, 4 is defined in ARM Architecture
- * reference manual for armv4/5 CP15 implementation is mandatory only for
- * armv6+.
- */
+/** No such instruction on ARM to sleep CPU. */
 NO_TRACE static inline void cpu_sleep(void)
 {
-#ifdef PROCESSOR_ARCH_armv7_a
-	asm volatile ( "wfe" );
-#elif defined(PROCESSOR_ARCH_armv6) | defined(PROCESSOR_arm926ej_s) | defined(PROCESSOR_arm920t)
-	asm volatile ( "mcr p15, 0, R0, c7, c0, 4" );
-#endif
 }
 
Index: kernel/arch/arm32/include/arch/barrier.h
===================================================================
--- kernel/arch/arm32/include/arch/barrier.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/barrier.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,92 +37,16 @@
 #define KERN_arm32_BARRIER_H_
 
-#ifdef KERNEL
-#include <arch/cp15.h>
-#else
-#include <libarch/cp15.h>
-#endif
-
+/*
+ * TODO: implement true ARM memory barriers for macros below.
+ */
 #define CS_ENTER_BARRIER()  asm volatile ("" ::: "memory")
 #define CS_LEAVE_BARRIER()  asm volatile ("" ::: "memory")
 
-#if defined PROCESSOR_ARCH_armv7_a
-/* ARMv7 uses instructions for memory barriers see ARM Architecture reference
- * manual for details:
- * DMB: ch. A8.8.43 page A8-376
- * DSB: ch. A8.8.44 page A8-378
- * See ch. A3.8.3 page A3-148 for details about memory barrier implementation
- * and functionality on armv7 architecture.
- */
-#define memory_barrier()  asm volatile ("dmb" ::: "memory")
-#define read_barrier()    asm volatile ("dsb" ::: "memory")
-#define write_barrier()   asm volatile ("dsb st" ::: "memory")
-#define inst_barrier()    asm volatile ("isb" ::: "memory")
-#elif defined PROCESSOR_ARCH_armv6 | defined KERNEL
-/*
- * ARMv6 introduced user access of the following commands:
- * - Prefetch flush
- * - Data synchronization barrier
- * - Data memory barrier
- * - Clean and prefetch range operations.
- * ARM Architecture Reference Manual version I ch. B.3.2.1 p. B3-4
- */
-/* ARMv6- use system control coprocessor (CP15) for memory barrier instructions.
- * Although at least mcr p15, 0, r0, c7, c10, 4 is mentioned in earlier archs,
- * CP15 implementation is mandatory only for armv6+.
- */
-#define memory_barrier()  CP15DMB_write(0)
-#define read_barrier()    CP15DSB_write(0)
-#define write_barrier()   read_barrier()
-#define inst_barrier()    CP15ISB_write(0)
-#else
-/* Older manuals mention syscalls as a way to implement cache coherency and
- * barriers. See for example ARM Architecture Reference Manual Version D
- * chapter 2.7.4 Prefetching and self-modifying code (p. A2-28)
- */
-// TODO implement on per PROCESSOR basis or via syscalls
 #define memory_barrier()  asm volatile ("" ::: "memory")
 #define read_barrier()    asm volatile ("" ::: "memory")
 #define write_barrier()   asm volatile ("" ::: "memory")
-#define inst_barrier()    asm volatile ("" ::: "memory")
-#endif
 
-/*
- * There are multiple ways ICache can be implemented on ARM machines. Namely
- * PIPT, VIPT, and ASID and VMID tagged VIVT (see ARM Architecture Reference
- * Manual B3.11.2 (p. 1383).  However, CortexA8 Manual states: "For maximum
- * compatibility across processors, ARM recommends that operating systems target
- * the ARMv7 base architecture that uses ASID-tagged VIVT instruction caches,
- * and do not assume the presence of the IVIPT extension. Software that relies
- * on the IVIPT extension might fail in an unpredictable way on an ARMv7
- * implementation that does not include the IVIPT extension." (7.2.6 p. 245).
- * Only PIPT invalidates cache for all VA aliases if one block is invalidated.
- *
- * @note: Supporting ASID and VMID tagged VIVT may need to add ICache
- * maintenance to other places than just smc.
- */
-
-#if defined PROCESSOR_ARCH_armv7_a | defined PROCESSOR_ARCH_armv6 | defined KERNEL
-/* Available on all supported arms,
- * invalidates entire ICache so the written value does not matter. */
-//TODO might be PL1 only on armv5-
-#define smc_coherence(a) \
-do { \
-	DCCMVAU_write((uint32_t)(a));  /* Flush changed memory */\
-	write_barrier();               /* Wait for completion */\
-	ICIALLU_write(0);              /* Flush ICache */\
-	inst_barrier();                /* Wait for Inst refetch */\
-} while (0)
-/* @note: Cache type register is not available in uspace. We would need
- * to export the cache line value, or use syscall for uspace smc_coherence */
-#define smc_coherence_block(a, l) \
-do { \
-	for (uintptr_t addr = (uintptr_t)a; addr < (uintptr_t)a + l; addr += 4)\
-		smc_coherence(addr); \
-} while (0)
-#else
 #define smc_coherence(a)
 #define smc_coherence_block(a, l)
-#endif
-
 
 #endif
Index: rnel/arch/arm32/include/arch/cache.h
===================================================================
--- kernel/arch/arm32/include/arch/cache.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Copyright (c) 2013 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 arm32
- * @{
- */
-/** @file
- *  @brief Security Extensions Routines
- */
-
-#ifndef KERN_arm32_CACHE_H_
-#define KERN_arm32_CACHE_H_
-
-unsigned dcache_levels(void);
-
-void dcache_flush(void);
-void dcache_flush_invalidate(void);
-void cpu_dcache_flush(void);
-void cpu_dcache_flush_invalidate(void);
-void icache_invalidate(void);
-
-#endif
-/** @}
- */
-
Index: rnel/arch/arm32/include/arch/cp15.h
===================================================================
--- kernel/arch/arm32/include/arch/cp15.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,525 +1,0 @@
-/*
- * Copyright (c) 2013 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 arm32
- * @{
- */
-/** @file
- *  @brief System Control Coprocessor (CP15)
- */
-
-#ifndef KERN_arm32_CP15_H_
-#define KERN_arm32_CP15_H_
-
-
-/** See ARM Architecture reference manual ch. B3.17.1 page B3-1456
- * for the list */
-
-#define CONTROL_REG_GEN_READ(name, crn, opc1, crm, opc2) \
-static inline uint32_t name##_read() \
-{ \
-	uint32_t val; \
-	asm volatile ( "mrc p15, "#opc1", %0, "#crn", "#crm", "#opc2"\n" : "=r" (val) ); \
-	return val; \
-}
-#define CONTROL_REG_GEN_WRITE(name, crn, opc1, crm, opc2) \
-static inline void name##_write(uint32_t val) \
-{ \
-	asm volatile ( "mcr p15, "#opc1", %0, "#crn", "#crm", "#opc2"\n" :: "r" (val) ); \
-}
-
-/* Identification registers */
-enum {
-	MIDR_IMPLEMENTER_MASK = 0xff,
-	MIDR_IMPLEMENTER_SHIFT = 24,
-	MIDR_VARIANT_MASK = 0xf,
-	MIDR_VARIANT_SHIFT = 20,
-	MIDR_ARCHITECTURE_MASK = 0xf,
-	MIDR_ARCHITECTURE_SHIFT = 16,
-	MIDR_PART_NUMBER_MASK = 0xfff,
-	MIDR_PART_NUMBER_SHIFT = 4,
-	MIDR_REVISION_MASK = 0xf,
-	MIDR_REVISION_SHIFT = 0,
-};
-CONTROL_REG_GEN_READ(MIDR, c0, 0, c0, 0);
-
-enum {
-	CTR_FORMAT_MASK = 0xe0000000,
-	CTR_FORMAT_ARMv7 = 0x80000000,
-	CTR_FORMAT_ARMv6 = 0x00000000,
-	/* ARMv7 format */
-	CTR_CWG_MASK = 0xf,
-	CTR_CWG_SHIFT = 24,
-	CTR_ERG_MASK = 0xf,
-	CTR_ERG_SHIFT = 20,
-	CTR_D_MIN_LINE_MASK = 0xf,
-	CTR_D_MIN_LINE_SHIFT = 16,
-	CTR_I_MIN_LINE_MASK = 0xf,
-	CTR_I_MIN_LINE_SHIFT = 0,
-	CTR_L1I_POLICY_MASK = 0x0000c000,
-	CTR_L1I_POLICY_AIVIVT = 0x00004000,
-	CTR_L1I_POLICY_VIPT = 0x00008000,
-	CTR_L1I_POLICY_PIPT = 0x0000c000,
-	/* ARMv6 format */
-	CTR_CTYPE_MASK = 0x1e000000,
-	CTR_CTYPE_WT = 0x00000000,
-	CTR_CTYPE_WB_NL = 0x04000000,
-	CTR_CTYPE_WB_D = 0x0a000000,
-	CTR_CTYPE_WB_A = 0x0c000000, /**< ARMv5- only */
-	CTR_CTYPE_WB_B = 0x0e000000, /**< ARMv5- only */
-	CTR_CTYPE_WB_C = 0x1c000000,
-	CTR_SEP_FLAG = 1 << 24,
-	CTR_DCACHE_P_FLAG = 1 << 23,
-	CTR_DCACHE_SIZE_MASK = 0xf,
-	CTR_DCACHE_SIZE_SHIFT = 18,
-	CTR_DCACHE_ASSOC_MASK = 0x7,
-	CTR_DCACHE_ASSOC_SHIFT = 15,
-	CTR_DCACHE_M_FLAG = 1 << 14,
-	CTR_DCACHE_LEN_MASK = 0x3,
-	CTR_DCACHE_LEN_SHIFT = 0,
-	CTR_ICACHE_P_FLAG = 1 << 11,
-	CTR_ICACHE_SIZE_MASK = 0xf,
-	CTR_ICACHE_SIZE_SHIFT = 6,
-	CTR_ICACHE_ASSOC_MASK = 0x7,
-	CTR_ICACHE_ASSOC_SHIFT = 3,
-	CTR_ICACHE_M_FLAG = 1 << 2,
-	CTR_ICACHE_LEN_MASK = 0x3,
-	CTR_ICACHE_LEN_SHIFT = 0,
-};
-CONTROL_REG_GEN_READ(CTR, c0, 0, c0, 1);
-CONTROL_REG_GEN_READ(TCMR, c0, 0, c0, 2);
-CONTROL_REG_GEN_READ(TLBTR, c0, 0, c0, 3);
-CONTROL_REG_GEN_READ(MPIDR, c0, 0, c0, 5);
-CONTROL_REG_GEN_READ(REVIDR, c0, 0, c0, 6);
-
-enum {
-	ID_PFR0_THUMBEE_MASK = 0xf << 12,
-	ID_PFR0_THUMBEE = 0x1 << 12,
-	ID_PFR0_JAZELLE_MASK = 0xf << 8,
-	ID_PFR0_JAZELLE = 0x1 << 8,
-	ID_PFR0_JAZELLE_CV_CLEAR = 0x2 << 8,
-	ID_PFR0_THUMB_MASK = 0xf << 4,
-	ID_PFR0_THUMB = 0x1 << 4,
-	ID_PFR0_THUMB2 = 0x3 << 4,
-	ID_PFR0_ARM_MASK = 0xf << 0,
-	ID_PFR0_ARM = 0x1 << 0,
-};
-CONTROL_REG_GEN_READ(ID_PFR0, c0, 0, c1, 0);
-
-enum {
-	ID_PFR1_GEN_TIMER_EXT_MASK = 0xf << 16,
-	ID_PFR1_GEN_TIMER_EXT = 0x1 << 16,
-	ID_PFR1_VIRT_EXT_MASK = 0xf << 12,
-	ID_PFR1_VIRT_EXT = 0x1 << 12,
-	ID_PFR1_M_PROF_MASK = 0xf << 8,
-	ID_PFR1_M_PROF_MODEL = 0x2 << 8,
-	ID_PFR1_SEC_EXT_MASK = 0xf << 4,
-	ID_PFR1_SEC_EXT = 0x1 << 4,
-	ID_PFR1_SEC_EXT_RFR = 0x2 << 4,
-	ID_PFR1_ARMV4_MODEL_MASK = 0xf << 0,
-	ID_PFR1_ARMV4_MODEL = 0x1 << 0,
-};
-CONTROL_REG_GEN_READ(ID_PFR1, c0, 0, c1, 1);
-CONTROL_REG_GEN_READ(ID_DFR0, c0, 0, c1, 2);
-CONTROL_REG_GEN_READ(ID_AFR0, c0, 0, c1, 3);
-CONTROL_REG_GEN_READ(ID_MMFR0, c0, 0, c1, 4);
-CONTROL_REG_GEN_READ(ID_MMFR1, c0, 0, c1, 5);
-CONTROL_REG_GEN_READ(ID_MMFR2, c0, 0, c1, 6);
-CONTROL_REG_GEN_READ(ID_MMFR3, c0, 0, c1, 7);
-
-CONTROL_REG_GEN_READ(ID_ISAR0, c0, 0, c2, 0);
-CONTROL_REG_GEN_READ(ID_ISAR1, c0, 0, c2, 1);
-CONTROL_REG_GEN_READ(ID_ISAR2, c0, 0, c2, 2);
-CONTROL_REG_GEN_READ(ID_ISAR3, c0, 0, c2, 3);
-CONTROL_REG_GEN_READ(ID_ISAR4, c0, 0, c2, 4);
-CONTROL_REG_GEN_READ(ID_ISAR5, c0, 0, c2, 5);
-
-enum {
-	CCSIDR_WT_FLAG = 1 << 31,
-	CCSIDR_WB_FLAG = 1 << 30,
-	CCSIDR_RA_FLAG = 1 << 29,
-	CCSIDR_WA_FLAG = 1 << 28,
-	CCSIDR_NUMSETS_MASK = 0x7fff,
-	CCSIDR_NUMSETS_SHIFT = 13,
-	CCSIDR_ASSOC_MASK = 0x3ff,
-	CCSIDR_ASSOC_SHIFT = 3,
-	CCSIDR_LINESIZE_MASK = 0x7,
-	CCSIDR_LINESIZE_SHIFT = 0,
-};
-CONTROL_REG_GEN_READ(CCSIDR, c0, 1, c0, 0);
-
-enum {
-	CLIDR_LOUU_MASK = 0x7,
-	CLIDR_LOUU_SHIFT = 27,
-	CLIDR_LOC_MASK = 0x7,
-	CLIDR_LOC_SHIFT = 24,
-	CLIDR_LOUIS_MASK = 0x7,
-	CLIDR_LOUIS_SHIFT = 21,
-	CLIDR_NOCACHE = 0x0,
-	CLIDR_ICACHE_ONLY = 0x1,
-	CLIDR_DCACHE_ONLY = 0x2,
-	CLIDR_SEP_CACHE = 0x3,
-	CLIDR_UNI_CACHE = 0x4,
-	CLIDR_CACHE_MASK = 0x7,
-#define CLIDR_CACHE(level, val)   ((val >> (level - 1) * 3) & CLIDR_CACHE_MASK)
-};
-CONTROL_REG_GEN_READ(CLIDR, c0, 1, c0, 1);
-CONTROL_REG_GEN_READ(AIDR, c0, 1, c0, 7); /* Implementation defined or MIDR */
-
-enum {
-	CCSELR_LEVEL_MASK = 0x7,
-	CCSELR_LEVEL_SHIFT = 1,
-	CCSELR_INSTRUCTION_FLAG = 1 << 0,
-};
-CONTROL_REG_GEN_READ(CSSELR, c0, 2, c0, 0);
-CONTROL_REG_GEN_WRITE(CSSELR, c0, 2, c0, 0);
-CONTROL_REG_GEN_READ(VPIDR, c0, 4, c0, 0);
-CONTROL_REG_GEN_WRITE(VPIDR, c0, 4, c0, 0);
-CONTROL_REG_GEN_READ(VMPIDR, c0, 4, c0, 5);
-CONTROL_REG_GEN_WRITE(VMPIDR, c0, 4, c0, 5);
-
-/* System control registers */
-/* COntrol register bit values see ch. B4.1.130 of ARM Architecture Reference
- * Manual ARMv7-A and ARMv7-R edition, page 1687 */
-enum {
-	SCTLR_MMU_EN_FLAG            = 1 << 0,
-	SCTLR_ALIGN_CHECK_EN_FLAG    = 1 << 1,  /* Allow alignemnt check */
-	SCTLR_CACHE_EN_FLAG          = 1 << 2,
-	SCTLR_CP15_BARRIER_EN_FLAG   = 1 << 5,
-	SCTLR_B_EN_FLAG              = 1 << 7,  /* ARMv6-, big endian switch */
-	SCTLR_SWAP_EN_FLAG           = 1 << 10,
-	SCTLR_BRANCH_PREDICT_EN_FLAG = 1 << 11,
-	SCTLR_INST_CACHE_EN_FLAG     = 1 << 12,
-	SCTLR_HIGH_VECTORS_EN_FLAG   = 1 << 13,
-	SCTLR_ROUND_ROBIN_EN_FLAG    = 1 << 14,
-	SCTLR_HW_ACCESS_FLAG_EN_FLAG = 1 << 17,
-	SCTLR_WRITE_XN_EN_FLAG       = 1 << 19, /* Only if virt. supported */
-	SCTLR_USPCE_WRITE_XN_EN_FLAG = 1 << 20, /* Only if virt. supported */
-	SCTLR_FAST_IRQ_EN_FLAG       = 1 << 21, /* Disable impl. specific feat*/
-	SCTLR_UNALIGNED_EN_FLAG      = 1 << 22, /* Must be 1 on armv7 */
-	SCTLR_IRQ_VECTORS_EN_FLAG    = 1 << 24,
-	SCTLR_BIG_ENDIAN_EXC_FLAG    = 1 << 25,
-	SCTLR_NMFI_EN_FLAG           = 1 << 27,
-	SCTLR_TEX_REMAP_EN_FLAG      = 1 << 28,
-	SCTLR_ACCESS_FLAG_EN_FLAG    = 1 << 29,
-	SCTLR_THUMB_EXC_EN_FLAG      = 1 << 30,
-};
-CONTROL_REG_GEN_READ(SCTLR, c1, 0, c0, 0);
-CONTROL_REG_GEN_WRITE(SCTLR, c1, 0, c0, 0);
-CONTROL_REG_GEN_READ(ACTLR, c1, 0, c0, 1);
-CONTROL_REG_GEN_WRITE(ACTLR, c1, 0, c0, 1);
-
-enum {
-	CPACR_ASEDIS_FLAG = 1 << 31,
-	CPACR_D32DIS_FLAG = 1 << 30,
-	CPACR_TRCDIS_FLAG = 1 << 28,
-#define CPACR_CP_MASK(cp) (0x3 << (cp * 2))
-#define CPACR_CP_NO_ACCESS(cp) (0x0 << (cp * 2))
-#define CPACR_CP_PL1_ACCESS(cp) (0x1 << (cp * 2))
-#define CPACR_CP_FULL_ACCESS(cp) (0x3 << (cp * 2))
-};
-CONTROL_REG_GEN_READ(CPACR, c1, 0, c0, 2);
-CONTROL_REG_GEN_WRITE(CPACR, c1, 0, c0, 2);
-
-/* Implemented as part of Security extensions */
-enum {
-	SCR_SIF_FLAG = 1 << 9,
-	SCR_HCE_FLAG = 1 << 8,
-	SCR_SCD_FLAG = 1 << 7,
-	SCR_nET_FLAG = 1 << 6,
-	SCR_AW_FLAG = 1 << 5,
-	SCR_FW_FLAG = 1 << 4,
-	SCR_EA_FLAG = 1 << 3,
-	SCR_FIQ_FLAG = 1 << 2,
-	SCR_IRQ_FLAG = 1 << 1,
-	SCR_NS_FLAG = 1 << 0,
-};
-CONTROL_REG_GEN_READ(SCR, c1, 0, c1, 0);
-CONTROL_REG_GEN_WRITE(SCR, c1, 0, c1, 0);
-CONTROL_REG_GEN_READ(SDER, c1, 0, c1, 1);
-CONTROL_REG_GEN_WRITE(SDER, c1, 0, c1, 1);
-
-enum {
-	NSACR_NSTRCDIS_FLAG = 1 << 20,
-	NSACR_RFR_FLAG = 1 << 19,
-	NSACR_NSASEDIS = 1 << 15,
-	NSACR_NSD32DIS = 1 << 14,
-#define NSACR_CP_FLAG(cp) (1 << cp)
-};
-CONTROL_REG_GEN_READ(NSACR, c1, 0, c1, 2);
-CONTROL_REG_GEN_WRITE(NSACR, c1, 0, c1, 2);
-
-/* Implemented as part of Virtualization extensions */
-CONTROL_REG_GEN_READ(HSCTLR, c1, 4, c0, 0);
-CONTROL_REG_GEN_WRITE(HSCTLR, c1, 4, c0, 0);
-CONTROL_REG_GEN_READ(HACTLR, c1, 4, c0, 1);
-CONTROL_REG_GEN_WRITE(HACTLR, c1, 4, c0, 1);
-
-CONTROL_REG_GEN_READ(HCR, c1, 4, c1, 0);
-CONTROL_REG_GEN_WRITE(HCR, c1, 4, c1, 0);
-CONTROL_REG_GEN_READ(HDCR, c1, 4, c1, 1);
-CONTROL_REG_GEN_WRITE(HDCR, c1, 4, c1, 1);
-CONTROL_REG_GEN_READ(HCPTR, c1, 4, c1, 2);
-CONTROL_REG_GEN_WRITE(HCPTR, c1, 4, c1, 2);
-CONTROL_REG_GEN_READ(HSTR, c1, 4, c1, 3);
-CONTROL_REG_GEN_WRITE(HSTR, c1, 4, c1, 3);
-CONTROL_REG_GEN_READ(HACR, c1, 4, c1, 7);
-CONTROL_REG_GEN_WRITE(HACR, c1, 4, c1, 7);
-
-/* Memory protection and control registers */
-CONTROL_REG_GEN_READ(TTBR0, c2, 0, c0, 0);
-CONTROL_REG_GEN_WRITE(TTBR0, c2, 0, c0, 0);
-CONTROL_REG_GEN_READ(TTBR1, c2, 0, c0, 1);
-CONTROL_REG_GEN_WRITE(TTBR1, c2, 0, c0, 1);
-CONTROL_REG_GEN_READ(TTBCR, c2, 0, c0, 2);
-CONTROL_REG_GEN_WRITE(TTBCR, c2, 0, c0, 2);
-
-CONTROL_REG_GEN_READ(HTCR, c2, 4, c0, 2);
-CONTROL_REG_GEN_WRITE(HTCR, c2, 4, c0, 2);
-CONTROL_REG_GEN_READ(VTCR, c2, 4, c1, 2);
-CONTROL_REG_GEN_WRITE(VTCR, c2, 4, c1, 2);
-
-/* PAE */
-CONTROL_REG_GEN_READ(TTBR0H, c2, 0, c2, 0);
-CONTROL_REG_GEN_WRITE(TTBR0H, c2, 0, c2, 0);
-CONTROL_REG_GEN_READ(TTBR1H, c2, 0, c2, 1);
-CONTROL_REG_GEN_WRITE(TTBR1H, c2, 0, c2, 1);
-CONTROL_REG_GEN_READ(HTTBRH, c2, 0, c2, 4);
-CONTROL_REG_GEN_WRITE(HTTBRH, c2, 0, c2, 4);
-CONTROL_REG_GEN_READ(VTTBRH, c2, 0, c2, 6);
-CONTROL_REG_GEN_WRITE(VTTBRH, c2, 0, c2, 6);
-
-CONTROL_REG_GEN_READ(DACR, c3, 0, c0, 0);
-CONTROL_REG_GEN_WRITE(DACR, c3, 0, c0, 0);
-
-/* Memory system fault registers */
-CONTROL_REG_GEN_READ(DFSR, c5, 0, c0, 0);
-CONTROL_REG_GEN_WRITE(DFSR, c5, 0, c0, 0);
-CONTROL_REG_GEN_READ(IFSR, c5, 0, c0, 1);
-CONTROL_REG_GEN_WRITE(IFSR, c5, 0, c0, 1);
-
-CONTROL_REG_GEN_READ(ADFSR, c5, 0, c1, 0);
-CONTROL_REG_GEN_WRITE(ADFSR, c5, 0, c1, 0);
-CONTROL_REG_GEN_READ(AIFSR, c5, 0, c1, 1);
-CONTROL_REG_GEN_WRITE(AIFSR, c5, 0, c1, 1);
-
-CONTROL_REG_GEN_READ(HADFSR, c5, 4, c1, 0);
-CONTROL_REG_GEN_WRITE(HADFSR, c5, 4, c1, 0);
-CONTROL_REG_GEN_READ(HAIFSR, c5, 4, c1, 1);
-CONTROL_REG_GEN_WRITE(HAIFSR, c5, 4, c1, 1);
-CONTROL_REG_GEN_READ(HSR, c5, 4, c2, 0);
-CONTROL_REG_GEN_WRITE(HSR, c5, 4, c2, 0);
-
-CONTROL_REG_GEN_READ(DFAR, c6, 0, c0, 0);
-CONTROL_REG_GEN_WRITE(DFAR, c6, 0, c0, 0);
-CONTROL_REG_GEN_READ(IFAR, c6, 0, c0, 2);
-CONTROL_REG_GEN_WRITE(IFAR, c6, 0, c0, 2);
-
-CONTROL_REG_GEN_READ(HDFAR, c6, 4, c0, 0);
-CONTROL_REG_GEN_WRITE(HDFAR, c6, 4, c0, 0);
-CONTROL_REG_GEN_READ(HIFAR, c6, 4, c0, 2);
-CONTROL_REG_GEN_WRITE(HIFAR, c6, 4, c0, 2);
-CONTROL_REG_GEN_READ(HPFAR, c6, 4, c0, 4);
-CONTROL_REG_GEN_WRITE(HPFAR, c6, 4, c0, 4);
-
-/* Cache maintenance, address translation and other */
-CONTROL_REG_GEN_WRITE(WFI, c7, 0, c0, 4); /* armv6 only */
-CONTROL_REG_GEN_WRITE(ICIALLLUIS, c7, 0, c1, 0);
-CONTROL_REG_GEN_WRITE(BPIALLIS, c7, 0, c1, 6);
-CONTROL_REG_GEN_READ(PAR, c7, 0, c4, 0);
-CONTROL_REG_GEN_WRITE(PAR, c7, 0, c4, 0);
-CONTROL_REG_GEN_READ(PARH, c7, 0, c7, 0);   /* PAE */
-CONTROL_REG_GEN_WRITE(PARH, c7, 0, c7, 0);   /* PAE */
-CONTROL_REG_GEN_WRITE(ICIALLU, c7, 0, c5, 0);
-CONTROL_REG_GEN_WRITE(ICIMVAU, c7, 0, c5, 1);
-CONTROL_REG_GEN_WRITE(CP15ISB, c7, 0, c5, 4);
-CONTROL_REG_GEN_WRITE(BPIALL, c7, 0, c5, 6);
-CONTROL_REG_GEN_WRITE(BPIMVA, c7, 0, c5, 7);
-
-CONTROL_REG_GEN_WRITE(DCIMVAC, c7, 0, c6, 1);
-CONTROL_REG_GEN_WRITE(DCIMSW, c7, 0, c6, 2);
-
-CONTROL_REG_GEN_WRITE(ATS1CPR, c7, 0, c8, 0);
-CONTROL_REG_GEN_WRITE(ATS1CPW, c7, 0, c8, 1);
-CONTROL_REG_GEN_WRITE(ATS1CUR, c7, 0, c8, 2);
-CONTROL_REG_GEN_WRITE(ATS1CUW, c7, 0, c8, 3);
-CONTROL_REG_GEN_WRITE(ATS1NSOPR, c7, 0, c8, 4);
-CONTROL_REG_GEN_WRITE(ATS1NSOPW, c7, 0, c8, 5);
-CONTROL_REG_GEN_WRITE(ATS1NSOUR, c7, 0, c8, 6);
-CONTROL_REG_GEN_WRITE(ATS1NSOUW, c7, 0, c8, 7);
-
-
-CONTROL_REG_GEN_WRITE(DCCMVAC, c7, 0, c10, 1);
-CONTROL_REG_GEN_WRITE(DCCSW, c7, 0, c10, 2);
-CONTROL_REG_GEN_WRITE(CP15DSB, c7, 0, c10, 4);
-CONTROL_REG_GEN_WRITE(CP15DMB, c7, 0, c10, 5);
-CONTROL_REG_GEN_WRITE(DCCMVAU, c7, 0, c11, 1);
-
-CONTROL_REG_GEN_WRITE(PFI, c7, 0, c11, 1); /* armv6 only */
-
-CONTROL_REG_GEN_WRITE(DCCIMVAC, c7, 0, c14, 1);
-CONTROL_REG_GEN_WRITE(DCCISW, c7, 0, c14, 2);
-
-CONTROL_REG_GEN_WRITE(ATS1HR, c7, 4, c8, 0);
-CONTROL_REG_GEN_WRITE(ATS1HW, c7, 4, c8, 1);
-
-/* TLB maintenance */
-CONTROL_REG_GEN_WRITE(TLBIALLIS, c8, 0, c3, 0); /* Inner shareable */
-CONTROL_REG_GEN_WRITE(TLBIMVAIS, c8, 0, c3, 1); /* Inner shareable */
-CONTROL_REG_GEN_WRITE(TLBIASIDIS, c8, 0, c3, 2); /* Inner shareable */
-CONTROL_REG_GEN_WRITE(TLBIMVAAIS, c8, 0, c3, 3); /* Inner shareable */
-
-CONTROL_REG_GEN_WRITE(ITLBIALL, c8, 0, c5, 0);
-CONTROL_REG_GEN_WRITE(ITLBIMVA, c8, 0, c5, 1);
-CONTROL_REG_GEN_WRITE(ITLBIASID, c8, 0, c5, 2);
-
-CONTROL_REG_GEN_WRITE(DTLBIALL, c8, 0, c6, 0);
-CONTROL_REG_GEN_WRITE(DTLBIMVA, c8, 0, c6, 1);
-CONTROL_REG_GEN_WRITE(DTLBIASID, c8, 0, c6, 2);
-
-CONTROL_REG_GEN_WRITE(TLBIALL, c8, 0, c7, 0);
-CONTROL_REG_GEN_WRITE(TLBIMVA, c8, 0, c7, 1);
-CONTROL_REG_GEN_WRITE(TLBIASID, c8, 0, c7, 2);
-CONTROL_REG_GEN_WRITE(TLBIMVAA, c8, 0, c7, 3);
-
-CONTROL_REG_GEN_WRITE(TLBIALLHIS, c8, 4, c3, 0); /* Inner shareable */
-CONTROL_REG_GEN_WRITE(TLBIMVAHIS, c8, 4, c3, 1); /* Inner shareable */
-CONTROL_REG_GEN_WRITE(TLBIALLNSNHIS, c8, 4, c3, 4); /* Inner shareable */
-
-CONTROL_REG_GEN_WRITE(TLBIALLH, c8, 4, c7, 0);
-CONTROL_REG_GEN_WRITE(TLBIMVAH, c8, 4, c7, 1);
-CONTROL_REG_GEN_WRITE(TLBIALLNSNHS, c8, 4, c7, 4);
-
-/* c9 are performance monitoring resgisters */
-enum {
-	PMCR_IMP_MASK = 0xff,
-	PMCR_IMP_SHIFT = 24,
-	PMCR_IDCODE_MASK = 0xff,
-	PMCR_IDCODE_SHIFT = 16,
-	PMCR_EVENT_NUM_MASK = 0x1f,
-	PMCR_EVENT_NUM_SHIFT = 11,
-	PMCR_DP_FLAG = 1 << 5,
-	PMCR_X_FLAG = 1 << 4,
-	PMCR_D_FLAG = 1 << 3,
-	PMCR_C_FLAG = 1 << 2,
-	PMCR_P_FLAG = 1 << 1,
-	PMCR_E_FLAG = 1 << 0,
-};
-CONTROL_REG_GEN_READ(PMCR, c9, 0, c12, 0);
-CONTROL_REG_GEN_WRITE(PMCR, c9, 0, c12, 0);
-enum {
-	PMCNTENSET_CYCLE_COUNTER_EN_FLAG = 1 << 31,
-#define PMCNTENSET_COUNTER_EN_FLAG(c)   (1 << c)
-};
-CONTROL_REG_GEN_READ(PMCNTENSET, c9, 0, c12, 1);
-CONTROL_REG_GEN_WRITE(PMCNTENSET, c9, 0, c12, 1);
-CONTROL_REG_GEN_READ(PMCCNTR, c9, 0, c13, 0);
-CONTROL_REG_GEN_WRITE(PMCCNTR, c9, 0, c13, 0);
-
-
-/*c10 has tons of reserved too */
-CONTROL_REG_GEN_READ(PRRR, c10, 0, c2, 0); /* no PAE */
-CONTROL_REG_GEN_WRITE(PRRR, c10, 0, c2, 0); /* no PAE */
-CONTROL_REG_GEN_READ(MAIR0, c10, 0, c2, 0); /* PAE */
-CONTROL_REG_GEN_WRITE(MAIR0, c10, 0, c2, 0); /* PAE */
-CONTROL_REG_GEN_READ(NMRR, c10, 0, c2, 1); /* no PAE */
-CONTROL_REG_GEN_WRITE(NMRR, c10, 0, c2, 1); /* no PAE */
-CONTROL_REG_GEN_READ(MAIR1, c10, 0, c2, 1); /* PAE */
-CONTROL_REG_GEN_WRITE(MAIR1, c10, 0, c2, 1); /* PAE */
-
-CONTROL_REG_GEN_READ(AMAIR0, c10, 0, c3, 0); /* PAE */
-CONTROL_REG_GEN_WRITE(AMAIR0, c10, 0, c3, 0); /* PAE */
-CONTROL_REG_GEN_READ(AMAIR1, c10, 0, c3, 1); /* PAE */
-CONTROL_REG_GEN_WRITE(AMAIR1, c10, 0, c3, 1); /* PAE */
-
-CONTROL_REG_GEN_READ(HMAIR0, c10, 4, c2, 0);
-CONTROL_REG_GEN_WRITE(HMAIR0, c10, 4, c2, 0);
-CONTROL_REG_GEN_READ(HMAIR1, c10, 4, c2, 1);
-CONTROL_REG_GEN_WRITE(HMAIR1, c10, 4, c2, 1);
-
-CONTROL_REG_GEN_READ(HAMAIR0, c10, 4, c3, 0);
-CONTROL_REG_GEN_WRITE(HAMAIR0, c10, 4, c3, 0);
-CONTROL_REG_GEN_READ(HAMAIR1, c10, 4, c3, 1);
-CONTROL_REG_GEN_WRITE(HAMAIR1, c10, 4, c3, 1);
-
-/* c11 is reserved for TCM and DMA */
-
-/* Security extensions */
-CONTROL_REG_GEN_READ(VBAR, c12, 0, c0, 0);
-CONTROL_REG_GEN_WRITE(VBAR, c12, 0, c0, 0);
-CONTROL_REG_GEN_READ(MVBAR, c12, 0, c0, 1);
-CONTROL_REG_GEN_WRITE(MVBAR, c12, 0, c0, 1);
-
-CONTROL_REG_GEN_READ(ISR, c12, 0, c1, 0);
-
-CONTROL_REG_GEN_READ(HVBAR, c12, 4, c0, 0);
-CONTROL_REG_GEN_WRITE(HVBAR, c12, 4, c0, 0);
-
-/* Process context and thread id (FCSE) */
-CONTROL_REG_GEN_READ(FCSEIDR, c13, 0, c0, 0);
-
-CONTROL_REG_GEN_READ(CONTEXTIDR, c13, 0, c0, 1);
-CONTROL_REG_GEN_WRITE(CONTEXTIDR, c13, 0, c0, 1);
-CONTROL_REG_GEN_READ(TPIDRURW, c13, 0, c0, 2);
-CONTROL_REG_GEN_WRITE(TPIDRURW, c13, 0, c0, 2);
-CONTROL_REG_GEN_READ(TPIDRURO, c13, 0, c0, 3);
-CONTROL_REG_GEN_WRITE(TPIDRURO, c13, 0, c0, 3);
-CONTROL_REG_GEN_READ(TPIDRPRW, c13, 0, c0, 4);
-CONTROL_REG_GEN_WRITE(TPIDRPRW, c13, 0, c0, 4);
-
-CONTROL_REG_GEN_READ(HTPIDR, c13, 4, c0, 2);
-CONTROL_REG_GEN_WRITE(HTPIDR, c13, 4, c0, 2);
-
-/* Generic Timer Extensions */
-CONTROL_REG_GEN_READ(CNTFRQ, c14, 0, c0, 0);
-CONTROL_REG_GEN_WRITE(CNTFRQ, c14, 0, c0, 0);
-CONTROL_REG_GEN_READ(CNTKCTL, c14, 0, c1, 0);
-CONTROL_REG_GEN_WRITE(CNTKCTL, c14, 0, c1, 0);
-
-CONTROL_REG_GEN_READ(CNTP_TVAL, c14, 0, c2, 0);
-CONTROL_REG_GEN_WRITE(CNTP_TVAL, c14, 0, c2, 0);
-CONTROL_REG_GEN_READ(CNTP_CTL, c14, 0, c2, 1);
-CONTROL_REG_GEN_WRITE(CNTP_CTL, c14, 0, c2, 1);
-
-CONTROL_REG_GEN_READ(CNTV_TVAL, c14, 0, c3, 0);
-CONTROL_REG_GEN_WRITE(CNTV_TVAL, c14, 0, c3, 0);
-CONTROL_REG_GEN_READ(CNTV_CTL, c14, 0, c3, 1);
-CONTROL_REG_GEN_WRITE(CNTV_CTL, c14, 0, c3, 1);
-
-CONTROL_REG_GEN_READ(CNTHCTL, c14, 4, c1, 0);
-CONTROL_REG_GEN_WRITE(CNTHCTL, c14, 4, c1, 0);
-
-CONTROL_REG_GEN_READ(CNTHP_TVAL, c14, 4, c2, 0);
-CONTROL_REG_GEN_WRITE(CNTHP_TVAL, c14, 4, c2, 0);
-CONTROL_REG_GEN_READ(CNTHP_CTL, c14, 4, c2, 1);
-CONTROL_REG_GEN_WRITE(CNTHP_CTL, c14, 4, c2, 1);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/arm32/include/arch/cpu.h
===================================================================
--- kernel/arch/arm32/include/arch/cpu.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/cpu.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,11 +40,8 @@
 #include <arch/asm.h>
 
-enum {
-	ARM_MAX_CACHE_LEVELS = 7,
-};
 
-/** Struct representing ARM CPU identification. */
+/** Struct representing ARM CPU identifiaction. */
 typedef struct {
-	/** Implementor (vendor) number. */
+	/** Implementator (vendor) number. */
 	uint32_t imp_num;
 
@@ -60,13 +57,4 @@
 	/** Revision number. */
 	uint32_t rev_num;
-
-	struct {
-		unsigned ways;
-		unsigned sets;
-		unsigned line_size;
-		unsigned way_shift;
-		unsigned set_shift;
-	} dcache[ARM_MAX_CACHE_LEVELS];
-	unsigned dcache_levels;
 } cpu_arch_t;
 
Index: kernel/arch/arm32/include/arch/cycle.h
===================================================================
--- kernel/arch/arm32/include/arch/cycle.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/cycle.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,4 @@
 
 #include <trace.h>
-#include <arch/cp15.h>
 
 /** Return count of CPU cycles.
@@ -49,14 +48,4 @@
 NO_TRACE static inline uint64_t get_cycle(void)
 {
-#ifdef PROCESSOR_ARCH_armv7_a
-	if ((ID_PFR1_read() & ID_PFR1_GEN_TIMER_EXT_MASK) ==
-	    ID_PFR1_GEN_TIMER_EXT) {
-	    uint32_t low = 0, high = 0;
-	    asm volatile( "MRRC p15, 0, %[low], %[high], c14": [low]"=r"(low), [high]"=r"(high));
-	   return ((uint64_t)high << 32) | low;
-	} else {
-		return (uint64_t)PMCCNTR_read() * 64;
-	}
-#endif
 	return 0;
 }
Index: kernel/arch/arm32/include/arch/fpu_context.h
===================================================================
--- kernel/arch/arm32/include/arch/fpu_context.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/fpu_context.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -31,5 +31,7 @@
  */
 /** @file
- *  @brief FPU context.
+ *  @brief FPU context (not implemented).
+ *
+ *  GXemul doesn't support FPU on its ARM CPU.
  */
 
@@ -39,17 +41,8 @@
 #include <typedefs.h>
 
-#define FPU_CONTEXT_ALIGN    8
+#define FPU_CONTEXT_ALIGN    0
 
-/* ARM Architecture reference manual, p B-1529.
- */
 typedef struct {
-	uint32_t fpexc;
-	uint32_t fpscr;
-	uint32_t s[64];
 } fpu_context_t;
-
-void fpu_setup(void);
-
-bool handle_if_fpu_exception(void);
 
 #endif
Index: rnel/arch/arm32/include/arch/mach/beagleboardxm/beagleboardxm.h
===================================================================
--- kernel/arch/arm32/include/arch/mach/beagleboardxm/beagleboardxm.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,48 +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 arm32beagleboardxm beagleboardxm
- *  @brief BeagleBoard-xM platform.
- *  @ingroup arm32
- * @{
- */
-/** @file
- *  @brief BeagleBoard platform driver.
- */
-
-#ifndef KERN_arm32_beagleboardxm_H_
-#define KERN_arm32_beagleboardxm_H_
-
-#include <arch/machine_func.h>
-
-extern struct arm_machine_ops bbxm_machine_ops;
-
-#endif
-
-/** @}
- */
-
Index: rnel/arch/arm32/include/arch/mach/beaglebone/beaglebone.h
===================================================================
--- kernel/arch/arm32/include/arch/mach/beaglebone/beaglebone.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2012 Matteo Facchinetti
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 arm32beaglebone beaglebone
- *  @brief BeagleBone platform.
- *  @ingroup arm32
- * @{
- */
-/** @file
- *  @brief BeagleBone platform driver.
- */
-
-#ifndef KERN_arm32_beaglebone_H_
-#define KERN_arm32_beaglebone_H_
-
-#include <arch/machine_func.h>
-
-extern struct arm_machine_ops bbone_machine_ops;
-
-#endif
-
-/** @}
- */
-
Index: kernel/arch/arm32/include/arch/mach/testarm/testarm.h
===================================================================
--- kernel/arch/arm32/include/arch/mach/testarm/testarm.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ kernel/arch/arm32/include/arch/mach/testarm/testarm.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2007 Michal Kebrt
+ * Copyright (c) 2009 Vineeth Pillai
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 arm32gxemul GXemul
+ *  @brief GXemul machine specific parts.
+ *  @ingroup arm32
+ * @{
+ */
+/** @file
+ *  @brief GXemul peripheries drivers declarations.
+ */
+
+#ifndef KERN_arm32_testarm_H_
+#define KERN_arm32_testarm_H_
+
+#include <arch/machine_func.h>
+
+/** Size of GXemul IRQ number range (starting from 0) */
+#define GXEMUL_IRQ_COUNT	32
+#define GXEMUL_KBD_IRQ		2
+#define GXEMUL_TIMER_IRQ	4
+
+/** Timer frequency */
+#define GXEMUL_TIMER_FREQ  100
+
+#define GXEMUL_KBD_ADDRESS   0x10000000
+#define GXEMUL_MP_ADDRESS    0x11000000
+#define GXEMUL_FB_ADDRESS    0x12000000
+#define GXEMUL_RTC_ADDRESS   0x15000000
+#define GXEMUL_IRQC_ADDRESS  0x16000000
+
+extern void *gxemul_kbd;
+extern void *gxemul_rtc;
+extern void *gxemul_irqc;
+
+#define GXEMUL_HALT_OFFSET        0x010
+#define GXEMUL_RTC_FREQ_OFFSET    0x100
+#define GXEMUL_MP_MEMSIZE_OFFSET  0x090
+#define GXEMUL_RTC_ACK_OFFSET     0x110
+
+extern void gxemul_init(void);
+extern void gxemul_output_init(void);
+extern void gxemul_input_init(void);
+extern void gxemul_timer_irq_start(void);
+extern void gxemul_cpu_halt(void);
+extern void gxemul_irq_exception(unsigned int, istate_t *);
+extern void gxemul_get_memory_extents(uintptr_t *, size_t *);
+extern void gxemul_frame_init(void);
+extern size_t gxemul_get_irq_count(void);
+extern const char *gxemul_get_platform_name(void);
+
+extern struct arm_machine_ops gxemul_machine_ops;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/arm32/include/arch/machine_func.h
===================================================================
--- kernel/arch/arm32/include/arch/machine_func.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/machine_func.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -108,6 +108,4 @@
 extern size_t machine_get_irq_count(void);
 
-extern const char * machine_get_platform_name(void);
-
 #endif
 
Index: kernel/arch/arm32/include/arch/mm/frame.h
===================================================================
--- kernel/arch/arm32/include/arch/mm/frame.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/mm/frame.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -47,27 +47,17 @@
 
 #ifdef MACHINE_gta02
-
-#define PHYSMEM_START_ADDR       0x30008000
 #define BOOT_PAGE_TABLE_ADDRESS  0x30010000
-
-#elif defined MACHINE_beagleboardxm
-
-#define PHYSMEM_START_ADDR       0x80000000
-#define BOOT_PAGE_TABLE_ADDRESS  0x80008000
-
-#elif defined MACHINE_beaglebone
-
-#define PHYSMEM_START_ADDR       0x80000000
-#define BOOT_PAGE_TABLE_ADDRESS  0x80008000
-
 #else
-
-#define PHYSMEM_START_ADDR       0x00000000
 #define BOOT_PAGE_TABLE_ADDRESS  0x00008000
-
 #endif
 
 #define BOOT_PAGE_TABLE_START_FRAME     (BOOT_PAGE_TABLE_ADDRESS >> FRAME_WIDTH)
 #define BOOT_PAGE_TABLE_SIZE_IN_FRAMES  (BOOT_PAGE_TABLE_SIZE >> FRAME_WIDTH)
+
+#ifdef MACHINE_gta02
+#define PHYSMEM_START_ADDR	0x30008000
+#else
+#define PHYSMEM_START_ADDR	0x00000000
+#endif
 
 extern void frame_low_arch_init(void);
Index: kernel/arch/arm32/include/arch/mm/page.h
===================================================================
--- kernel/arch/arm32/include/arch/mm/page.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/mm/page.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -46,13 +46,4 @@
 #define PAGE_SIZE	FRAME_SIZE
 
-#if (defined MACHINE_beagleboardxm) || (defined MACHINE_beaglebone)
-#ifndef __ASM__
-#	define KA2PA(x)	((uintptr_t) (x))
-#	define PA2KA(x)	((uintptr_t) (x))
-#else
-#	define KA2PA(x)	(x)
-#	define PA2KA(x)	(x)
-#endif
-#else
 #ifndef __ASM__
 #	define KA2PA(x)	(((uintptr_t) (x)) - 0x80000000)
@@ -62,58 +53,57 @@
 #	define PA2KA(x)	((x) + 0x80000000)
 #endif
-#endif
 
 /* Number of entries in each level. */
-#define PTL0_ENTRIES_ARCH       (1 << 12)       /* 4096 */
-#define PTL1_ENTRIES_ARCH       0
-#define PTL2_ENTRIES_ARCH       0
+#define PTL0_ENTRIES_ARCH 	(1 << 12)	/* 4096 */
+#define PTL1_ENTRIES_ARCH 	0
+#define PTL2_ENTRIES_ARCH 	0
 /* coarse page tables used (256 * 4 = 1KB per page) */
-#define PTL3_ENTRIES_ARCH       (1 << 8)        /* 256 */
+#define PTL3_ENTRIES_ARCH 	(1 << 8)	/* 256 */
 
 /* Page table sizes for each level. */
-#define PTL0_SIZE_ARCH          FOUR_FRAMES
-#define PTL1_SIZE_ARCH          0
-#define PTL2_SIZE_ARCH          0
-#define PTL3_SIZE_ARCH          ONE_FRAME
+#define PTL0_SIZE_ARCH 		FOUR_FRAMES
+#define PTL1_SIZE_ARCH 		0
+#define PTL2_SIZE_ARCH 		0
+#define PTL3_SIZE_ARCH 		ONE_FRAME
 
 /* Macros calculating indices into page tables for each level. */
-#define PTL0_INDEX_ARCH(vaddr)  (((vaddr) >> 20) & 0xfff)
-#define PTL1_INDEX_ARCH(vaddr)  0
-#define PTL2_INDEX_ARCH(vaddr)  0
-#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 12) & 0x0ff)
+#define PTL0_INDEX_ARCH(vaddr) 	(((vaddr) >> 20) & 0xfff)
+#define PTL1_INDEX_ARCH(vaddr) 	0
+#define PTL2_INDEX_ARCH(vaddr) 	0
+#define PTL3_INDEX_ARCH(vaddr) 	(((vaddr) >> 12) & 0x0ff)
 
 /* Get PTE address accessors for each level. */
 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) \
-        ((pte_t *) ((((pte_t *)(ptl0))[(i)].l0).coarse_table_addr << 10))
+	((pte_t *) ((((pte_t *)(ptl0))[(i)].l0).coarse_table_addr << 10))
 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) \
-        (ptl1)
+	(ptl1)
 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) \
-        (ptl2)
+	(ptl2)
 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) \
-        ((uintptr_t) ((((pte_t *)(ptl3))[(i)].l1).frame_base_addr << 12))
+	((uintptr_t) ((((pte_t *)(ptl3))[(i)].l1).frame_base_addr << 12))
 
 /* Set PTE address accessors for each level. */
 #define SET_PTL0_ADDRESS_ARCH(ptl0) \
-        (set_ptl0_addr((pte_t *) (ptl0)))
+	(set_ptl0_addr((pte_t *) (ptl0)))
 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \
-        (((pte_t *) (ptl0))[(i)].l0.coarse_table_addr = (a) >> 10)
+	(((pte_t *) (ptl0))[(i)].l0.coarse_table_addr = (a) >> 10)
 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \
-        (((pte_t *) (ptl3))[(i)].l1.frame_base_addr = (a) >> 12)
+	(((pte_t *) (ptl3))[(i)].l1.frame_base_addr = (a) >> 12)
 
 /* Get PTE flags accessors for each level. */
 #define GET_PTL1_FLAGS_ARCH(ptl0, i) \
-        get_pt_level0_flags((pte_t *) (ptl0), (size_t) (i))
+	get_pt_level0_flags((pte_t *) (ptl0), (size_t) (i))
 #define GET_PTL2_FLAGS_ARCH(ptl1, i) \
-        PAGE_PRESENT
+	PAGE_PRESENT
 #define GET_PTL3_FLAGS_ARCH(ptl2, i) \
-        PAGE_PRESENT
+	PAGE_PRESENT
 #define GET_FRAME_FLAGS_ARCH(ptl3, i) \
-        get_pt_level1_flags((pte_t *) (ptl3), (size_t) (i))
+	get_pt_level1_flags((pte_t *) (ptl3), (size_t) (i))
 
 /* Set PTE flags accessors for each level. */
 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \
-        set_pt_level0_flags((pte_t *) (ptl0), (size_t) (i), (x))
+	set_pt_level0_flags((pte_t *) (ptl0), (size_t) (i), (x))
 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x)
 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x)
@@ -129,14 +119,224 @@
 	set_pt_level1_present((pte_t *) (ptl3), (size_t) (i))
 
-#if defined(PROCESSOR_ARCH_armv6) | defined(PROCESSOR_ARCH_armv7_a)
-#include "page_armv6.h"
-#elif defined(PROCESSOR_ARCH_armv4) | defined(PROCESSOR_ARCH_armv5)
-#include "page_armv4.h"
-#else
-#error "Unsupported architecture"
+/* Macros for querying the last-level PTE entries. */
+#define PTE_VALID_ARCH(pte) \
+	(*((uint32_t *) (pte)) != 0)
+#define PTE_PRESENT_ARCH(pte) \
+	(((pte_t *) (pte))->l0.descriptor_type != 0)
+#define PTE_GET_FRAME_ARCH(pte) \
+	(((pte_t *) (pte))->l1.frame_base_addr << FRAME_WIDTH)
+#define PTE_WRITABLE_ARCH(pte) \
+	(((pte_t *) (pte))->l1.access_permission_0 == PTE_AP_USER_RW_KERNEL_RW)
+#define PTE_EXECUTABLE_ARCH(pte) \
+	1
+
+#ifndef __ASM__
+
+/** Level 0 page table entry. */
+typedef struct {
+	/* 0b01 for coarse tables, see below for details */
+	unsigned descriptor_type : 2;
+	unsigned impl_specific : 3;
+	unsigned domain : 4;
+	unsigned should_be_zero : 1;
+
+	/* Pointer to the coarse 2nd level page table (holding entries for small
+	 * (4KB) or large (64KB) pages. ARM also supports fine 2nd level page
+	 * tables that may hold even tiny pages (1KB) but they are bigger (4KB
+	 * per table in comparison with 1KB per the coarse table)
+	 */
+	unsigned coarse_table_addr : 22;
+} ATTRIBUTE_PACKED pte_level0_t;
+
+/** Level 1 page table entry (small (4KB) pages used). */
+typedef struct {
+
+	/* 0b10 for small pages */
+	unsigned descriptor_type : 2;
+	unsigned bufferable : 1;
+	unsigned cacheable : 1;
+
+	/* access permissions for each of 4 subparts of a page
+	 * (for each 1KB when small pages used */
+	unsigned access_permission_0 : 2;
+	unsigned access_permission_1 : 2;
+	unsigned access_permission_2 : 2;
+	unsigned access_permission_3 : 2;
+	unsigned frame_base_addr : 20;
+} ATTRIBUTE_PACKED pte_level1_t;
+
+typedef union {
+	pte_level0_t l0;
+	pte_level1_t l1;
+} pte_t;
+
+/* Level 1 page tables access permissions */
+
+/** User mode: no access, privileged mode: no access. */
+#define PTE_AP_USER_NO_KERNEL_NO	0
+
+/** User mode: no access, privileged mode: read/write. */
+#define PTE_AP_USER_NO_KERNEL_RW	1
+
+/** User mode: read only, privileged mode: read/write. */
+#define PTE_AP_USER_RO_KERNEL_RW	2
+
+/** User mode: read/write, privileged mode: read/write. */
+#define PTE_AP_USER_RW_KERNEL_RW	3
+
+
+/* pte_level0_t and pte_level1_t descriptor_type flags */
+
+/** pte_level0_t and pte_level1_t "not present" flag (used in descriptor_type). */
+#define PTE_DESCRIPTOR_NOT_PRESENT	0
+
+/** pte_level0_t coarse page table flag (used in descriptor_type). */
+#define PTE_DESCRIPTOR_COARSE_TABLE	1
+
+/** pte_level1_t small page table flag (used in descriptor type). */
+#define PTE_DESCRIPTOR_SMALL_PAGE	2
+
+
+/** Sets the address of level 0 page table.
+ *
+ * @param pt Pointer to the page table to set.
+ *
+ */
+NO_TRACE static inline void set_ptl0_addr(pte_t *pt)
+{
+	asm volatile (
+		"mcr p15, 0, %[pt], c2, c0, 0\n"
+		:: [pt] "r" (pt)
+	);
+}
+
+
+/** Returns level 0 page table entry flags.
+ *
+ * @param pt Level 0 page table.
+ * @param i  Index of the entry to return.
+ *
+ */
+NO_TRACE static inline int get_pt_level0_flags(pte_t *pt, size_t i)
+{
+	pte_level0_t *p = &pt[i].l0;
+	int np = (p->descriptor_type == PTE_DESCRIPTOR_NOT_PRESENT);
+	
+	return (np << PAGE_PRESENT_SHIFT) | (1 << PAGE_USER_SHIFT) |
+	    (1 << PAGE_READ_SHIFT) | (1 << PAGE_WRITE_SHIFT) |
+	    (1 << PAGE_EXEC_SHIFT) | (1 << PAGE_CACHEABLE_SHIFT);
+}
+
+/** Returns level 1 page table entry flags.
+ *
+ * @param pt Level 1 page table.
+ * @param i  Index of the entry to return.
+ *
+ */
+NO_TRACE static inline int get_pt_level1_flags(pte_t *pt, size_t i)
+{
+	pte_level1_t *p = &pt[i].l1;
+	
+	int dt = p->descriptor_type;
+	int ap = p->access_permission_0;
+	
+	return ((dt == PTE_DESCRIPTOR_NOT_PRESENT) << PAGE_PRESENT_SHIFT) |
+	    ((ap == PTE_AP_USER_RO_KERNEL_RW) << PAGE_READ_SHIFT) |
+	    ((ap == PTE_AP_USER_RW_KERNEL_RW) << PAGE_READ_SHIFT) |
+	    ((ap == PTE_AP_USER_RW_KERNEL_RW) << PAGE_WRITE_SHIFT) |
+	    ((ap != PTE_AP_USER_NO_KERNEL_RW) << PAGE_USER_SHIFT) |
+	    ((ap == PTE_AP_USER_NO_KERNEL_RW) << PAGE_READ_SHIFT) |
+	    ((ap == PTE_AP_USER_NO_KERNEL_RW) << PAGE_WRITE_SHIFT) |
+	    (1 << PAGE_EXEC_SHIFT) |
+	    (p->bufferable << PAGE_CACHEABLE);
+}
+
+/** Sets flags of level 0 page table entry.
+ *
+ * @param pt    level 0 page table
+ * @param i     index of the entry to be changed
+ * @param flags new flags
+ *
+ */
+NO_TRACE static inline void set_pt_level0_flags(pte_t *pt, size_t i, int flags)
+{
+	pte_level0_t *p = &pt[i].l0;
+	
+	if (flags & PAGE_NOT_PRESENT) {
+		p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT;
+		/*
+		 * Ensures that the entry will be recognized as valid when
+		 * PTE_VALID_ARCH applied.
+		 */
+		p->should_be_zero = 1;
+	} else {
+		p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
+		p->should_be_zero = 0;
+	}
+}
+
+NO_TRACE static inline void set_pt_level0_present(pte_t *pt, size_t i)
+{
+	pte_level0_t *p = &pt[i].l0;
+
+	p->should_be_zero = 0;
+	write_barrier();
+	p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
+}
+
+/** Sets flags of level 1 page table entry.
+ *
+ * We use same access rights for the whole page. When page
+ * is not preset we store 1 in acess_rigts_3 so that at least
+ * one bit is 1 (to mark correct page entry, see #PAGE_VALID_ARCH).
+ *
+ * @param pt    Level 1 page table.
+ * @param i     Index of the entry to be changed.
+ * @param flags New flags.
+ *
+ */
+NO_TRACE static inline void set_pt_level1_flags(pte_t *pt, size_t i, int flags)
+{
+	pte_level1_t *p = &pt[i].l1;
+	
+	if (flags & PAGE_NOT_PRESENT)
+		p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT;
+	else
+		p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
+	
+	p->cacheable = p->bufferable = (flags & PAGE_CACHEABLE) != 0;
+	
+	/* default access permission */
+	p->access_permission_0 = p->access_permission_1 = 
+	    p->access_permission_2 = p->access_permission_3 =
+	    PTE_AP_USER_NO_KERNEL_RW;
+	
+	if (flags & PAGE_USER)  {
+		if (flags & PAGE_READ) {
+			p->access_permission_0 = p->access_permission_1 = 
+			    p->access_permission_2 = p->access_permission_3 = 
+			    PTE_AP_USER_RO_KERNEL_RW;
+		}
+		if (flags & PAGE_WRITE) {
+			p->access_permission_0 = p->access_permission_1 = 
+			    p->access_permission_2 = p->access_permission_3 = 
+			    PTE_AP_USER_RW_KERNEL_RW; 
+		}
+	}
+}
+
+NO_TRACE static inline void set_pt_level1_present(pte_t *pt, size_t i)
+{
+	pte_level1_t *p = &pt[i].l1;
+
+	p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
+}
+	
+extern void page_arch_init(void);
+
+#endif /* __ASM__ */
+
 #endif
 
-#endif
-
 /** @}
  */
Index: rnel/arch/arm32/include/arch/mm/page_armv4.h
===================================================================
--- kernel/arch/arm32/include/arch/mm/page_armv4.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,269 +1,0 @@
-/*
- * Copyright (c) 2007 Pavel Jancik, Michal Kebrt
- * 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 arm32mm
- * @{
- */
-/** @file
- *  @brief Paging related declarations.
- */
-
-#ifndef KERN_arm32_PAGE_armv4_H_
-#define KERN_arm32_PAGE_armv4_H_
-
-#ifndef KERN_arm32_PAGE_H_
-#error "Do not include arch specific page.h directly use generic page.h instead"
-#endif
-
-/* Macros for querying the last-level PTE entries. */
-#define PTE_VALID_ARCH(pte) \
-	(*((uint32_t *) (pte)) != 0)
-#define PTE_PRESENT_ARCH(pte) \
-	(((pte_t *) (pte))->l0.descriptor_type != 0)
-#define PTE_GET_FRAME_ARCH(pte) \
-	(((pte_t *) (pte))->l1.frame_base_addr << FRAME_WIDTH)
-#define PTE_WRITABLE_ARCH(pte) \
-	(((pte_t *) (pte))->l1.access_permission_0 == PTE_AP_USER_RW_KERNEL_RW)
-#define PTE_EXECUTABLE_ARCH(pte) \
-	1
-
-#ifndef __ASM__
-
-/** Level 0 page table entry. */
-typedef struct {
-	/* 0b01 for coarse tables, see below for details */
-	unsigned descriptor_type : 2;
-	unsigned impl_specific : 3;
-	unsigned domain : 4;
-	unsigned should_be_zero : 1;
-
-	/* Pointer to the coarse 2nd level page table (holding entries for small
-	 * (4KB) or large (64KB) pages. ARM also supports fine 2nd level page
-	 * tables that may hold even tiny pages (1KB) but they are bigger (4KB
-	 * per table in comparison with 1KB per the coarse table)
-	 */
-	unsigned coarse_table_addr : 22;
-} ATTRIBUTE_PACKED pte_level0_t;
-
-/** Level 1 page table entry (small (4KB) pages used). */
-typedef struct {
-
-	/* 0b10 for small pages */
-	unsigned descriptor_type : 2;
-	unsigned bufferable : 1;
-	unsigned cacheable : 1;
-
-	/* access permissions for each of 4 subparts of a page
-	 * (for each 1KB when small pages used */
-	unsigned access_permission_0 : 2;
-	unsigned access_permission_1 : 2;
-	unsigned access_permission_2 : 2;
-	unsigned access_permission_3 : 2;
-	unsigned frame_base_addr : 20;
-} ATTRIBUTE_PACKED pte_level1_t;
-
-typedef union {
-	pte_level0_t l0;
-	pte_level1_t l1;
-} pte_t;
-
-/* Level 1 page tables access permissions */
-
-/** User mode: no access, privileged mode: no access. */
-#define PTE_AP_USER_NO_KERNEL_NO	0
-
-/** User mode: no access, privileged mode: read/write. */
-#define PTE_AP_USER_NO_KERNEL_RW	1
-
-/** User mode: read only, privileged mode: read/write. */
-#define PTE_AP_USER_RO_KERNEL_RW	2
-
-/** User mode: read/write, privileged mode: read/write. */
-#define PTE_AP_USER_RW_KERNEL_RW	3
-
-
-/* pte_level0_t and pte_level1_t descriptor_type flags */
-
-/** pte_level0_t and pte_level1_t "not present" flag (used in descriptor_type). */
-#define PTE_DESCRIPTOR_NOT_PRESENT	0
-
-/** pte_level0_t coarse page table flag (used in descriptor_type). */
-#define PTE_DESCRIPTOR_COARSE_TABLE	1
-
-/** pte_level1_t small page table flag (used in descriptor type). */
-#define PTE_DESCRIPTOR_SMALL_PAGE	2
-
-
-/** Sets the address of level 0 page table.
- *
- * @param pt Pointer to the page table to set.
- *
- */
-NO_TRACE static inline void set_ptl0_addr(pte_t *pt)
-{
-	asm volatile (
-		"mcr p15, 0, %[pt], c2, c0, 0\n"
-		:: [pt] "r" (pt)
-	);
-}
-
-
-/** Returns level 0 page table entry flags.
- *
- * @param pt Level 0 page table.
- * @param i  Index of the entry to return.
- *
- */
-NO_TRACE static inline int get_pt_level0_flags(pte_t *pt, size_t i)
-{
-	pte_level0_t *p = &pt[i].l0;
-	int np = (p->descriptor_type == PTE_DESCRIPTOR_NOT_PRESENT);
-	
-	return (np << PAGE_PRESENT_SHIFT) | (1 << PAGE_USER_SHIFT) |
-	    (1 << PAGE_READ_SHIFT) | (1 << PAGE_WRITE_SHIFT) |
-	    (1 << PAGE_EXEC_SHIFT) | (1 << PAGE_CACHEABLE_SHIFT);
-}
-
-/** Returns level 1 page table entry flags.
- *
- * @param pt Level 1 page table.
- * @param i  Index of the entry to return.
- *
- */
-NO_TRACE static inline int get_pt_level1_flags(pte_t *pt, size_t i)
-{
-	pte_level1_t *p = &pt[i].l1;
-	
-	int dt = p->descriptor_type;
-	int ap = p->access_permission_0;
-	
-	return ((dt == PTE_DESCRIPTOR_NOT_PRESENT) << PAGE_PRESENT_SHIFT) |
-	    ((ap == PTE_AP_USER_RO_KERNEL_RW) << PAGE_READ_SHIFT) |
-	    ((ap == PTE_AP_USER_RW_KERNEL_RW) << PAGE_READ_SHIFT) |
-	    ((ap == PTE_AP_USER_RW_KERNEL_RW) << PAGE_WRITE_SHIFT) |
-	    ((ap != PTE_AP_USER_NO_KERNEL_RW) << PAGE_USER_SHIFT) |
-	    ((ap == PTE_AP_USER_NO_KERNEL_RW) << PAGE_READ_SHIFT) |
-	    ((ap == PTE_AP_USER_NO_KERNEL_RW) << PAGE_WRITE_SHIFT) |
-	    (1 << PAGE_EXEC_SHIFT) |
-	    (p->bufferable << PAGE_CACHEABLE);
-}
-
-/** Sets flags of level 0 page table entry.
- *
- * @param pt    level 0 page table
- * @param i     index of the entry to be changed
- * @param flags new flags
- *
- */
-NO_TRACE static inline void set_pt_level0_flags(pte_t *pt, size_t i, int flags)
-{
-	pte_level0_t *p = &pt[i].l0;
-	
-	if (flags & PAGE_NOT_PRESENT) {
-		p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT;
-		/*
-		 * Ensures that the entry will be recognized as valid when
-		 * PTE_VALID_ARCH applied.
-		 */
-		p->should_be_zero = 1;
-	} else {
-		p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
-		p->should_be_zero = 0;
-	}
-}
-
-
-/** Sets flags of level 1 page table entry.
- *
- * We use same access rights for the whole page. When page
- * is not preset we store 1 in acess_rigts_3 so that at least
- * one bit is 1 (to mark correct page entry, see #PAGE_VALID_ARCH).
- *
- * @param pt    Level 1 page table.
- * @param i     Index of the entry to be changed.
- * @param flags New flags.
- *
- */
-NO_TRACE static inline void set_pt_level1_flags(pte_t *pt, size_t i, int flags)
-{
-	pte_level1_t *p = &pt[i].l1;
-	
-	if (flags & PAGE_NOT_PRESENT)
-		p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT;
-	else
-		p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
-	
-	p->cacheable = p->bufferable = (flags & PAGE_CACHEABLE) != 0;
-	
-	/* default access permission */
-	p->access_permission_0 = p->access_permission_1 = 
-	    p->access_permission_2 = p->access_permission_3 =
-	    PTE_AP_USER_NO_KERNEL_RW;
-	
-	if (flags & PAGE_USER)  {
-		if (flags & PAGE_READ) {
-			p->access_permission_0 = p->access_permission_1 = 
-			    p->access_permission_2 = p->access_permission_3 = 
-			    PTE_AP_USER_RO_KERNEL_RW;
-		}
-		if (flags & PAGE_WRITE) {
-			p->access_permission_0 = p->access_permission_1 = 
-			    p->access_permission_2 = p->access_permission_3 = 
-			    PTE_AP_USER_RW_KERNEL_RW; 
-		}
-	}
-}
-
-NO_TRACE static inline void set_pt_level0_present(pte_t *pt, size_t i)
-{
-	pte_level0_t *p = &pt[i].l0;
-
-	p->should_be_zero = 0;
-	write_barrier();
-	p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
-}
-
-
-NO_TRACE static inline void set_pt_level1_present(pte_t *pt, size_t i)
-{
-	pte_level1_t *p = &pt[i].l1;
-
-	p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
-}
-
-
-extern void page_arch_init(void);
-
-
-#endif /* __ASM__ */
-
-#endif
-
-/** @}
- */
Index: rnel/arch/arm32/include/arch/mm/page_armv6.h
===================================================================
--- kernel/arch/arm32/include/arch/mm/page_armv6.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,285 +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 arm32mm
- * @{
- */
-/** @file
- *  @brief Paging related declarations.
- */
-
-#ifndef KERN_arm32_PAGE_armv7_H_
-#define KERN_arm32_PAGE_armv7_H_
-
-#ifndef KERN_arm32_PAGE_H_
-#error "Do not include arch specific page.h directly use generic page.h instead"
-#endif
-
-/* Macros for querying the last-level PTE entries. */
-#define PTE_VALID_ARCH(pte) \
-	(*((uint32_t *) (pte)) != 0)
-#define PTE_PRESENT_ARCH(pte) \
-	(((pte_t *) (pte))->l0.descriptor_type != 0)
-#define PTE_GET_FRAME_ARCH(pte) \
-	(((pte_t *) (pte))->l1.frame_base_addr << FRAME_WIDTH)
-#define PTE_WRITABLE_ARCH(pte) \
-	(((pte_t *) (pte))->l1.access_permission_1 != PTE_AP1_RO)
-#define PTE_EXECUTABLE_ARCH(pte) \
-	(((pte_t *) (pte))->l1.descriptor_type != PTE_DESCRIPTOR_SMALL_PAGE_NX)
-
-#ifndef __ASM__
-
-/** Level 0 page table entry. */
-typedef struct {
-	/* 0b01 for coarse tables, see below for details */
-	unsigned descriptor_type : 2;
-	unsigned pxn : 1;
-	unsigned ns : 1;
-	unsigned should_be_zero_0 : 1;
-	unsigned domain : 4;
-	unsigned should_be_zero_1 : 1;
-
-	/* Pointer to the coarse 2nd level page table (holding entries for small
-	 * (4KB) or large (64KB) pages. ARM also supports fine 2nd level page
-	 * tables that may hold even tiny pages (1KB) but they are bigger (4KB
-	 * per table in comparison with 1KB per the coarse table)
-	 */
-	unsigned coarse_table_addr : 22;
-} ATTRIBUTE_PACKED pte_level0_t;
-
-/** Level 1 page table entry (small (4KB) pages used). */
-typedef struct {
-
-	/* 0b10 for small pages, 0b11 for NX small pages */
-	unsigned descriptor_type : 2;
-	unsigned bufferable : 1;
-	unsigned cacheable : 1;
-	unsigned access_permission_0 : 2;
-	unsigned tex : 3;
-	unsigned access_permission_1 : 1;
-	unsigned shareable : 1;
-	unsigned non_global : 1;
-	unsigned frame_base_addr : 20;
-} ATTRIBUTE_PACKED pte_level1_t;
-
-typedef union {
-	pte_level0_t l0;
-	pte_level1_t l1;
-} pte_t;
-
-/* Level 1 page tables access permissions */
-
-/** User mode: no access, privileged mode: no access. */
-#define PTE_AP0_USER_NO_KERNEL_NO   0
-
-/** User mode: no access, privileged mode: read/write. */
-#define PTE_AP0_USER_NO_KERNEL_FULL   1
-
-/** User mode: read only, privileged mode: read/write. */
-#define PTE_AP0_USER_LIMITED_KERNEL_FULL   2
-
-/** User mode: read/write, privileged mode: read/write. */
-#define PTE_AP0_USER_FULL_KERNEL_FULL    3
-
-/** Allow writes */
-#define PTE_AP1_RO   1
-
-
-/* pte_level0_t and pte_level1_t descriptor_type flags */
-
-/** pte_level0_t and pte_level1_t "not present" flag (used in descriptor_type). */
-#define PTE_DESCRIPTOR_NOT_PRESENT	0
-
-/** pte_level0_t coarse page table flag (used in descriptor_type). */
-#define PTE_DESCRIPTOR_COARSE_TABLE	1
-
-/** pte_level1_t small page table flag (used in descriptor type). */
-#define PTE_DESCRIPTOR_SMALL_PAGE	2
-
-/** pte_level1_t small page table flag with NX (used in descriptor type). */
-#define PTE_DESCRIPTOR_SMALL_PAGE_NX	3
-
-/** Sets the address of level 0 page table.
- *
- * @param pt Pointer to the page table to set.
- *
- */
-NO_TRACE static inline void set_ptl0_addr(pte_t *pt)
-{
-	asm volatile (
-		"mcr p15, 0, %[pt], c2, c0, 0\n"
-		:: [pt] "r" (pt)
-	);
-}
-
-
-/** Returns level 0 page table entry flags.
- *
- * @param pt Level 0 page table.
- * @param i  Index of the entry to return.
- *
- */
-NO_TRACE static inline int get_pt_level0_flags(pte_t *pt, size_t i)
-{
-	const pte_level0_t *p = &pt[i].l0;
-	const unsigned np = (p->descriptor_type == PTE_DESCRIPTOR_NOT_PRESENT);
-	
-	return (np << PAGE_PRESENT_SHIFT) | (1 << PAGE_USER_SHIFT) |
-	    (1 << PAGE_READ_SHIFT) | (1 << PAGE_WRITE_SHIFT) |
-	    (1 << PAGE_EXEC_SHIFT) | (1 << PAGE_CACHEABLE_SHIFT);
-}
-
-/** Returns level 1 page table entry flags.
- *
- * @param pt Level 1 page table.
- * @param i  Index of the entry to return.
- *
- */
-NO_TRACE static inline int get_pt_level1_flags(pte_t *pt, size_t i)
-{
-	const pte_level1_t *p = &pt[i].l1;
-	
-	const unsigned dt = p->descriptor_type;
-	const unsigned ap0 = p->access_permission_0;
-	const unsigned ap1 = p->access_permission_1;
-	
-	return ((dt == PTE_DESCRIPTOR_NOT_PRESENT) << PAGE_PRESENT_SHIFT) |
-	    ((dt != PTE_DESCRIPTOR_SMALL_PAGE_NX) << PAGE_EXEC_SHIFT) |
-	    ((ap0 == PTE_AP0_USER_LIMITED_KERNEL_FULL) << PAGE_READ_SHIFT) |
-	    ((ap0 == PTE_AP0_USER_FULL_KERNEL_FULL) << PAGE_READ_SHIFT) |
-	    ((ap0 == PTE_AP0_USER_NO_KERNEL_FULL) << PAGE_READ_SHIFT) |
-	    ((ap0 != PTE_AP0_USER_NO_KERNEL_FULL) << PAGE_USER_SHIFT) |
-	    (((ap1 != PTE_AP1_RO) && (ap0 == PTE_AP0_USER_FULL_KERNEL_FULL)) << PAGE_WRITE_SHIFT) |
-	    (((ap1 != PTE_AP1_RO) && (ap0 == PTE_AP0_USER_NO_KERNEL_FULL)) << PAGE_WRITE_SHIFT) |
-	    (p->bufferable << PAGE_CACHEABLE);
-}
-
-/** Sets flags of level 0 page table entry.
- *
- * @param pt    level 0 page table
- * @param i     index of the entry to be changed
- * @param flags new flags
- *
- */
-NO_TRACE static inline void set_pt_level0_flags(pte_t *pt, size_t i, int flags)
-{
-	pte_level0_t *p = &pt[i].l0;
-	
-	if (flags & PAGE_NOT_PRESENT) {
-		p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT;
-		/*
-		 * Ensures that the entry will be recognized as valid when
-		 * PTE_VALID_ARCH applied.
-		 */
-		p->should_be_zero_0 = 1;
-		p->should_be_zero_1 = 1;
-	} else {
-		p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
-		p->should_be_zero_0 = 0;
-		p->should_be_zero_1 = 0;
-		p->domain = 0;
-		p->ns = 0;
-	}
-}
-
-
-/** Sets flags of level 1 page table entry.
- *
- * We use same access rights for the whole page. When page
- * is not preset we store 1 in acess_rigts_3 so that at least
- * one bit is 1 (to mark correct page entry, see #PAGE_VALID_ARCH).
- *
- * @param pt    Level 1 page table.
- * @param i     Index of the entry to be changed.
- * @param flags New flags.
- *
- */
-NO_TRACE static inline void set_pt_level1_flags(pte_t *pt, size_t i, int flags)
-{
-	pte_level1_t *p = &pt[i].l1;
-	
-	if (flags & PAGE_NOT_PRESENT) {
-		p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT;
-	} else {
-		if (flags & PAGE_EXEC)
-			p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
-		else
-			p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE_NX;
-	}
-	
-	/* tex=0 buf=1 and cache=1 => normal memory
-	 * tex=0 buf=1 and cache=0 => shareable device mmio
-	 */
-	p->cacheable = (flags & PAGE_CACHEABLE);
-	p->bufferable = 1;
-	p->tex = 0;
-	
-	/* Shareable is ignored for devices (non-cacheable),
-	 * turn it on for normal memory. */
-	p->shareable = 1;
-	
-	p->non_global = !(flags & PAGE_GLOBAL);
-	
-	/* default access permission: kernel only*/
-	p->access_permission_0 = PTE_AP0_USER_NO_KERNEL_FULL;
-	
-	if (flags & PAGE_USER) {
-		p->access_permission_0 = PTE_AP0_USER_FULL_KERNEL_FULL;
-		// TODO Fix kernel to use PAGE_WRITE flag properly and
-		// apply this for kernel pages as well.
-		if (!(flags & PAGE_WRITE))
-			p->access_permission_1 = PTE_AP1_RO;
-	}
-}
-
-NO_TRACE static inline void set_pt_level0_present(pte_t *pt, size_t i)
-{
-	pte_level0_t *p = &pt[i].l0;
-
-	p->should_be_zero_0 = 0;
-	p->should_be_zero_1 = 0;
-	write_barrier();
-	p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
-}
-
-NO_TRACE static inline void set_pt_level1_present(pte_t *pt, size_t i)
-{
-	pte_level1_t *p = &pt[i].l1;
-
-	p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
-}
-
-
-extern void page_arch_init(void);
-
-#endif /* __ASM__ */
-
-#endif
-
-/** @}
- */
Index: kernel/arch/arm32/include/arch/mm/page_fault.h
===================================================================
--- kernel/arch/arm32/include/arch/mm/page_fault.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/mm/page_fault.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,34 +40,18 @@
 
 
-/** Decribes CP15 "fault status register" (FSR).
- *
- * "VMSAv6 added a fifth fault status bit (bit[10]) to both the IFSR and DFSR.
- * It is IMPLEMENTATION DEFINED how this bit is encoded in earlier versions of
- * the architecture. A write flag (bit[11] of the DFSR) has also been
- * introduced."
- * ARM Architecture Reference Manual version i ch. B4.6 (PDF p. 719)
- *
- * See ARM Architecture Reference Manual ch. B4.9.6 (pdf p.743). for FSR info
- */
+/** Decribes CP15 "fault status register" (FSR). */
+typedef struct {
+	unsigned status : 3;
+	unsigned domain : 4;
+	unsigned zero : 1;
+	unsigned should_be_zero : 24;
+} ATTRIBUTE_PACKED fault_status_t;
+
+
+/** Help union used for casting integer value into #fault_status_t. */
 typedef union {
-	struct {
-		unsigned status : 4;
-		unsigned domain : 4;
-		unsigned zero : 1;
-		unsigned lpae : 1; /**< Needs LPAE support implemented */
-		unsigned fs : 1; /**< armv6+ mandated, earlier IPLM. DEFINED */
-		unsigned wr : 1; /**< armv6+ only */
-		unsigned ext : 1 ; /**< external abort */
-		unsigned cm : 1; /**< Cache maintenance, needs LPAE support */
-		unsigned should_be_zero : 18;
-	} data;
-	struct {
-		unsigned status : 4;
-		unsigned sbz0 : 6;
-		unsigned fs : 1;
-		unsigned should_be_zero : 21;
-	} inst;
-	uint32_t raw;
-} fault_status_t;
+	fault_status_t fs;
+	uint32_t dummy;
+} fault_status_union_t;
 
 
Index: kernel/arch/arm32/include/arch/regutils.h
===================================================================
--- kernel/arch/arm32/include/arch/regutils.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/include/arch/regutils.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,17 +41,15 @@
 #define STATUS_REG_MODE_MASK         0x1f
 
+#define CP15_R1_HIGH_VECTORS_BIT     (1 << 13)
+
 /* ARM Processor Operation Modes */
-enum {
-	USER_MODE = 0x10,
-	FIQ_MODE = 0x11,
-	IRQ_MODE = 0x12,
-	SUPERVISOR_MODE = 0x13,
-	MONITOR_MODE = 0x16,
-	ABORT_MODE = 0x17,
-	HYPERVISOR_MODE = 0x1a,
-	UNDEFINED_MODE = 0x1b,
-	SYSTEM_MODE = 0x1f,
-	MODE_MASK = 0x1f,
-};
+#define USER_MODE        0x10
+#define FIQ_MODE         0x11
+#define IRQ_MODE         0x12
+#define SUPERVISOR_MODE  0x13
+#define ABORT_MODE       0x17
+#define UNDEFINED_MODE   0x1b
+#define SYSTEM_MODE      0x1f
+
 /* [CS]PRS manipulation macros */
 #define GEN_STATUS_READ(nm, reg) \
Index: rnel/arch/arm32/include/arch/security_ext.h
===================================================================
--- kernel/arch/arm32/include/arch/security_ext.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,85 +1,0 @@
-/*
- * Copyright (c) 2013 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 arm32
- * @{
- */
-/** @file
- *  @brief Security Extensions Routines
- */
-
-#ifndef KERN_arm32_SECURITY_EXT_H_
-#define KERN_arm32_SECURITY_EXT_H_
-
-#include <arch/cp15.h>
-#include <arch/regutils.h>
-
-/** Test whether the current cpu supports security extensions.
- * return true if security extensions are supported, false otherwise.
- * @note The Processor Feature Register 1 that provides this information
- * is available only on armv7+. This function returns false on all\
- * older archs.
- */
-static inline bool sec_ext_is_implemented()
-{
-#ifdef PROCESSOR_ARCH_armv7_a
-	const uint32_t idpfr = ID_PFR1_read() & ID_PFR1_SEC_EXT_MASK;
-	return idpfr == ID_PFR1_SEC_EXT || idpfr == ID_PFR1_SEC_EXT_RFR;
-#endif
-	return false;
-}
-
-/** Test whether we are running in monitor mode.
- * return true, if the current mode is Monitor mode, false otherwise.
- * @note this is safe to call even on machines that do not implement monitor
- * mode.
- */
-static inline bool sec_ext_is_monitor_mode()
-{
-	return (current_status_reg_read() & MODE_MASK) == MONITOR_MODE;
-}
-
-/** Test whether we are running in a secure state.
- * return true if the current state is secure, false otherwise.
- *
- * @note: This functions will cause undef isntruction trap if we
- * are not running in the secure state.
- *
- * @note: u-boot enables non-secure access to cp 10/11, as well as some other
- * features and switches to non-secure state during boot.
- * Look for 'secureworld_exit' in arch/arm/cpu/armv7/omap3/board.c.
- */
-static inline bool sec_ext_is_secure()
-{
-	return sec_ext_is_implemented()
-	    && (sec_ext_is_monitor_mode() || !(SCR_read() & SCR_NS_FLAG));
-}
-
-#endif
-/** @}
- */
Index: kernel/arch/arm32/src/arm32.c
===================================================================
--- kernel/arch/arm32/src/arm32.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/arm32.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -49,5 +49,4 @@
 #include <str.h>
 #include <arch/ras.h>
-#include <sysinfo/sysinfo.h>
 
 /** Performs arm32-specific initialization before main_bsp() is called. */
@@ -117,8 +116,4 @@
 {
 	machine_input_init();
-	const char *platform = machine_get_platform_name();
-
-	sysinfo_set_item_data("platform", NULL, (void *) platform,
-	    str_size(platform));
 }
 
@@ -138,5 +133,5 @@
 	uint8_t *stck;
 	
-	stck = &THREAD->kstack[STACK_SIZE];
+	stck = &THREAD->kstack[STACK_SIZE - SP_DELTA];
 	supervisor_sp = (uintptr_t) stck;
 }
Index: kernel/arch/arm32/src/cpu/cpu.c
===================================================================
--- kernel/arch/arm32/src/cpu/cpu.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/cpu/cpu.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,155 +34,71 @@
  */
 
-#include <arch/cache.h>
 #include <arch/cpu.h>
-#include <arch/cp15.h>
 #include <cpu.h>
 #include <arch.h>
 #include <print.h>
 
-static inline unsigned log2(unsigned val)
-{
-	unsigned log = 0;
-	--val;
-	while (val) {
-		++log;
-		val >>= 1;
-	}
-	return log;
-}
+/** Number of indexes left out in the #imp_data array */
+#define IMP_DATA_START_OFFSET 0x40
 
-static unsigned dcache_ways(unsigned level);
-static unsigned dcache_sets(unsigned level);
-static unsigned dcache_linesize_log(unsigned level);
+/** Implementators (vendor) names */
+static const char *imp_data[] = {
+	"?",					/* IMP_DATA_START_OFFSET */
+	"ARM Ltd",				/* 0x41 */
+	"",					/* 0x42 */
+	"",                             	/* 0x43 */
+	"Digital Equipment Corporation",	/* 0x44 */
+	"", "", "", "", "", "", "", "", "", "",	/* 0x45 - 0x4e */
+	"", "", "", "", "", "", "", "", "", "", /* 0x4f - 0x58 */
+	"", "", "", "", "", "", "", "", "", "", /* 0x59 - 0x62 */
+	"", "", "", "", "", "",			/* 0x63 - 0x68 */
+	"Intel Corporation"			/* 0x69 */
+};
 
-
-/** Implementers (vendor) names */
-static const char * implementer(unsigned id)
-{
-	switch (id)
-	{
-	case 0x41: return "ARM Limited";
-	case 0x44: return "Digital Equipment Corporation";
-	case 0x4d: return "Motorola, Freescale Semiconductor Inc.";
-	case 0x51: return "Qualcomm Inc.";
-	case 0x56: return "Marvell Semiconductor Inc.";
-	case 0x69: return "Intel Corporation";
-	}
-	return "Unknown implementer";
-}
+/** Length of the #imp_data array */
+static unsigned int imp_data_length = sizeof(imp_data) / sizeof(char *);
 
 /** Architecture names */
-static const char * architecture_string(cpu_arch_t *arch)
-{
-	static const char *arch_data[] = {
-		"ARM",       /* 0x0 */
-		"ARMv4",       /* 0x1 */
-		"ARMv4T",      /* 0x2 */
-		"ARMv5",       /* 0x3 */
-		"ARMv5T",      /* 0x4 */
-		"ARMv5TE",     /* 0x5 */
-		"ARMv5TEJ",    /* 0x6 */
-		"ARMv6"        /* 0x7 */
-	};
-	if (arch->arch_num < (sizeof(arch_data) / sizeof(arch_data[0])))
-		return arch_data[arch->arch_num];
-	else
-		return arch_data[0];
-}
+static const char *arch_data[] = {
+	"?",       /* 0x0 */
+	"4",       /* 0x1 */
+	"4T",      /* 0x2 */
+	"5",       /* 0x3 */
+	"5T",      /* 0x4 */
+	"5TE",     /* 0x5 */
+	"5TEJ",    /* 0x6 */
+	"6"        /* 0x7 */
+};
+
+/** Length of the #arch_data array */
+static unsigned int arch_data_length = sizeof(arch_data) / sizeof(char *);
 
 
 /** Retrieves processor identification from CP15 register 0.
- *
+ * 
  * @param cpu Structure for storing CPU identification.
- * See page B4-1630 of ARM Architecture Reference Manual.
  */
 static void arch_cpu_identify(cpu_arch_t *cpu)
 {
-	const uint32_t ident = MIDR_read();
-
-	cpu->imp_num = (ident >> MIDR_IMPLEMENTER_SHIFT) & MIDR_IMPLEMENTER_MASK;
-	cpu->variant_num = (ident >> MIDR_VARIANT_SHIFT) & MIDR_VARIANT_MASK;
-	cpu->arch_num = (ident >> MIDR_ARCHITECTURE_SHIFT) & MIDR_ARCHITECTURE_MASK;
-	cpu->prim_part_num = (ident >> MIDR_PART_NUMBER_SHIFT) & MIDR_PART_NUMBER_MASK;
-	cpu->rev_num = (ident >> MIDR_REVISION_SHIFT) & MIDR_REVISION_MASK;
-
-	// TODO CPUs with arch_num == 0xf use CPUID scheme for identification
-	cpu->dcache_levels = dcache_levels();
-
-	for (unsigned i = 0; i < cpu->dcache_levels; ++i) {
-		cpu->dcache[i].ways = dcache_ways(i);
-		cpu->dcache[i].sets = dcache_sets(i);
-		cpu->dcache[i].way_shift = 31 - log2(cpu->dcache[i].ways);
-		cpu->dcache[i].set_shift = dcache_linesize_log(i);
-		cpu->dcache[i].line_size = 1 << dcache_linesize_log(i);
-		printf("Found DCache L%u: %u-way, %u sets, %u byte lines "
-		    "(shifts: w%u, s%u)\n", i + 1, cpu->dcache[i].ways,
-		    cpu->dcache[i].sets, cpu->dcache[i].line_size,
-		    cpu->dcache[i].way_shift, cpu->dcache[i].set_shift);
-	}
+	uint32_t ident;
+	asm volatile (
+		"mrc p15, 0, %[ident], c0, c0, 0\n"
+		: [ident] "=r" (ident)
+	);
+	
+	cpu->imp_num = ident >> 24;
+	cpu->variant_num = (ident << 8) >> 28;
+	cpu->arch_num = (ident << 12) >> 28;
+	cpu->prim_part_num = (ident << 16) >> 20;
+	cpu->rev_num = (ident << 28) >> 28;
 }
 
-/** Enables unaligned access and caching for armv6+ */
+/** Does nothing on ARM. */
 void cpu_arch_init(void)
 {
-	uint32_t control_reg = SCTLR_read();
-	
-	/* Turn off tex remap, RAZ/WI prior to armv7 */
-	control_reg &= ~SCTLR_TEX_REMAP_EN_FLAG;
-	/* Turn off accessed flag, RAZ/WI prior to armv7 */
-	control_reg &= ~(SCTLR_ACCESS_FLAG_EN_FLAG | SCTLR_HW_ACCESS_FLAG_EN_FLAG);
-
-	/* Unaligned access is supported on armv6+ */
-#if defined(PROCESSOR_ARCH_armv7_a) | defined(PROCESSOR_ARCH_armv6)
-	/* Enable unaligned access, RAZ/WI prior to armv6
-	 * switchable on armv6, RAO/WI writes on armv7,
-	 * see ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition
-	 * L.3.1 (p. 2456) */
-	control_reg |= SCTLR_UNALIGNED_EN_FLAG;
-	/* Disable alignment checks, this turns unaligned access to undefined,
-	 * unless U bit is set. */
-	control_reg &= ~SCTLR_ALIGN_CHECK_EN_FLAG;
-	/* Enable caching, On arm prior to armv7 there is only one level
-	 * of caches. Data cache is coherent.
-	 * "This means that the behavior of accesses from the same observer to
-	 * different VAs, that are translated to the same PA
-	 * with the same memory attributes, is fully coherent."
-	 *    ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition
-	 *    B3.11.1 (p. 1383)
-	 * We are safe to turn this on. For arm v6 see ch L.6.2 (p. 2469)
-	 * L2 Cache for armv7 is enabled by default (i.e. controlled by
-	 * this flag).
-	 */
-	control_reg |= SCTLR_CACHE_EN_FLAG;
-#endif
-#ifdef PROCESSOR_ARCH_armv7_a
-	 /* ICache coherency is elaborate on in barrier.h.
-	  * VIPT and PIPT caches need maintenance only on code modify,
-	  * so it should be safe for general use.
-	  * Enable branch predictors too as they follow the same rules
-	  * as ICache and they can be flushed together
-	  */
-	if ((CTR_read() & CTR_L1I_POLICY_MASK) != CTR_L1I_POLICY_AIVIVT) {
-		control_reg |=
-		    SCTLR_INST_CACHE_EN_FLAG | SCTLR_BRANCH_PREDICT_EN_FLAG;
-	}
-#endif
-	SCTLR_write(control_reg);
-
-#ifdef CONFIG_FPU
-	fpu_setup();
-#endif
-
-#ifdef PROCESSOR_ARCH_armv7_a
-	if ((ID_PFR1_read() & ID_PFR1_GEN_TIMER_EXT_MASK) !=
-	    ID_PFR1_GEN_TIMER_EXT) {
-		PMCR_write(PMCR_read() | PMCR_E_FLAG | PMCR_D_FLAG);
-		PMCNTENSET_write(PMCNTENSET_CYCLE_COUNTER_EN_FLAG);
-	}
-#endif
 }
 
 /** Retrieves processor identification and stores it to #CPU.arch */
-void cpu_identify(void)
+void cpu_identify(void) 
 {
 	arch_cpu_identify(&CPU->arch);
@@ -192,132 +108,22 @@
 void cpu_print_report(cpu_t *m)
 {
-	printf("cpu%d: vendor=%s, architecture=%s, part number=%x, "
+	const char *vendor = imp_data[0];
+	const char *architecture = arch_data[0];
+	cpu_arch_t * cpu_arch = &m->arch;
+
+	if ((cpu_arch->imp_num) > 0 &&
+	    (cpu_arch->imp_num < (imp_data_length + IMP_DATA_START_OFFSET))) {
+		vendor = imp_data[cpu_arch->imp_num - IMP_DATA_START_OFFSET];
+	}
+
+	if ((cpu_arch->arch_num) > 0 &&
+	    (cpu_arch->arch_num < arch_data_length)) {
+		architecture = arch_data[cpu_arch->arch_num];
+	}
+
+	printf("cpu%d: vendor=%s, architecture=ARM%s, part number=%x, "
 	    "variant=%x, revision=%x\n",
-	    m->id, implementer(m->arch.imp_num),
-	    architecture_string(&m->arch), m->arch.prim_part_num,
-	    m->arch.variant_num, m->arch.rev_num);
-}
-
-/** See chapter B4.1.19 of ARM Architecture Reference Manual */
-static unsigned dcache_linesize_log(unsigned level)
-{
-#ifdef PROCESSOR_ARCH_armv7_a
-	CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);
-	const unsigned ls_log = 2 +
-	    ((CCSIDR_read() >> CCSIDR_LINESIZE_SHIFT) & CCSIDR_LINESIZE_MASK);
-	return ls_log + 2; //return log2(bytes)
-#endif
-	return 0;
-
-}
-
-/** See chapter B4.1.19 of ARM Architecture Reference Manual */
-static unsigned dcache_ways(unsigned level)
-{
-#ifdef PROCESSOR_ARCH_armv7_a
-	CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);
-	const unsigned ways = 1 +
-	    ((CCSIDR_read() >> CCSIDR_ASSOC_SHIFT) & CCSIDR_ASSOC_MASK);
-	return ways;
-#endif
-	return 0;
-}
-
-/** See chapter B4.1.19 of ARM Architecture Reference Manual */
-static unsigned dcache_sets(unsigned level)
-{
-#ifdef PROCESSOR_ARCH_armv7_a
-	CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);
-	const unsigned sets = 1 +
-	    ((CCSIDR_read() >> CCSIDR_NUMSETS_SHIFT) & CCSIDR_NUMSETS_MASK);
-	return sets;
-#endif
-	return 0;
-}
-
-unsigned dcache_levels(void)
-{
-	unsigned levels = 0;
-#ifdef PROCESSOR_ARCH_armv7_a
-	const uint32_t val = CLIDR_read();
-	for (unsigned i = 1; i <= 7; ++i) {
-		const unsigned ctype = CLIDR_CACHE(i, val);
-		switch (ctype) {
-		case CLIDR_DCACHE_ONLY:
-		case CLIDR_SEP_CACHE:
-		case CLIDR_UNI_CACHE:
-			++levels;
-		default:
-			(void)0;
-		}
-	}
-#endif
-	return levels;
-}
-
-static void dcache_clean_manual(unsigned level, bool invalidate,
-    unsigned ways, unsigned sets, unsigned way_shift, unsigned set_shift)
-{
-
-	for (unsigned i = 0; i < ways; ++i) {
-		for (unsigned j = 0; j < sets; ++j) {
-			const uint32_t val =
-			    ((level & 0x7) << 1) |
-			    (j << set_shift) | (i << way_shift);
-			if (invalidate)
-				DCCISW_write(val);
-			else
-				DCCSW_write(val);
-		}
-	}
-}
-
-void dcache_flush(void)
-{
-	/* See ARM Architecture Reference Manual ch. B4.2.1 p. B4-1724 */
-	const unsigned levels = dcache_levels();
-	for (unsigned i = 0; i < levels; ++i) {
-		const unsigned ways = dcache_ways(i);
-		const unsigned sets = dcache_sets(i);
-		const unsigned way_shift =  31 - log2(ways);
-		const unsigned set_shift = dcache_linesize_log(i);
-		dcache_clean_manual(i, false, ways, sets, way_shift, set_shift);
-	}
-}
-
-void dcache_flush_invalidate(void)
-{
-	/* See ARM Architecture Reference Manual ch. B4.2.1 p. B4-1724 */
-	const unsigned levels = dcache_levels();
-	for (unsigned i = 0; i < levels; ++i) {
-		const unsigned ways = dcache_ways(i);
-		const unsigned sets = dcache_sets(i);
-		const unsigned way_shift =  31 - log2(ways);
-		const unsigned set_shift = dcache_linesize_log(i);
-		dcache_clean_manual(i, true, ways, sets, way_shift, set_shift);
-	}
-}
-
-
-void cpu_dcache_flush(void)
-{
-	for (unsigned i = 0; i < CPU->arch.dcache_levels; ++i)
-		dcache_clean_manual(i, false,
-		    CPU->arch.dcache[i].ways, CPU->arch.dcache[i].sets,
-		    CPU->arch.dcache[i].way_shift, CPU->arch.dcache[i].set_shift);
-}
-
-void cpu_dcache_flush_invalidate(void)
-{
-	const unsigned levels =  dcache_levels();
-	for (unsigned i = 0; i < levels; ++i)
-		dcache_clean_manual(i, true,
-		    CPU->arch.dcache[i].ways, CPU->arch.dcache[i].sets,
-		    CPU->arch.dcache[i].way_shift, CPU->arch.dcache[i].set_shift);
-}
-
-void icache_invalidate(void)
-{
-	ICIALLU_write(0);
+	    m->id, vendor, architecture, cpu_arch->prim_part_num,
+	    cpu_arch->variant_num, cpu_arch->rev_num);
 }
 
Index: kernel/arch/arm32/src/dummy.S
===================================================================
--- kernel/arch/arm32/src/dummy.S	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/dummy.S	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -32,4 +32,9 @@
 .global asm_delay_loop
 
+.global fpu_context_restore
+.global fpu_context_save
+.global fpu_enable
+.global fpu_init
+
 .global sys_tls_set
 .global dummy
@@ -41,4 +46,16 @@
 	mov	pc, lr
 
+fpu_context_restore:
+	mov	pc, lr
+    
+fpu_context_save:
+	mov	pc, lr
+    
+fpu_enable:
+	mov	pc, lr
+
+fpu_init:
+	mov	pc, lr
+    
 # not used on ARM
 sys_tls_set:
Index: kernel/arch/arm32/src/exception.c
===================================================================
--- kernel/arch/arm32/src/exception.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/exception.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,4 @@
 #include <interrupt.h>
 #include <arch/mm/page_fault.h>
-#include <arch/cp15.h>
 #include <arch/barrier.h>
 #include <print.h>
@@ -74,5 +73,5 @@
 	/* make it LDR instruction and store at exception vector */
 	*vector = handler_address_ptr | LDR_OPCODE;
-	smc_coherence(vector);
+	smc_coherence(*vector);
 	
 	/* store handler's address */
@@ -118,29 +117,21 @@
 
 #ifdef HIGH_EXCEPTION_VECTORS
-/** Activates use of high exception vectors addresses.
- *
- * "High vectors were introduced into some implementations of ARMv4 and are
- * required in ARMv6 implementations. High vectors allow the exception vector
- * locations to be moved from their normal address range 0x00000000-0x0000001C
- * at the bottom of the 32-bit address space, to an alternative address range
- * 0xFFFF0000-0xFFFF001C near the top of the address space. These alternative
- * locations are known as the high vectors.
- *
- * Prior to ARMv6, it is IMPLEMENTATION DEFINED whether the high vectors are
- * supported. When they are, a hardware configuration input selects whether
- * the normal vectors or the high vectors are to be used from
- * reset." ARM Architecture Reference Manual A2.6.11 (p. 64 in the PDF).
- *
- * ARM920T (gta02) TRM A2.3.5 (PDF p. 36) and ARM926EJ-S (icp) 2.3.2 (PDF p. 42)
- * say that armv4 an armv5 chips that we support implement this.
- */
+/** Activates use of high exception vectors addresses. */
 static void high_vectors(void)
 {
-	uint32_t control_reg = SCTLR_read();
+	uint32_t control_reg;
+	
+	asm volatile (
+		"mrc p15, 0, %[control_reg], c1, c0"
+		: [control_reg] "=r" (control_reg)
+	);
 	
 	/* switch on the high vectors bit */
-	control_reg |= SCTLR_HIGH_VECTORS_EN_FLAG;
+	control_reg |= CP15_R1_HIGH_VECTORS_BIT;
 	
-	SCTLR_write(control_reg);
+	asm volatile (
+		"mcr p15, 0, %[control_reg], c1, c0"
+		:: [control_reg] "r" (control_reg)
+	);
 }
 #endif
@@ -155,25 +146,4 @@
 }
 
-/** Undefined instruction exception handler.
- *
- * Calls scheduler_fpu_lazy_request
- */
-static void undef_insn_exception(unsigned int exc_no, istate_t *istate)
-{
-#ifdef CONFIG_FPU
-	if (handle_if_fpu_exception()) {
-		/*
-		 * Retry the failing instruction,
-		 * ARM Architecture Reference Manual says on p.B1-1169
-		 * that offset for undef instruction exception is 4
-		 */
-		istate->pc -= 4;
-		return;
-	}
-#endif
-	fault_if_from_uspace(istate, "Undefined instruction.");
-	panic_badtrap(istate, exc_no, "Undefined instruction.");
-}
-
 /** Initializes exception handling.
  *
@@ -183,5 +153,4 @@
 void exception_init(void)
 {
-	// TODO check for availability of high vectors for <= armv5
 #ifdef HIGH_EXCEPTION_VECTORS
 	high_vectors();
@@ -189,6 +158,4 @@
 	install_exception_handlers();
 	
-	exc_register(EXC_UNDEF_INSTR, "undefined instruction", true,
-	    (iroutine_t) undef_insn_exception);
 	exc_register(EXC_IRQ, "interrupt", true,
 	    (iroutine_t) irq_exception);
Index: rnel/arch/arm32/src/fpu.s
===================================================================
--- kernel/arch/arm32/src/fpu.s	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/*
- * Copyright (c) 2013 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.
- */
-
-.text
-
-.global fpsid_read
-.global mvfr0_read
-.global fpscr_read
-.global fpscr_write
-.global fpexc_read
-.global fpexc_write
-
-.global fpu_context_save_s32
-.global fpu_context_restore_s32
-.global fpu_context_save_d16
-.global fpu_context_restore_d16
-.global fpu_context_save_d32
-.global fpu_context_restore_d32
-
-fpsid_read:
-	vmrs r0, fpsid
-	mov pc, lr
-
-mvfr0_read:
-	vmrs r0, mvfr0
-	mov pc, lr
-
-fpscr_read:
-	vmrs r0, fpscr
-	mov pc, lr
-
-fpscr_write:
-	vmsr fpscr, r0
-	mov pc, lr
-
-fpexc_read:
-	vmrs r0, fpexc
-	mov pc, lr
-
-fpexc_write:
-	vmsr fpexc, r0
-	mov pc, lr
-
-fpu_context_save_s32:
-	vmrs r1, fpexc
-	vmrs r2, fpscr
-	stmia r0!, {r1, r2}
-	vstmia r0!, {s0-s31}
-	mov pc, lr
-
-fpu_context_restore_s32:
-	ldmia r0!, {r1, r2}
-	vmsr fpexc, r1
-	vmsr fpscr, r2
-	vldmia r0!, {s0-s31}
-	mov pc, lr
-
-fpu_context_save_d16:
-	vmrs r1, fpexc
-	vmrs r2, fpscr
-	stmia r0!, {r1, r2}
-	vstmia r0!, {d0-d15}
-	mov pc, lr
-
-fpu_context_restore_d16:
-	ldmia r0!, {r1, r2}
-	vmsr fpexc, r1
-	vmsr fpscr, r2
-	vldmia r0!, {d0-d15}
-	mov pc, lr
-
-fpu_context_save_d32:
-	vmrs r1, fpexc
-	stmia r0!, {r1}
-	vmrs r1, fpscr
-	stmia r0!, {r1}
-	vstmia r0!, {d0-d15}
-	vstmia r0!, {d16-d31}
-	mov pc, lr
-
-fpu_context_restore_d32:
-	ldmia r0!, {r1, r2}
-	vmsr fpexc, r1
-	vmsr fpscr, r2
-	vldmia r0!, {d0-d15}
-	vldmia r0!, {d16-d31}
-	mov pc, lr
-
-
-
Index: rnel/arch/arm32/src/fpu_context.c
===================================================================
--- kernel/arch/arm32/src/fpu_context.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,281 +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 arm32
- * @{
- */
-/** @file
- *  @brief arm32 FPU context
- */
-
-#include <fpu_context.h>
-#include <arch.h>
-#include <arch/types.h>
-#include <arch/security_ext.h>
-#include <arch/cp15.h>
-#include <cpu.h>
-
-#define FPSID_IMPLEMENTER(r)   ((r) >> 24)
-#define FPSID_SW_ONLY_FLAG   (1 << 23)
-#define FPSID_SUBACHITECTURE(r)   (((r) >> 16) & 0x7f)
-#define FPSID_PART_NUMBER(r)   (((r) >> 8) & 0xff)
-#define FPSID_VARIANT(r)   (((r) >> 4) 0xf)
-#define FPSID_REVISION(r)   (((r) >> 0) 0xf)
-
-
-enum {
-	FPU_VFPv1 = 0x00,
-	FPU_VFPv2_COMMONv1 = 0x01,
-	FPU_VFPv3_COMMONv2 = 0x02,
-	FPU_VFPv3_NO_COMMON = 0x3, /* Does not support fpu exc. traps */
-	FPU_VFPv3_COMMONv3 = 0x4,
-};
-
-extern uint32_t fpsid_read(void);
-extern uint32_t mvfr0_read(void);
-
-enum {
-	FPEXC_EX_FLAG = (1 << 31),
-	FPEXC_ENABLED_FLAG = (1 << 30),
-};
-extern uint32_t fpexc_read(void);
-extern void fpexc_write(uint32_t);
-
-/** ARM Architecture Reference Manual ch. B4.1.58, p. B$-1551 */
-enum {
-	FPSCR_N_FLAG = (1 << 31),
-	FPSCR_Z_FLAG = (1 << 30),
-	FPSCR_C_FLAG = (1 << 29),
-	FPSCR_V_FLAG = (1 << 28),
-	FPSCR_QC_FLAG = (1 << 27),
-	FPSCR_AHP_FLAG = (1 << 26),
-	FPSCR_DN_FLAG = (1 << 25),
-	FPSCR_FZ_FLAG = (1 << 24),
-	FPSCR_ROUND_MODE_MASK = (0x3 << 22),
-	FPSCR_ROUND_TO_NEAREST = (0x0 << 22),
-	FPSCR_ROUND_TO_POS_INF = (0x1 << 22),
-	FPSCR_ROUND_TO_NEG_INF = (0x2 << 22),
-	FPSCR_ROUND_TO_ZERO = (0x3 << 22),
-	FPSCR_STRIDE_MASK = (0x3 << 20),
-	FPSCR_STRIDE_SHIFT = 20,
-	FPSCR_LEN_MASK = (0x7 << 16),
-	FPSCR_LEN_SHIFT = 16,
-	FPSCR_DENORMAL_EN_FLAG = (1 << 15),
-	FPSCR_INEXACT_EN_FLAG = (1 << 12),
-	FPSCR_UNDERFLOW_EN_FLAG = (1 << 11),
-	FPSCR_OVERFLOW_EN_FLAG = (1 << 10),
-	FPSCR_ZERO_DIV_EN_FLAG = (1 << 9),
-	FPSCR_INVALID_OP_EN_FLAG = (1 << 8),
-	FPSCR_DENORMAL_FLAG = (1 << 7),
-	FPSCR_INEXACT_FLAG = (1 << 4),
-	FPSCR_UNDERFLOW_FLAG = (1 << 3),
-	FPSCR_OVERLOW_FLAG = (1 << 2),
-	FPSCR_DIV_ZERO_FLAG = (1 << 1),
-	FPSCR_INVALID_OP_FLAG = (1 << 0),
-
-	FPSCR_EN_ALL = FPSCR_DENORMAL_EN_FLAG | FPSCR_INEXACT_EN_FLAG | FPSCR_UNDERFLOW_EN_FLAG | FPSCR_OVERFLOW_EN_FLAG | FPSCR_ZERO_DIV_EN_FLAG | FPSCR_INVALID_OP_EN_FLAG,
-};
-extern uint32_t fpscr_read(void);
-extern void fpscr_write(uint32_t);
-
-extern void fpu_context_save_s32(fpu_context_t *);
-extern void fpu_context_restore_s32(fpu_context_t *);
-extern void fpu_context_save_d16(fpu_context_t *);
-extern void fpu_context_restore_d16(fpu_context_t *);
-extern void fpu_context_save_d32(fpu_context_t *);
-extern void fpu_context_restore_d32(fpu_context_t *);
-
-static void (*save_context)(fpu_context_t *ctx);
-static void (*restore_context)(fpu_context_t *ctx);
-
-static int fpu_have_coprocessor_access()
-{
-/* The register containing the information (CPACR) is not available on armv6-
- * rely on user decision to use CONFIG_FPU.
- */
-#ifdef PROCESSOR_ARC_armv7_a
-	const uint32_t cpacr = CPACR_read();
-	/* FPU needs access to coprocessor 10 and 11.
-	 * Moreover they need to have same access enabledd */
-	if (((cpacr & CPACR_CP_MASK(10)) != CPACR_CP_FULL_ACCESS(10)) &&
-	   ((cpacr & CPACR_CP_MASK(11)) != CPACR_CP_FULL_ACCESS(11))) {
-		printf("No access to CP10 and CP11: %" PRIx32 "\n", cpacr);
-		return 0;
-	}
-#endif
-	return 1;
-}
-
-/** Enable coprocessor access. Turn both non-secure mode bit and generic access.
- * Cortex A8 Manual says:
- * "You must execute an Instruction Memory Barrier (IMB) sequence immediately
- * after an update of the Coprocessor Access Control Register, see Memory
- * Barriers in the ARM Architecture Reference Manual. You must not attempt to
- * execute any instructions that are affected by the change of access rights
- * between the IMB sequence and the register update."
- * Cortex a8 TRM ch. 3.2.27. c1, Coprocessor Access Control Register
- *
- * @note do we need to call secure monitor here?
- */
-static void fpu_enable_coprocessor_access()
-{
-/* The register containing the information (CPACR) is not available on armv6-
- * rely on user decision to use CONFIG_FPU.
- */
-#ifdef PROCESSOR_ARCH_armv7_a
-	/* Allow coprocessor access */
-	uint32_t cpacr = CPACR_read();
-	/* FPU needs access to coprocessor 10 and 11.
-	 * Moreover, they need to have same access enabled */
-	cpacr &= ~(CPACR_CP_MASK(10) | CPACR_CP_MASK(11));
-	cpacr |= (CPACR_CP_FULL_ACCESS(10) | CPACR_CP_FULL_ACCESS(11));
-	CPACR_write(cpacr);
-#endif
-}
-
-
-void fpu_init(void)
-{
-	/* Check if we have access */
-	if (!fpu_have_coprocessor_access())
-		return;
-
-	/* Clear all fpu flags */
-	fpexc_write(0);
-	fpu_enable();
-	/* Mask all exception traps,
-	 * The bits are RAZ/WI on archs that don't support fpu exc traps.
-	 */
-	fpscr_write(fpscr_read() & ~FPSCR_EN_ALL);
-}
-
-void fpu_setup(void)
-{
-	/* Enable coprocessor access*/
-	fpu_enable_coprocessor_access();
-
-	/* Check if we succeeded */
-	if (!fpu_have_coprocessor_access())
-		return;
-
-	const uint32_t fpsid = fpsid_read();
-	if (fpsid & FPSID_SW_ONLY_FLAG) {
-		printf("No FPU avaiable\n");
-		return;
-	}
-	switch (FPSID_SUBACHITECTURE(fpsid))
-	{
-	case FPU_VFPv1:
-		printf("Detected VFPv1\n");
-		save_context = fpu_context_save_s32;
-		restore_context = fpu_context_restore_s32;
-		break;
-	case FPU_VFPv2_COMMONv1:
-		printf("Detected VFPv2\n");
-		save_context = fpu_context_save_d16;
-		restore_context = fpu_context_restore_d16;
-		break;
-	case FPU_VFPv3_COMMONv2:
-	case FPU_VFPv3_NO_COMMON:
-	case FPU_VFPv3_COMMONv3: {
-		const uint32_t mvfr0 = mvfr0_read();
-		/* See page B4-1637 */
-		if ((mvfr0 & 0xf) == 0x1) {
-			printf("Detected VFPv3+ with 16 regs\n");
-			save_context = fpu_context_save_d16;
-			restore_context = fpu_context_restore_d16;
-		} else {
-			printf("Detected VFPv3+ with 32 regs\n");
-			save_context = fpu_context_save_d32;
-			restore_context = fpu_context_restore_d32;
-		}
-		break;
-	}
-
-	}
-}
-
-bool handle_if_fpu_exception(void)
-{
-	/* Check if we have access */
-	if (!fpu_have_coprocessor_access())
-		return false;
-
-	const uint32_t fpexc = fpexc_read();
-	if (fpexc & FPEXC_ENABLED_FLAG) {
-		const uint32_t fpscr = fpscr_read();
-		printf("FPU exception\n"
-		    "\tFPEXC: %" PRIx32 " FPSCR: %" PRIx32 "\n", fpexc, fpscr);
-		return false;
-	}
-#ifdef CONFIG_FPU_LAZY
-	scheduler_fpu_lazy_request();
-	return true;
-#else
-	return false;
-#endif
-}
-
-void fpu_enable(void)
-{
-	/* Check if we have access */
-	if (!fpu_have_coprocessor_access())
-		return;
-	/* Enable FPU instructions */
-	fpexc_write(fpexc_read() | FPEXC_ENABLED_FLAG);
-}
-
-void fpu_disable(void)
-{
-	/* Check if we have access */
-	if (!fpu_have_coprocessor_access())
-		return;
-	/* Disable FPU instructions */
-	fpexc_write(fpexc_read() & ~FPEXC_ENABLED_FLAG);
-}
-
-void fpu_context_save(fpu_context_t *ctx)
-{
-	/* This is only necessary if we enable fpu exceptions. */
-#if 0
-	const uint32_t fpexc = fpexc_read();
-
-	if (fpexc & FPEXC_EX_FLAG) {
-		printf("EX FPU flag is on, things will fail\n");
-		//TODO implement common subarch context saving
-	}
-#endif
-	if (save_context)
-		save_context(ctx);
-}
-
-void fpu_context_restore(fpu_context_t *ctx)
-{
-	if (restore_context)
-		restore_context(ctx);
-}
Index: rnel/arch/arm32/src/mach/beagleboardxm/beagleboardxm.c
===================================================================
--- kernel/arch/arm32/src/mach/beagleboardxm/beagleboardxm.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,200 +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 arm32beagleboardxm
- * @{
- */
-/** @file
- *  @brief BeagleBoard-xM platform driver.
- */
-
-#include <arch/exception.h>
-#include <arch/mach/beagleboardxm/beagleboardxm.h>
-#include <genarch/drivers/amdm37x/uart.h>
-#include <genarch/drivers/amdm37x/irc.h>
-#include <genarch/drivers/amdm37x/gpt.h>
-#include <genarch/fb/fb.h>
-#include <genarch/srln/srln.h>
-#include <interrupt.h>
-#include <mm/km.h>
-#include <ddi/ddi.h>
-#include <ddi/device.h>
-
-static void bbxm_init(void);
-static void bbxm_timer_irq_start(void);
-static void bbxm_cpu_halt(void);
-static void bbxm_get_memory_extents(uintptr_t *start, size_t *size);
-static void bbxm_irq_exception(unsigned int exc_no, istate_t *istate);
-static void bbxm_frame_init(void);
-static void bbxm_output_init(void);
-static void bbxm_input_init(void);
-static size_t bbxm_get_irq_count(void);
-static const char *bbxm_get_platform_name(void);
-
-#define BBXM_MEMORY_START	0x80000000	/* physical */
-#define BBXM_MEMORY_SIZE	0x20000000	/* 512 MB */
-
-static struct beagleboard {
-	amdm37x_irc_regs_t *irc_addr;
-	amdm37x_uart_t uart;
-	amdm37x_gpt_t timer;
-} beagleboard;
-
-struct arm_machine_ops bbxm_machine_ops = {
-	.machine_init = bbxm_init,
-	.machine_timer_irq_start = bbxm_timer_irq_start,
-	.machine_cpu_halt = bbxm_cpu_halt,
-	.machine_get_memory_extents = bbxm_get_memory_extents,
-	.machine_irq_exception = bbxm_irq_exception,
-	.machine_frame_init = bbxm_frame_init,
-	.machine_output_init = bbxm_output_init,
-	.machine_input_init = bbxm_input_init,
-	.machine_get_irq_count = bbxm_get_irq_count,
-	.machine_get_platform_name = bbxm_get_platform_name
-};
-
-static irq_ownership_t bb_timer_irq_claim(irq_t *irq)
-{
-	return IRQ_ACCEPT;
-}
-
-static void bb_timer_irq_handler(irq_t *irq)
-{
-        /*
-         * We are holding a lock which prevents preemption.
-         * Release the lock, call clock() and reacquire the lock again.
-         */
-	amdm37x_gpt_irq_ack(&beagleboard.timer);
-	spinlock_unlock(&irq->lock);
-	clock();
-	spinlock_lock(&irq->lock);
-}
-
-static void bbxm_init(void)
-{
-	/* Initialize interrupt controller */
-	beagleboard.irc_addr =
-	    (void *) km_map(AMDM37x_IRC_BASE_ADDRESS, AMDM37x_IRC_SIZE,
-	    PAGE_NOT_CACHEABLE);
-	ASSERT(beagleboard.irc_addr);
-	amdm37x_irc_init(beagleboard.irc_addr);
-
-	/* Initialize timer. Use timer1, because it is in WKUP power domain
-	 * (always on) and has special capabilities for precise 1ms ticks */
-	amdm37x_gpt_timer_ticks_init(&beagleboard.timer,
-	    AMDM37x_GPT1_BASE_ADDRESS, AMDM37x_GPT1_SIZE, HZ);
-}
-
-static void bbxm_timer_irq_start(void)
-{
-	/* Initialize timer IRQ */
-	static irq_t timer_irq;
-	irq_initialize(&timer_irq);
-	timer_irq.devno = device_assign_devno();
-	timer_irq.inr = AMDM37x_GPT1_IRQ;
-	timer_irq.claim = bb_timer_irq_claim;
-	timer_irq.handler = bb_timer_irq_handler;
-	irq_register(&timer_irq);
-
-	/* Enable timer interrupt */
-	amdm37x_irc_enable(beagleboard.irc_addr, AMDM37x_GPT1_IRQ);
-
-	/* Start timer here */
-	amdm37x_gpt_timer_ticks_start(&beagleboard.timer);
-}
-
-static void bbxm_cpu_halt(void)
-{
-	while (1);
-}
-
-/** Get extents of available memory.
- *
- * @param start		Place to store memory start address (physical).
- * @param size		Place to store memory size.
- */
-static void bbxm_get_memory_extents(uintptr_t *start, size_t *size)
-{
-	*start = BBXM_MEMORY_START;
-	*size = BBXM_MEMORY_SIZE;
-}
-
-static void bbxm_irq_exception(unsigned int exc_no, istate_t *istate)
-{
-	const unsigned inum = amdm37x_irc_inum_get(beagleboard.irc_addr);
-	amdm37x_irc_irq_ack(beagleboard.irc_addr);
-
-	irq_t *irq = irq_dispatch_and_lock(inum);
-	if (irq) {
-		/* The IRQ handler was found. */
-		irq->handler(irq);
-		spinlock_unlock(&irq->lock);
-	} else {
-		/* Spurious interrupt.*/
-		printf("cpu%d: spurious interrupt (inum=%d)\n",
-		    CPU->id, inum);
-	}
-}
-
-static void bbxm_frame_init(void)
-{
-}
-
-static void bbxm_output_init(void)
-{
-	/* UART3 is wired to external RS232 connector */
-	const bool ok = amdm37x_uart_init(&beagleboard.uart,
-	    AMDM37x_UART3_IRQ, AMDM37x_UART3_BASE_ADDRESS, AMDM37x_UART3_SIZE);
-	if (ok) {
-		stdout_wire(&beagleboard.uart.outdev);
-	}
-}
-
-static void bbxm_input_init(void)
-{
-	srln_instance_t *srln_instance = srln_init();
-	if (srln_instance) {
-		indev_t *sink = stdin_wire();
-		indev_t *srln = srln_wire(srln_instance, sink);
-		amdm37x_uart_input_wire(&beagleboard.uart, srln);
-		amdm37x_irc_enable(beagleboard.irc_addr, AMDM37x_UART3_IRQ);
-	}
-}
-
-size_t bbxm_get_irq_count(void)
-{
-	return AMDM37x_IRC_IRQ_COUNT;
-}
-
-const char *bbxm_get_platform_name(void)
-{
-	return "beagleboardxm";
-}
-
-/**
- * @}
- */
Index: rnel/arch/arm32/src/mach/beaglebone/beaglebone.c
===================================================================
--- kernel/arch/arm32/src/mach/beaglebone/beaglebone.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,229 +1,0 @@
-/*
- * Copyright (c) 2012 Matteo Facchinetti
- * Copyright (c) 2012 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup arm32beaglebone
- * @{
- */
-/** @file
- *  @brief BeagleBone platform driver.
- */
-
-#include <arch/exception.h>
-#include <arch/mach/beaglebone/beaglebone.h>
-#include <genarch/drivers/am335x/irc.h>
-#include <genarch/drivers/am335x/uart.h>
-#include <genarch/drivers/am335x/timer.h>
-#include <genarch/drivers/am335x/cm_per.h>
-#include <genarch/drivers/am335x/cm_dpll.h>
-#include <genarch/drivers/am335x/ctrl_module.h>
-#include <genarch/srln/srln.h>
-#include <interrupt.h>
-#include <ddi/ddi.h>
-#include <ddi/device.h>
-#include <mm/km.h>
-
-#define BBONE_MEMORY_START       0x80000000      /* physical */
-#define BBONE_MEMORY_SIZE        0x10000000      /* 256 MB */
-
-static void bbone_init(void);
-static void bbone_timer_irq_start(void);
-static void bbone_cpu_halt(void);
-static void bbone_get_memory_extents(uintptr_t *start, size_t *size);
-static void bbone_irq_exception(unsigned int exc_no, istate_t *istate);
-static void bbone_frame_init(void);
-static void bbone_output_init(void);
-static void bbone_input_init(void);
-static size_t bbone_get_irq_count(void);
-static const char *bbone_get_platform_name(void);
-
-static struct beaglebone {
-	am335x_irc_regs_t *irc_addr;
-	am335x_cm_per_regs_t *cm_per_addr;
-	am335x_cm_dpll_regs_t *cm_dpll_addr;
-	am335x_ctrl_module_t  *ctrl_module;
-	am335x_timer_t timer;
-	am335x_uart_t uart;
-} bbone;
-
-struct arm_machine_ops bbone_machine_ops = {
-	.machine_init = bbone_init,
-	.machine_timer_irq_start = bbone_timer_irq_start,
-	.machine_cpu_halt = bbone_cpu_halt,
-	.machine_get_memory_extents = bbone_get_memory_extents,
-	.machine_irq_exception = bbone_irq_exception,
-	.machine_frame_init = bbone_frame_init,
-	.machine_output_init = bbone_output_init,
-	.machine_input_init = bbone_input_init,
-	.machine_get_irq_count = bbone_get_irq_count,
-	.machine_get_platform_name = bbone_get_platform_name,
-};
-
-static void bbone_init(void)
-{
-	bbone.irc_addr = (void *) km_map(AM335x_IRC_BASE_ADDRESS,
-	    AM335x_IRC_SIZE, PAGE_NOT_CACHEABLE);
-
-	bbone.cm_per_addr = (void *) km_map(AM335x_CM_PER_BASE_ADDRESS,
-	    AM335x_CM_PER_SIZE, PAGE_NOT_CACHEABLE);
-
-	bbone.cm_dpll_addr = (void *) km_map(AM335x_CM_DPLL_BASE_ADDRESS,
-	    AM335x_CM_DPLL_SIZE, PAGE_NOT_CACHEABLE);
-
-	bbone.ctrl_module = (void *) km_map(AM335x_CTRL_MODULE_BASE_ADDRESS,
-	    AM335x_CTRL_MODULE_SIZE, PAGE_NOT_CACHEABLE);
-
-	ASSERT(bbone.irc_addr != NULL);
-	ASSERT(bbone.cm_per_addr != NULL);
-	ASSERT(bbone.cm_dpll_addr != NULL);
-	ASSERT(bbone.ctrl_module != NULL);
-
-	/* Initialize the interrupt controller */
-	am335x_irc_init(bbone.irc_addr);
-}
-
-static irq_ownership_t bbone_timer_irq_claim(irq_t *irq)
-{
-	return IRQ_ACCEPT;
-}
-
-static void bbone_timer_irq_handler(irq_t *irq)
-{
-	am335x_timer_intr_ack(&bbone.timer);
-	spinlock_unlock(&irq->lock);
-	clock();
-	spinlock_lock(&irq->lock);
-}
-
-static void bbone_timer_irq_start(void)
-{
-	unsigned sysclk_freq;
-	int rc;
-
-	/* Initialize the IRQ */
-	static irq_t timer_irq;
-	irq_initialize(&timer_irq);
-	timer_irq.devno = device_assign_devno();
-	timer_irq.inr = AM335x_DMTIMER2_IRQ;
-	timer_irq.claim = bbone_timer_irq_claim;
-	timer_irq.handler = bbone_timer_irq_handler;
-	irq_register(&timer_irq);
-
-	/* Enable the DMTIMER2 clock module */
-	am335x_clock_module_enable(bbone.cm_per_addr, DMTIMER2);
-	/* Select the SYSCLK as the clock source for the dmtimer2 module */
-	am335x_clock_source_select(bbone.cm_dpll_addr, DMTIMER2,
-	   CLK_SRC_M_OSC);
-	/* Initialize the DMTIMER2 */
-	if (am335x_ctrl_module_clock_freq_get(bbone.ctrl_module,
-	    &sysclk_freq) != EOK) {
-		printf("Cannot get the system clock frequency!\n");
-		return;
-	} else
-		printf("system clock running at %u hz\n", sysclk_freq);
-
-	rc = am335x_timer_init(&bbone.timer, DMTIMER2, HZ, sysclk_freq);
-	if (rc != EOK) {
-		printf("Timer initialization failed\n");
-		return;
-	}
-	/* Enable the interrupt */
-	am335x_irc_enable(bbone.irc_addr, AM335x_DMTIMER2_IRQ);
-	/* Start the timer */
-	am335x_timer_start(&bbone.timer);
-}
-
-static void bbone_cpu_halt(void)
-{
-	while (1);
-}
-
-/** Get extents of available memory.
- *
- * @param start		Place to store memory start address (physical).
- * @param size		Place to store memory size.
- */
-static void bbone_get_memory_extents(uintptr_t *start, size_t *size)
-{
-	*start = BBONE_MEMORY_START;
-	*size  = BBONE_MEMORY_SIZE;
-}
-
-static void bbone_irq_exception(unsigned int exc_no, istate_t *istate)
-{
-	const unsigned inum = am335x_irc_inum_get(bbone.irc_addr);
-	am335x_irc_irq_ack(bbone.irc_addr);
-
-	irq_t *irq = irq_dispatch_and_lock(inum);
-	if (irq) {
-		/* The IRQ handler was found. */
-		irq->handler(irq);
-		spinlock_unlock(&irq->lock);
-	} else {
-		printf("Spurious interrupt\n");
-	}
-}
-
-static void bbone_frame_init(void)
-{
-}
-
-static void bbone_output_init(void)
-{
-	const bool ok = am335x_uart_init(&bbone.uart,
-	    AM335x_UART0_IRQ, AM335x_UART0_BASE_ADDRESS,
-	    AM335x_UART0_SIZE);
-
-	if (ok)
-		stdout_wire(&bbone.uart.outdev);
-}
-
-static void bbone_input_init(void)
-{
-	srln_instance_t *srln_instance = srln_init();
-	if (srln_instance) {
-		indev_t *sink = stdin_wire();
-		indev_t *srln = srln_wire(srln_instance, sink);
-		am335x_uart_input_wire(&bbone.uart, srln);
-		am335x_irc_enable(bbone.irc_addr, AM335x_UART0_IRQ);
-	}
-}
-
-size_t bbone_get_irq_count(void)
-{
-	return AM335x_IRC_IRQ_COUNT;
-}
-
-const char *bbone_get_platform_name(void)
-{
-	return "beaglebone";
-}
-
-/**
- * @}
- */
-
Index: kernel/arch/arm32/src/mach/gta02/gta02.c
===================================================================
--- kernel/arch/arm32/src/mach/gta02/gta02.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/mach/gta02/gta02.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup arm32gta02
+/** @addtogroup arm32gxemul
  * @{
  */
Index: kernel/arch/arm32/src/mach/testarm/testarm.c
===================================================================
--- kernel/arch/arm32/src/mach/testarm/testarm.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ kernel/arch/arm32/src/mach/testarm/testarm.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2007 Michal Kebrt, Petr Stepan
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 arm32gxemul
+ * @{
+ */
+/** @file
+ *  @brief GXemul drivers.
+ */
+
+#include <arch/exception.h>
+#include <arch/mach/testarm/testarm.h>
+#include <mm/page.h>
+#include <mm/km.h>
+#include <genarch/fb/fb.h>
+#include <abi/fb/visuals.h>
+#include <genarch/drivers/dsrln/dsrlnin.h>
+#include <genarch/drivers/dsrln/dsrlnout.h>
+#include <genarch/srln/srln.h>
+#include <console/console.h>
+#include <ddi/irq.h>
+#include <ddi/device.h>
+#include <config.h>
+#include <sysinfo/sysinfo.h>
+#include <interrupt.h>
+#include <print.h>
+
+
+void *gxemul_kbd;
+void *gxemul_rtc;
+void *gxemul_irqc;
+static irq_t gxemul_timer_irq;
+
+struct arm_machine_ops gxemul_machine_ops = {
+	gxemul_init,
+	gxemul_timer_irq_start,
+	gxemul_cpu_halt,
+	gxemul_get_memory_extents,
+	gxemul_irq_exception,
+	gxemul_frame_init,
+	gxemul_output_init,
+	gxemul_input_init,
+	gxemul_get_irq_count,
+	gxemul_get_platform_name
+};
+
+void gxemul_init(void)
+{
+	gxemul_kbd = (void *) km_map(GXEMUL_KBD_ADDRESS, PAGE_SIZE,
+	    PAGE_WRITE | PAGE_NOT_CACHEABLE);
+	gxemul_rtc = (void *) km_map(GXEMUL_RTC_ADDRESS, PAGE_SIZE,
+	    PAGE_WRITE | PAGE_NOT_CACHEABLE);
+	gxemul_irqc = (void *) km_map(GXEMUL_IRQC_ADDRESS, PAGE_SIZE,
+	    PAGE_WRITE | PAGE_NOT_CACHEABLE);
+}
+
+void gxemul_output_init(void)
+{
+#ifdef CONFIG_FB
+	fb_properties_t prop = {
+		.addr = GXEMUL_FB_ADDRESS,
+		.offset = 0,
+		.x = 640,
+		.y = 480,
+		.scan = 1920,
+		.visual = VISUAL_RGB_8_8_8,
+	};
+	
+	outdev_t *fbdev = fb_init(&prop);
+	if (fbdev)
+		stdout_wire(fbdev);
+#endif
+	
+#ifdef CONFIG_ARM_PRN
+	outdev_t *dsrlndev = dsrlnout_init((ioport8_t *) gxemul_kbd);
+	if (dsrlndev)
+		stdout_wire(dsrlndev);
+#endif
+}
+
+void gxemul_input_init(void)
+{
+#ifdef CONFIG_ARM_KBD
+	/*
+	 * Initialize the GXemul keyboard port. Then initialize the serial line
+	 * module and connect it to the GXemul keyboard.
+	 */
+	dsrlnin_instance_t *dsrlnin_instance
+	    = dsrlnin_init((dsrlnin_t *) gxemul_kbd, GXEMUL_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);
+		}
+	}
+	
+	/*
+	 * 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, GXEMUL_KBD_IRQ);
+	sysinfo_set_item_val("kbd.address.physical", NULL,
+	    GXEMUL_KBD_ADDRESS);
+#endif
+}
+
+size_t gxemul_get_irq_count(void)
+{
+	return GXEMUL_IRQ_COUNT;
+}
+
+const char *gxemul_get_platform_name(void)
+{
+	return "gxemul";
+}
+
+/** Starts gxemul Real Time Clock device, which asserts regular interrupts.
+ *
+ * @param frequency Interrupts frequency (0 disables RTC).
+ */
+static void gxemul_timer_start(uint32_t frequency)
+{
+	*((uint32_t *) (gxemul_rtc + GXEMUL_RTC_FREQ_OFFSET))
+	    = frequency;
+}
+
+static irq_ownership_t gxemul_timer_claim(irq_t *irq)
+{
+	return IRQ_ACCEPT;
+}
+
+/** Timer interrupt handler.
+ *
+ * @param irq Interrupt information.
+ * @param arg Not used.
+ */
+static void gxemul_timer_irq_handler(irq_t *irq)
+{
+	/*
+	* We are holding a lock which prevents preemption.
+	* Release the lock, call clock() and reacquire the lock again.
+	*/
+	spinlock_unlock(&irq->lock);
+	clock();
+	spinlock_lock(&irq->lock);
+	
+	/* acknowledge tick */
+	*((uint32_t *) (gxemul_rtc + GXEMUL_RTC_ACK_OFFSET))
+	    = 0;
+}
+
+/** Initializes and registers timer interrupt handler. */
+static void gxemul_timer_irq_init(void)
+{
+	irq_initialize(&gxemul_timer_irq);
+	gxemul_timer_irq.devno = device_assign_devno();
+	gxemul_timer_irq.inr = GXEMUL_TIMER_IRQ;
+	gxemul_timer_irq.claim = gxemul_timer_claim;
+	gxemul_timer_irq.handler = gxemul_timer_irq_handler;
+	
+	irq_register(&gxemul_timer_irq);
+}
+
+
+/** Starts timer.
+ *
+ * Initiates regular timer interrupts after initializing
+ * corresponding interrupt handler.
+ */
+void gxemul_timer_irq_start(void)
+{
+	gxemul_timer_irq_init();
+	gxemul_timer_start(GXEMUL_TIMER_FREQ);
+}
+
+/** Get extents of available memory.
+ *
+ * @param start		Place to store memory start address.
+ * @param size		Place to store memory size.
+ */
+void gxemul_get_memory_extents(uintptr_t *start, size_t *size)
+{
+	*start = 0;
+	*size = *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET));
+}
+
+/** Returns the mask of active interrupts. */
+static inline uint32_t gxemul_irqc_get_sources(void)
+{
+	return *((uint32_t *) gxemul_irqc);
+}
+
+/** Interrupt Exception handler.
+ *
+ * Determines the sources of interrupt and calls their handlers.
+ */
+void gxemul_irq_exception(unsigned int exc_no, istate_t *istate)
+{
+	uint32_t sources = gxemul_irqc_get_sources();
+	unsigned int i;
+	
+	for (i = 0; i < GXEMUL_IRQ_COUNT; i++) {
+		if (sources & (1 << i)) {
+			irq_t *irq = irq_dispatch_and_lock(i);
+			if (irq) {
+				/* The IRQ handler was found. */
+				irq->handler(irq);
+				spinlock_unlock(&irq->lock);
+			} else {
+				/* Spurious interrupt.*/
+				printf("cpu%d: spurious interrupt (inum=%d)\n",
+				    CPU->id, i);
+			}
+		}
+	}
+}
+
+void gxemul_cpu_halt(void)
+{
+	*((char *) (gxemul_kbd + GXEMUL_HALT_OFFSET)) = 0;
+}
+
+void gxemul_frame_init(void)
+{
+}
+
+/** @}
+ */
Index: kernel/arch/arm32/src/machine_func.c
===================================================================
--- kernel/arch/arm32/src/machine_func.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/machine_func.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,6 +41,5 @@
 #include <arch/mach/gta02/gta02.h>
 #include <arch/mach/integratorcp/integratorcp.h>
-#include <arch/mach/beagleboardxm/beagleboardxm.h>
-#include <arch/mach/beaglebone/beaglebone.h>
+#include <arch/mach/testarm/testarm.h>
 
 /** Pointer to machine_ops structure being used. */
@@ -52,10 +51,8 @@
 #if defined(MACHINE_gta02)
 	machine_ops = &gta02_machine_ops;
+#elif defined(MACHINE_testarm)
+	machine_ops = &gxemul_machine_ops;
 #elif defined(MACHINE_integratorcp)
 	machine_ops = &icp_machine_ops;
-#elif defined(MACHINE_beagleboardxm)
-	machine_ops = &bbxm_machine_ops;
-#elif defined(MACHINE_beaglebone)
-	machine_ops = &bbone_machine_ops;
 #else
 #error Machine type not defined.
@@ -134,10 +131,4 @@
 }
 
-const char * machine_get_platform_name(void)
-{
-	if (machine_ops->machine_get_platform_name)
-		return machine_ops->machine_get_platform_name();
-	return NULL;
-}
 /** @}
  */
Index: kernel/arch/arm32/src/mm/page.c
===================================================================
--- kernel/arch/arm32/src/mm/page.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/mm/page.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -52,16 +52,14 @@
 void page_arch_init(void)
 {
-	int flags = PAGE_CACHEABLE | PAGE_EXEC;
+	int flags = PAGE_CACHEABLE;
 	page_mapping_operations = &pt_mapping_operations;
 
 	page_table_lock(AS_KERNEL, true);
 	
+	uintptr_t cur;
+
 	/* Kernel identity mapping */
-	//FIXME: We need to consider the possibility that
-	//identity_base > identity_size and physmem_end.
-	//This might lead to overflow if identity_size is too big.
-	for (uintptr_t cur = PHYSMEM_START_ADDR;
-	    cur < min(KA2PA(config.identity_base) +
-	        config.identity_size, config.physmem_end);
+	for (cur = PHYSMEM_START_ADDR;
+	    cur < min(config.identity_size, config.physmem_end);
 	    cur += FRAME_SIZE)
 		page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
Index: kernel/arch/arm32/src/mm/page_fault.c
===================================================================
--- kernel/arch/arm32/src/mm/page_fault.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/mm/page_fault.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,4 @@
  */
 #include <panic.h>
-#include <arch/cp15.h>
 #include <arch/exception.h>
 #include <arch/mm/page_fault.h>
@@ -43,90 +42,39 @@
 #include <print.h>
 
-
-/**
- * FSR encoding ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition.
+/** Returns value stored in fault status register.
  *
- * B3.13.3 page B3-1406 (PDF page 1406)
+ *  @return Value stored in CP15 fault status register (FSR).
  */
-typedef enum {
-	DFSR_SOURCE_ALIGN = 0x0001,
-	DFSR_SOURCE_CACHE_MAINTENANCE = 0x0004,
-	DFSR_SOURCE_SYNC_EXTERNAL_TRANSLATION_L1 = 0x000c,
-	DFSR_SOURCE_SYNC_EXTERNAL_TRANSLATION_L2 = 0x000e,
-	DFSR_SOURCE_SYNC_PARITY_TRANSLATION_L1 = 0x040c,
-	DFSR_SOURCE_SYNC_PARITY_TRANSLATION_L2 = 0x040e,
-	DFSR_SOURCE_TRANSLATION_L1 = 0x0005,
-	DFSR_SOURCE_TRANSLATION_L2 = 0x0007,
-	DFSR_SOURCE_ACCESS_FLAG_L1 = 0x0003,  /**< @note: This used to be alignment enc. */
-	DFSR_SOURCE_ACCESS_FLAG_L2 = 0x0006,
-	DFSR_SOURCE_DOMAIN_L1 = 0x0009,
-	DFSR_SOURCE_DOMAIN_L2 = 0x000b,
-	DFSR_SOURCE_PERMISSION_L1 = 0x000d,
-	DFSR_SOURCE_PERMISSION_L2 = 0x000f,
-	DFSR_SOURCE_DEBUG = 0x0002,
-	DFSR_SOURCE_SYNC_EXTERNAL = 0x0008,
-	DFSR_SOURCE_TLB_CONFLICT = 0x0400,
-	DFSR_SOURCE_LOCKDOWN = 0x0404, /**< @note: Implementation defined */
-	DFSR_SOURCE_COPROCESSOR = 0x040a, /**< @note Implementation defined */
-	DFSR_SOURCE_SYNC_PARITY = 0x0409,
-	DFSR_SOURCE_ASYNC_EXTERNAL = 0x0406,
-	DFSR_SOURCE_ASYNC_PARITY = 0x0408,
-	DFSR_SOURCE_MASK = 0x0000040f,
-} dfsr_source_t;
-
-static inline const char * dfsr_source_to_str(dfsr_source_t source)
+static inline fault_status_t read_fault_status_register(void)
 {
-	switch (source)	{
-	case DFSR_SOURCE_TRANSLATION_L1:
-		return "Translation fault L1";
-	case DFSR_SOURCE_TRANSLATION_L2:
-		return "Translation fault L2";
-	case DFSR_SOURCE_PERMISSION_L1:
-		return "Permission fault L1";
-	case DFSR_SOURCE_PERMISSION_L2:
-		return "Permission fault L2";
-	case DFSR_SOURCE_ALIGN:
-		return "Alignment fault";
-	case DFSR_SOURCE_CACHE_MAINTENANCE:
-		return "Instruction cache maintenance fault";
-	case DFSR_SOURCE_SYNC_EXTERNAL_TRANSLATION_L1:
-		return "Synchronous external abort on translation table walk level 1";
-	case DFSR_SOURCE_SYNC_EXTERNAL_TRANSLATION_L2:
-		return "Synchronous external abort on translation table walk level 2";
-	case DFSR_SOURCE_SYNC_PARITY_TRANSLATION_L1:
-		return "Synchronous parity error on translation table walk level 1";
-	case DFSR_SOURCE_SYNC_PARITY_TRANSLATION_L2:
-		return "Synchronous parity error on translation table walk level 2";
-	case DFSR_SOURCE_ACCESS_FLAG_L1:
-		return "Access flag fault L1";
-	case DFSR_SOURCE_ACCESS_FLAG_L2:
-		return "Access flag fault L2";
-	case DFSR_SOURCE_DOMAIN_L1:
-		return "Domain fault L1";
-	case DFSR_SOURCE_DOMAIN_L2:
-		return "Domain flault L2";
-	case DFSR_SOURCE_DEBUG:
-		return "Debug event";
-	case DFSR_SOURCE_SYNC_EXTERNAL:
-		return "Synchronous external abort";
-	case DFSR_SOURCE_TLB_CONFLICT:
-		return "TLB conflict abort";
-	case DFSR_SOURCE_LOCKDOWN:
-		return "Lockdown (Implementation defined)";
-	case DFSR_SOURCE_COPROCESSOR:
-		return "Coprocessor abort (Implementation defined)";
-	case DFSR_SOURCE_SYNC_PARITY:
-		return "Synchronous parity error on memory access";
-	case DFSR_SOURCE_ASYNC_EXTERNAL:
-		return "Asynchronous external abort";
-	case DFSR_SOURCE_ASYNC_PARITY:
-		return "Asynchronous parity error on memory access";
-	case DFSR_SOURCE_MASK:
-		break;
-	}
-	return "Unknown data abort";
+	fault_status_union_t fsu;
+	
+	/* fault status is stored in CP15 register 5 */
+	asm volatile (
+		"mrc p15, 0, %[dummy], c5, c0, 0"
+		: [dummy] "=r" (fsu.dummy)
+	);
+	
+	return fsu.fs;
 }
 
-#if defined(PROCESSOR_ARCH_armv4) | defined(PROCESSOR_ARCH_armv5)
+/** Returns FAR (fault address register) content.
+ *
+ * @return FAR (fault address register) content (address that caused a page
+ *         fault)
+ */
+static inline uintptr_t read_fault_address_register(void)
+{
+	uintptr_t ret;
+	
+	/* fault adress is stored in CP15 register 6 */
+	asm volatile (
+		"mrc p15, 0, %[ret], c6, c0, 0"
+		: [ret] "=r" (ret)
+	);
+	
+	return ret;
+}
+
 /** Decides whether read or write into memory is requested.
  *
@@ -149,5 +97,5 @@
 		panic("page_fault - instruction does not access memory "
 		    "(instr_code: %#0" PRIx32 ", badvaddr:%p).",
-		    *(uint32_t*)instr_union.instr, (void *) badvaddr);
+		    instr_union.pc, (void *) badvaddr);
 		return PF_ACCESS_EXEC;
 	}
@@ -188,5 +136,4 @@
 	    inst, (void *) badvaddr);
 }
-#endif
 
 /** Handles "data abort" exception (load or store at invalid address).
@@ -198,50 +145,16 @@
 void data_abort(unsigned int exc_no, istate_t *istate)
 {
-	const uintptr_t badvaddr = DFAR_read();
-	const fault_status_t fsr = { .raw = DFSR_read() };
-	const dfsr_source_t source = fsr.raw & DFSR_SOURCE_MASK;
+	fault_status_t fsr __attribute__ ((unused)) =
+	    read_fault_status_register();
+	uintptr_t badvaddr = read_fault_address_register();
 
-	switch (source)	{
-	case DFSR_SOURCE_TRANSLATION_L1:
-	case DFSR_SOURCE_TRANSLATION_L2:
-	case DFSR_SOURCE_PERMISSION_L1:
-	case DFSR_SOURCE_PERMISSION_L2:
-		/* Page fault is handled further down */
-		break;
-	case DFSR_SOURCE_ALIGN:
-	case DFSR_SOURCE_CACHE_MAINTENANCE:
-	case DFSR_SOURCE_SYNC_EXTERNAL_TRANSLATION_L1:
-	case DFSR_SOURCE_SYNC_EXTERNAL_TRANSLATION_L2:
-	case DFSR_SOURCE_SYNC_PARITY_TRANSLATION_L1:
-	case DFSR_SOURCE_SYNC_PARITY_TRANSLATION_L2:
-	case DFSR_SOURCE_ACCESS_FLAG_L1:
-	case DFSR_SOURCE_ACCESS_FLAG_L2:
-	case DFSR_SOURCE_DOMAIN_L1:
-	case DFSR_SOURCE_DOMAIN_L2:
-	case DFSR_SOURCE_DEBUG:
-	case DFSR_SOURCE_SYNC_EXTERNAL:
-	case DFSR_SOURCE_TLB_CONFLICT:
-	case DFSR_SOURCE_LOCKDOWN:
-	case DFSR_SOURCE_COPROCESSOR:
-	case DFSR_SOURCE_SYNC_PARITY:
-	case DFSR_SOURCE_ASYNC_EXTERNAL:
-	case DFSR_SOURCE_ASYNC_PARITY:
-	case DFSR_SOURCE_MASK:
-		/* Weird abort stuff */
-		fault_if_from_uspace(istate, "Unhandled abort %s at address: "
-		    "%#x.", dfsr_source_to_str(source), badvaddr);
-		panic("Unhandled abort %s at address: %#x.",
-		    dfsr_source_to_str(source), badvaddr);
+	pf_access_t access = get_memory_access_type(istate->pc, badvaddr);
+
+	int ret = as_page_fault(badvaddr, access, istate);
+
+	if (ret == AS_PF_FAULT) {
+		fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr);
+		panic_memtrap(istate, access, badvaddr, NULL);
 	}
-
-#if defined(PROCESSOR_ARCH_armv6) | defined(PROCESSOR_ARCH_armv7_a)
-	const pf_access_t access =
-	    fsr.data.wr ? PF_ACCESS_WRITE : PF_ACCESS_READ;
-#elif defined(PROCESSOR_ARCH_armv4) | defined(PROCESSOR_ARCH_armv5)
-	const pf_access_t access = get_memory_access_type(istate->pc, badvaddr);
-#else
-#error "Unsupported architecture"
-#endif
-	as_page_fault(badvaddr, access, istate);
 }
 
@@ -254,5 +167,11 @@
 void prefetch_abort(unsigned int exc_no, istate_t *istate)
 {
-	as_page_fault(istate->pc, PF_ACCESS_EXEC, istate);
+	int ret = as_page_fault(istate->pc, PF_ACCESS_EXEC, istate);
+
+	if (ret == AS_PF_FAULT) {
+		fault_if_from_uspace(istate,
+		    "Page fault - prefetch_abort: %#x.", istate->pc);
+		panic_memtrap(istate, PF_ACCESS_EXEC, istate->pc, NULL);
+	}
 }
 
Index: kernel/arch/arm32/src/ras.c
===================================================================
--- kernel/arch/arm32/src/ras.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/arm32/src/ras.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -67,6 +67,5 @@
 void ras_check(unsigned int n, istate_t *istate)
 {
-	bool restart_needed = false;
-	uintptr_t restart_pc = 0;
+	uintptr_t rewrite_pc = istate->pc;
 
 	if (istate_from_uspace(istate)) {
@@ -74,15 +73,14 @@
 			if ((ras_page[RAS_START] < istate->pc) &&
 			    (ras_page[RAS_END] > istate->pc)) {
-				restart_needed = true;
-				restart_pc = ras_page[RAS_START];
+				rewrite_pc = ras_page[RAS_START];
 			}
 			ras_page[RAS_START] = 0;
 			ras_page[RAS_END] = 0xffffffff;
-		}
+		}	
 	}
 
 	exc_dispatch(n, istate);
-	if (restart_needed)
-		istate->pc = restart_pc;
+
+	istate->pc = rewrite_pc;
 }
 
Index: kernel/arch/ia32/Makefile.inc
===================================================================
--- kernel/arch/ia32/Makefile.inc	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia32/Makefile.inc	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -105,3 +105,4 @@
 	arch/$(KARCH)/src/boot/memmap.c \
 	arch/$(KARCH)/src/fpu_context.c \
+	arch/$(KARCH)/src/debugger.c \
 	arch/$(KARCH)/src/syscall.c
Index: kernel/arch/ia32/include/arch/debugger.h
===================================================================
--- kernel/arch/ia32/include/arch/debugger.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ kernel/arch/ia32/include/arch/debugger.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,1 @@
+../../../amd64/include/arch/debugger.h
Index: kernel/arch/ia32/include/arch/istate.h
===================================================================
--- kernel/arch/ia32/include/arch/istate.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia32/include/arch/istate.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -68,10 +68,8 @@
 } istate_t;
 
-#define RPL_USER	3
-
 /** Return true if exception happened while in userspace */
 NO_TRACE static inline int istate_from_uspace(istate_t *istate)
 {
-	return (istate->cs & RPL_USER) == RPL_USER;
+	return !(istate->eip & UINT32_C(0x80000000));
 }
 
Index: kernel/arch/ia32/src/debugger.c
===================================================================
--- kernel/arch/ia32/src/debugger.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ kernel/arch/ia32/src/debugger.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,1 @@
+../../amd64/src/debugger.c
Index: kernel/arch/ia32/src/fpu_context.c
===================================================================
--- kernel/arch/ia32/src/fpu_context.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia32/src/fpu_context.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,31 +37,4 @@
 #include <arch.h>
 #include <cpu.h>
-
-
-/** x87 FPU scr values (P3+ MMX2) */
-enum {
-	X87_FLUSH_ZERO_FLAG = (1 << 15),
-	X87_ROUND_CONTROL_MASK = (0x3 << 13),
-	x87_ROUND_TO_NEAREST_EVEN = (0x0 << 13),
-	X87_ROUND_DOWN_TO_NEG_INF = (0x1 << 13),
-	X87_ROUND_UP_TO_POS_INF = (0x2 << 13),
-	X87_ROUND_TO_ZERO = (0x3 << 13),
-	X87_PRECISION_MASK = (1 << 12),
-	X87_UNDERFLOW_MASK = (1 << 11),
-	X87_OVERFLOW_MASK = (1 << 10),
-	X87_ZERO_DIV_MASK = (1 << 9),
-	X87_DENORMAL_OP_MASK = (1 << 8),
-	X87_INVALID_OP_MASK = (1 << 7),
-	X87_DENOM_ZERO_FLAG = (1 << 6),
-	X87_PRECISION_EXC_FLAG = (1 << 5),
-	X87_UNDERFLOW_EXC_FLAG = (1 << 4),
-	X87_OVERFLOW_EXC_FLAG = (1 << 3),
-	X87_ZERO_DIV_EXC_FLAG = (1 << 2),
-	X87_DENORMAL_EXC_FLAG = (1 << 1),
-	X87_INVALID_OP_EXC_FLAG = (1 << 0),
-
-	X87_ALL_MASK = X87_PRECISION_MASK | X87_UNDERFLOW_MASK | X87_OVERFLOW_MASK | X87_ZERO_DIV_MASK | X87_DENORMAL_OP_MASK | X87_INVALID_OP_MASK,
-};
-
 
 typedef void (*fpu_context_function)(fpu_context_t *fctx);
@@ -125,5 +98,4 @@
 }
 
-/** Initialize x87 FPU. Mask all exceptions. */
 void fpu_init()
 {
@@ -139,5 +111,5 @@
 		"ldmxcsr %[help0]\n"
 		: [help0] "+m" (help0), [help1] "+r" (help1)
-		: [magic] "i" (X87_ALL_MASK)
+		: [magic] "i" (0x1f80)
 	);
 }
Index: kernel/arch/ia32/src/ia32.c
===================================================================
--- kernel/arch/ia32/src/ia32.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia32/src/ia32.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -45,4 +45,5 @@
 #include <arch/bios/bios.h>
 #include <arch/boot/boot.h>
+#include <arch/debugger.h>
 #include <arch/drivers/i8254.h>
 #include <arch/drivers/i8259.h>
@@ -117,4 +118,6 @@
 #endif
 		
+		/* Enable debugger */
+		debugger_init();
 		/* Merge all memory zones to 1 big zone */
 		zone_merge_all();
Index: kernel/arch/ia64/include/arch/istate.h
===================================================================
--- kernel/arch/ia64/include/arch/istate.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia64/include/arch/istate.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -106,6 +106,4 @@
 	uint64_t in5;
 	uint64_t in6;
-
-	uint64_t alignment;
 } istate_t;
 
Index: kernel/arch/ia64/include/arch/mm/as.h
===================================================================
--- kernel/arch/ia64/include/arch/mm/as.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia64/include/arch/mm/as.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -43,4 +43,6 @@
 #define USER_ADDRESS_SPACE_END_ARCH      UINT64_C(0xdfffffffffffffff)
 
+#define USTACK_ADDRESS_ARCH  UINT64_C(0x0000000ff0000000)
+
 typedef struct {
 } as_arch_t;
Index: kernel/arch/ia64/src/ivt.S
===================================================================
--- kernel/arch/ia64/src/ivt.S	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia64/src/ivt.S	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 #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)
+#define STACK_FRAME_SIZE	ALIGN_UP((STACK_ITEMS*STACK_ITEM_SIZE) + STACK_SCRATCH_AREA_SIZE, STACK_ALIGNMENT)
 
 #if (STACK_ITEMS % 2 == 0)
Index: kernel/arch/ia64/src/mm/tlb.c
===================================================================
--- kernel/arch/ia64/src/mm/tlb.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia64/src/mm/tlb.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -113,6 +113,6 @@
 	va = page;
 	
-	rr.word = rr_read(VA2VRN(page));
-	if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(page))))) {
+	rr.word = rr_read(VA2VRN(va));
+	if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) {
 		/*
 		 * The selected region register does not contain required RID.
@@ -122,6 +122,6 @@
 		
 		rr0 = rr;
-		rr0.map.rid = ASID2RID(asid, VA2VRN(page));
-		rr_write(VA2VRN(page), rr0.word);
+		rr0.map.rid = ASID2RID(asid, VA2VRN(va));
+		rr_write(VA2VRN(va), rr0.word);
 		srlz_d();
 		srlz_i();
@@ -139,38 +139,38 @@
 	case 1: /* cnt 4 - 15 */
 		ps = PAGE_WIDTH + 2;
-		va &= ~((1UL << ps) - 1);
+		va &= ~((1 << ps) - 1);
 		break;
 	case 2: /* cnt 16 - 63 */
 		ps = PAGE_WIDTH + 4;
-		va &= ~((1UL << ps) - 1);
+		va &= ~((1 << ps) - 1);
 		break;
 	case 3: /* cnt 64 - 255 */
 		ps = PAGE_WIDTH + 6;
-		va &= ~((1UL << ps) - 1);
+		va &= ~((1 << ps) - 1);
 		break;
 	case 4: /* cnt 256 - 1023 */
 		ps = PAGE_WIDTH + 8;
-		va &= ~((1UL << ps) - 1);
+		va &= ~((1 << ps) - 1);
 		break;
 	case 5: /* cnt 1024 - 4095 */
 		ps = PAGE_WIDTH + 10;
-		va &= ~((1UL << ps) - 1);
+		va &= ~((1 << ps) - 1);
 		break;
 	case 6: /* cnt 4096 - 16383 */
 		ps = PAGE_WIDTH + 12;
-		va &= ~((1UL << ps) - 1);
+		va &= ~((1 << ps) - 1);
 		break;
 	case 7: /* cnt 16384 - 65535 */
 	case 8: /* cnt 65536 - (256K - 1) */
 		ps = PAGE_WIDTH + 14;
-		va &= ~((1UL << ps) - 1);
+		va &= ~((1 << ps) - 1);
 		break;
 	default:
 		ps = PAGE_WIDTH + 18;
-		va &= ~((1UL << ps) - 1);
+		va &= ~((1 << ps) - 1);
 		break;
 	}
 	
-	for (; va < (page + cnt * PAGE_SIZE); va += (1UL << ps))
+	for (; va < (page + cnt * PAGE_SIZE); va += (1 << ps))
 		asm volatile (
 			"ptc.l %[va], %[ps] ;;"
@@ -183,5 +183,5 @@
 	
 	if (restore_rr) {
-		rr_write(VA2VRN(page), rr.word);
+		rr_write(VA2VRN(va), rr.word);
 		srlz_d();
 		srlz_i();
@@ -501,5 +501,9 @@
 		 * Forward the page fault to address space page fault handler.
 		 */
-		as_page_fault(va, PF_ACCESS_EXEC, istate);
+		if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
+			panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL);
+		}
 	}
 }
@@ -615,5 +619,9 @@
 		 * handler.
 		 */
-		as_page_fault(va, PF_ACCESS_READ, istate);
+		if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
+			panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
+		}
 	}
 }
@@ -659,5 +667,9 @@
 		dtc_pte_copy(t);
 	} else {
-		as_page_fault(va, PF_ACCESS_WRITE, istate);
+		if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
+			panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
+		}
 	}
 }
@@ -688,5 +700,9 @@
 		itc_pte_copy(t);
 	} else {
-		as_page_fault(va, PF_ACCESS_EXEC, istate);
+		if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
+			panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL);
+		}
 	}
 }
@@ -748,5 +764,9 @@
 	ASSERT((t) && (t->p));
 	ASSERT(!t->w);
-	as_page_fault(va, PF_ACCESS_WRITE, istate);
+	if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
+		fault_if_from_uspace(istate, "Page fault at %p.",
+		    (void *) va);
+		panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
+	}
 }
 
@@ -779,5 +799,9 @@
 			dtc_pte_copy(t);
 	} else {
-		as_page_fault(va, PF_ACCESS_READ, istate);
+		if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
+			fault_if_from_uspace(istate, "Page fault at %p.",
+			    (void *) va);
+			panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
+		}
 	}
 }
Index: kernel/arch/ia64/src/proc/scheduler.c
===================================================================
--- kernel/arch/ia64/src/proc/scheduler.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ia64/src/proc/scheduler.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -90,5 +90,5 @@
 		:
 		: "r" (&THREAD->kstack[STACK_SIZE / 2]),
-		  "r" (&THREAD->kstack[STACK_SIZE / 2])
+		  "r" (&THREAD->kstack[STACK_SIZE / 2 - SP_DELTA])
 		);
 }
Index: kernel/arch/mips32/include/arch/mm/tlb.h
===================================================================
--- kernel/arch/mips32/include/arch/mm/tlb.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/mips32/include/arch/mm/tlb.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -112,9 +112,9 @@
 #ifdef __BE__
 		unsigned p : 1;
-		unsigned : 25;
-		unsigned index : 6;
+		unsigned : 27;
+		unsigned index : 4;
 #else
-		unsigned index : 6;
-		unsigned : 25;
+		unsigned index : 4;
+		unsigned : 27;
 		unsigned p : 1;
 #endif
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/mips32/src/mips32.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -228,5 +228,5 @@
 {
 	supervisor_sp =
-	    (uintptr_t) &THREAD->kstack[STACK_SIZE];
+	    (uintptr_t) &THREAD->kstack[STACK_SIZE - SP_DELTA];
 }
 
Index: kernel/arch/mips32/src/mm/tlb.c
===================================================================
--- kernel/arch/mips32/src/mm/tlb.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/mips32/src/mm/tlb.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -48,5 +48,9 @@
 #include <symtab.h>
 
-static pte_t *find_mapping_and_check(uintptr_t, int, istate_t *);
+static void tlb_refill_fail(istate_t *);
+static void tlb_invalid_fail(istate_t *);
+static void tlb_modified_fail(istate_t *);
+
+static pte_t *find_mapping_and_check(uintptr_t, int, istate_t *, int *);
 
 /** Initialize TLB.
@@ -88,33 +92,54 @@
 	uintptr_t badvaddr;
 	pte_t *pte;
+	int pfrc;
 	
 	badvaddr = cp0_badvaddr_read();
 	asid = AS->asid;
 	
-	pte = find_mapping_and_check(badvaddr, PF_ACCESS_READ, istate);
-	if (pte) {
-		/*
-		 * Record access to PTE.
-		 */
-		pte->a = 1;
-
-		tlb_prepare_entry_hi(&hi, asid, badvaddr);
-		tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d,
-		    pte->cacheable, pte->pfn);
-
-		/*
-		 * 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);
+	pte = find_mapping_and_check(badvaddr, PF_ACCESS_READ, istate, &pfrc);
+	if (!pte) {
+		switch (pfrc) {
+		case AS_PF_FAULT:
+			goto fail;
+			break;
+		case AS_PF_DEFER:
+			/*
+			 * The page fault came during copy_from_uspace()
+			 * or copy_to_uspace().
+			 */
+			return;
+		default:
+			panic("Unexpected pfrc (%d).", pfrc);
 		}
-		cp0_pagemask_write(TLB_PAGE_MASK_16K);
-		tlbwr();
-	}
+	}
+
+	/*
+	 * Record access to PTE.
+	 */
+	pte->a = 1;
+
+	tlb_prepare_entry_hi(&hi, asid, badvaddr);
+	tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable,
+	    pte->pfn);
+
+	/*
+	 * 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();
+
+	return;
+	
+fail:
+	tlb_refill_fail(istate);
 }
 
@@ -130,4 +155,5 @@
 	entry_hi_t hi;
 	pte_t *pte;
+	int pfrc;
 
 	badvaddr = cp0_badvaddr_read();
@@ -142,31 +168,56 @@
 	index.value = cp0_index_read();
 
-	ASSERT(!index.p);
-
-	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;
-
-		tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d,
-		    pte->cacheable, pte->pfn);
-
-		/*
-		 * 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();
-	}
+	/*
+	 * Fail if the entry is not in TLB.
+	 */
+	if (index.p) {
+		printf("TLB entry not found.\n");
+		goto fail;
+	}
+
+	pte = find_mapping_and_check(badvaddr, PF_ACCESS_READ, istate, &pfrc);
+	if (!pte) {
+		switch (pfrc) {
+		case AS_PF_FAULT:
+			goto fail;
+			break;
+		case AS_PF_DEFER:
+			/*
+			 * The page fault came during copy_from_uspace()
+			 * or copy_to_uspace().
+			 */
+			return;
+		default:
+			panic("Unexpected pfrc (%d).", pfrc);
+		}
+	}
+
+	/*
+	 * Read the faulting TLB entry.
+	 */
+	tlbr();
+
+	/*
+	 * Record access to PTE.
+	 */
+	pte->a = 1;
+
+	tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable,
+	    pte->pfn);
+
+	/*
+	 * 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();
+
+	return;
+	
+fail:
+	tlb_invalid_fail(istate);
 }
 
@@ -182,4 +233,5 @@
 	entry_hi_t hi;
 	pte_t *pte;
+	int pfrc;
 
 	badvaddr = cp0_badvaddr_read();
@@ -197,32 +249,82 @@
 	 * Fail if the entry is not in TLB.
 	 */
-	ASSERT(!index.p);
-
-	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;
-
-		tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->w,
-		    pte->cacheable, pte->pfn);
-
-		/*
-		 * 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();
-	}
+	if (index.p) {
+		printf("TLB entry not found.\n");
+		goto fail;
+	}
+
+	pte = find_mapping_and_check(badvaddr, PF_ACCESS_WRITE, istate, &pfrc);
+	if (!pte) {
+		switch (pfrc) {
+		case AS_PF_FAULT:
+			goto fail;
+			break;
+		case AS_PF_DEFER:
+			/*
+			 * The page fault came during copy_from_uspace()
+			 * or copy_to_uspace().
+			 */
+			return;
+		default:
+			panic("Unexpected pfrc (%d).", pfrc);
+		}
+	}
+
+	/*
+	 * Read the faulting TLB entry.
+	 */
+	tlbr();
+
+	/*
+	 * Record access and write to PTE.
+	 */
+	pte->a = 1;
+	pte->d = 1;
+
+	tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->w, pte->cacheable,
+	    pte->pfn);
+
+	/*
+	 * 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();
+
+	return;
+	
+fail:
+	tlb_modified_fail(istate);
+}
+
+void tlb_refill_fail(istate_t *istate)
+{
+	uintptr_t va = cp0_badvaddr_read();
+	
+	fault_if_from_uspace(istate, "TLB Refill Exception on %p.",
+	    (void *) va);
+	panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, "TLB Refill Exception.");
+}
+
+
+void tlb_invalid_fail(istate_t *istate)
+{
+	uintptr_t va = cp0_badvaddr_read();
+	
+	fault_if_from_uspace(istate, "TLB Invalid Exception on %p.",
+	    (void *) va);
+	panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, "TLB Invalid Exception.");
+}
+
+void tlb_modified_fail(istate_t *istate)
+{
+	uintptr_t va = cp0_badvaddr_read();
+	
+	fault_if_from_uspace(istate, "TLB Modified Exception on %p.",
+	    (void *) va);
+	panic_memtrap(istate, PF_ACCESS_WRITE, va, "TLB Modified Exception.");
 }
 
@@ -232,8 +334,12 @@
  * @param access	Access mode that caused the fault.
  * @param istate	Pointer to interrupted state.
+ * @param pfrc		Pointer to variable where as_page_fault() return code
+ * 			will be stored.
  *
  * @return		PTE on success, NULL otherwise.
  */
-pte_t *find_mapping_and_check(uintptr_t badvaddr, int access, istate_t *istate)
+pte_t *
+find_mapping_and_check(uintptr_t badvaddr, int access, istate_t *istate,
+    int *pfrc)
 {
 	entry_hi_t hi;
@@ -242,5 +348,11 @@
 	hi.value = cp0_entry_hi_read();
 
-	ASSERT(hi.asid == AS->asid);
+	/*
+	 * Handler cannot succeed if the ASIDs don't match.
+	 */
+	if (hi.asid != AS->asid) {
+		printf("EntryHi.asid=%d, AS->asid=%d\n", hi.asid, AS->asid);
+		return NULL;
+	}
 
 	/*
@@ -254,18 +366,32 @@
 		 */
 		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) {
-		pte = page_mapping_find(AS, badvaddr, true);
-		ASSERT(pte && pte->p);
-		ASSERT(pte->w || access != PF_ACCESS_WRITE);
-		return pte;
-	}
-
-	return NULL;
+	} else {
+		int rc;
+		
+		/*
+		 * Mapping not found in page tables.
+		 * Resort to higher-level page fault handler.
+		 */
+		switch (rc = as_page_fault(badvaddr, access, istate)) {
+		case 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 && pte->p);
+			ASSERT(pte->w || access != PF_ACCESS_WRITE);
+			return pte;
+		case AS_PF_DEFER:
+			*pfrc = AS_PF_DEFER;
+			return NULL;
+		case AS_PF_FAULT:
+			*pfrc = AS_PF_FAULT;
+			return NULL;
+		default:
+			panic("Unexpected rc (%d).", rc);
+		}
+		
+	}
 }
 
Index: kernel/arch/mips64/src/mips64.c
===================================================================
--- kernel/arch/mips64/src/mips64.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/mips64/src/mips64.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -205,5 +205,5 @@
 {
 	supervisor_sp =
-	    (uintptr_t) &THREAD->kstack[STACK_SIZE];
+	    (uintptr_t) &THREAD->kstack[STACK_SIZE - SP_DELTA];
 }
 
Index: kernel/arch/mips64/src/mm/tlb.c
===================================================================
--- kernel/arch/mips64/src/mm/tlb.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/mips64/src/mm/tlb.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -79,4 +79,6 @@
  * @param access   Access mode that caused the fault.
  * @param istate   Pointer to interrupted state.
+ * @param pfrc     Pointer to variable where as_page_fault()
+ *                 return code will be stored.
  *
  * @return PTE on success, NULL otherwise.
@@ -84,10 +86,16 @@
  */
 static pte_t *find_mapping_and_check(uintptr_t badvaddr, int access,
-    istate_t *istate)
+    istate_t *istate, int *pfrc)
 {
 	entry_hi_t hi;
 	hi.value = cp0_entry_hi_read();
 	
-	ASSERT(hi.asid == AS->asid);
+	/*
+	 * Handler cannot succeed if the ASIDs don't match.
+	 */
+	if (hi.asid != AS->asid) {
+		printf("EntryHi.asid=%d, AS->asid=%d\n", hi.asid, AS->asid);
+		return NULL;
+	}
 	
 	/*
@@ -101,23 +109,32 @@
 		 */
 		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) {
+	} else {
+		int rc;
+		
 		/*
-		 * The higher-level page fault handler succeeded,
-		 * The mapping ought to be in place.
+		 * Mapping not found in page tables.
+		 * Resort to higher-level page fault handler.
 		 */
-		pte = page_mapping_find(AS, badvaddr, true);
-		ASSERT(pte);
-		ASSERT(pte->p);
-		ASSERT((pte->w) || (access != PF_ACCESS_WRITE));
-		return pte;
-	}
-
-	return NULL;
+		switch (rc = as_page_fault(badvaddr, access, istate)) {
+		case 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;
+		case AS_PF_DEFER:
+			*pfrc = AS_PF_DEFER;
+			return NULL;
+		case AS_PF_FAULT:
+			*pfrc = AS_PF_FAULT;
+			return NULL;
+		default:
+			panic("Unexpected return code (%d).", rc);
+		}
+	}
 }
 
@@ -139,4 +156,31 @@
 }
 
+static void tlb_refill_fail(istate_t *istate)
+{
+	uintptr_t va = cp0_badvaddr_read();
+	
+	fault_if_from_uspace(istate, "TLB Refill Exception on %p.",
+	    (void *) va);
+	panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, "TLB Refill Exception.");
+}
+
+static void tlb_invalid_fail(istate_t *istate)
+{
+	uintptr_t va = cp0_badvaddr_read();
+	
+	fault_if_from_uspace(istate, "TLB Invalid Exception on %p.",
+	    (void *) va);
+	panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, "TLB Invalid Exception.");
+}
+
+static void tlb_modified_fail(istate_t *istate)
+{
+	uintptr_t va = cp0_badvaddr_read();
+	
+	fault_if_from_uspace(istate, "TLB Modified Exception on %p.",
+	    (void *) va);
+	panic_memtrap(istate, PF_ACCESS_WRITE, va, "TLB Modified Exception.");
+}
+
 /** Process TLB Refill Exception.
  *
@@ -152,34 +196,55 @@
 	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);
+	int pfrc;
+	pte_t *pte = find_mapping_and_check(badvaddr, PF_ACCESS_READ,
+	    istate, &pfrc);
+	if (!pte) {
+		switch (pfrc) {
+		case AS_PF_FAULT:
+			goto fail;
+			break;
+		case AS_PF_DEFER:
+			/*
+			 * The page fault came during copy_from_uspace()
+			 * or copy_to_uspace().
+			 */
+			return;
+		default:
+			panic("Unexpected pfrc (%d).", pfrc);
 		}
-	
-		cp0_pagemask_write(TLB_PAGE_MASK_16K);
-		tlbwr();
-	}
+	}
+	
+	/*
+	 * 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();
+	
+	return;
+	
+fail:
+	tlb_refill_fail(istate);
 }
 
@@ -206,34 +271,60 @@
 	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();
-	}
-	
+	/*
+	 * Fail if the entry is not in TLB.
+	 */
+	if (index.p) {
+		printf("TLB entry not found.\n");
+		goto fail;
+	}
+	
+	int pfrc;
+	pte_t *pte = find_mapping_and_check(badvaddr, PF_ACCESS_READ,
+	    istate, &pfrc);
+	if (!pte) {
+		switch (pfrc) {
+		case AS_PF_FAULT:
+			goto fail;
+			break;
+		case AS_PF_DEFER:
+			/*
+			 * The page fault came during copy_from_uspace()
+			 * or copy_to_uspace().
+			 */
+			return;
+		default:
+			panic("Unexpected pfrc (%d).", pfrc);
+		}
+	}
+	
+	/*
+	 * 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();
+	
+	return;
+	
+fail:
+	tlb_invalid_fail(istate);
 }
 
@@ -260,34 +351,61 @@
 	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();
-	}
+	/*
+	 * Fail if the entry is not in TLB.
+	 */
+	if (index.p) {
+		printf("TLB entry not found.\n");
+		goto fail;
+	}
+	
+	int pfrc;
+	pte_t *pte = find_mapping_and_check(badvaddr, PF_ACCESS_WRITE,
+	    istate, &pfrc);
+	if (!pte) {
+		switch (pfrc) {
+		case AS_PF_FAULT:
+			goto fail;
+			break;
+		case AS_PF_DEFER:
+			/*
+			 * The page fault came during copy_from_uspace()
+			 * or copy_to_uspace().
+			 */
+			return;
+		default:
+			panic("Unexpected pfrc (%d).", pfrc);
+		}
+	}
+	
+	/*
+	 * 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();
+	
+	return;
+	
+fail:
+	tlb_modified_fail(istate);
 }
 
Index: kernel/arch/ppc32/src/mm/pht.c
===================================================================
--- kernel/arch/ppc32/src/mm/pht.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ppc32/src/mm/pht.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -49,4 +49,6 @@
  * @param access   Access mode that caused the fault.
  * @param istate   Pointer to interrupted state.
+ * @param pfrc     Pointer to variable where as_page_fault() return code
+ *                 will be stored.
  *
  * @return PTE on success, NULL otherwise.
@@ -54,5 +56,5 @@
  */
 static pte_t *find_mapping_and_check(as_t *as, uintptr_t badvaddr, int access,
-    istate_t *istate)
+    istate_t *istate, int *pfrc)
 {
 	/*
@@ -66,20 +68,38 @@
 		 */
 		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) {
+	} else {
 		/*
-		 * The higher-level page fault handler succeeded,
-		 * The mapping ought to be in place.
+		 * Mapping not found in page tables.
+		 * Resort to higher-level page fault handler.
 		 */
-		pte = page_mapping_find(as, badvaddr, true);
-		ASSERT((pte) && (pte->present));
-		return pte;
-	}
-
-	return NULL;
+		int rc = as_page_fault(badvaddr, access, istate);
+		switch (rc) {
+		case 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) && (pte->present));
+			*pfrc = 0;
+			return pte;
+		case AS_PF_DEFER:
+			*pfrc = rc;
+			return NULL;
+		case AS_PF_FAULT:
+			*pfrc = rc;
+			return NULL;
+		default:
+			panic("Unexpected rc (%d).", rc);
+		}
+	}
+}
+
+static void pht_refill_fail(uintptr_t badvaddr, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "PHT Refill Exception on %p.",
+	    (void *) badvaddr);
+	panic_memtrap(istate, PF_ACCESS_UNKNOWN, badvaddr,
+	    "PHT Refill Exception.");
 }
 
@@ -182,12 +202,27 @@
 		badvaddr = istate->pc;
 	
+	int pfrc;
 	pte_t *pte = find_mapping_and_check(AS, badvaddr,
-	    PF_ACCESS_READ /* FIXME */, istate);
-	
-	if (pte) {
-		/* Record access to PTE */
-		pte->accessed = 1;
-		pht_insert(badvaddr, pte);
-	}
+	    PF_ACCESS_READ /* FIXME */, istate, &pfrc);
+	
+	if (!pte) {
+		switch (pfrc) {
+		case AS_PF_FAULT:
+			pht_refill_fail(badvaddr, istate);
+			return;
+		case AS_PF_DEFER:
+			/*
+			 * The page fault came during copy_from_uspace()
+			 * or copy_to_uspace().
+			 */
+			return;
+		default:
+			panic("Unexpected pfrc (%d).", pfrc);
+		}
+	}
+	
+	/* Record access to PTE */
+	pte->accessed = 1;
+	pht_insert(badvaddr, pte);
 }
 
Index: kernel/arch/ppc32/src/ppc32.c
===================================================================
--- kernel/arch/ppc32/src/ppc32.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ppc32/src/ppc32.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -103,5 +103,4 @@
 }
 
-#ifdef CONFIG_FB
 static bool display_register(ofw_tree_node_t *node, void *arg)
 {
@@ -170,5 +169,4 @@
 	return true;
 }
-#endif
 
 void arch_post_mm_init(void)
Index: kernel/arch/ppc32/src/proc/scheduler.c
===================================================================
--- kernel/arch/ppc32/src/proc/scheduler.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/ppc32/src/proc/scheduler.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -55,5 +55,5 @@
 	asm volatile (
 		"mtsprg0 %[ksp]\n"
-		:: [ksp] "r" (KA2PA(&THREAD->kstack[STACK_SIZE]))
+		:: [ksp] "r" (KA2PA(&THREAD->kstack[STACK_SIZE - SP_DELTA]))
 	);
 }
Index: kernel/arch/sparc64/src/mm/sun4u/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4u/tlb.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/sparc64/src/mm/sun4u/tlb.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -58,4 +58,10 @@
 static void dtlb_pte_copy(pte_t *, size_t, bool);
 static void itlb_pte_copy(pte_t *, size_t);
+static void do_fast_instruction_access_mmu_miss_fault(istate_t *, uintptr_t,
+    const char *);
+static void do_fast_data_access_mmu_miss_fault(istate_t *, tlb_tag_access_reg_t,
+    const char *);
+static void do_fast_data_access_protection_fault(istate_t *,
+    tlb_tag_access_reg_t, const char *);
 
 const char *context_encoding[] = {
@@ -216,5 +222,9 @@
 		 * handler.
 		 */
-		as_page_fault(page_16k, PF_ACCESS_EXEC, istate);
+		if (as_page_fault(page_16k, PF_ACCESS_EXEC, istate) ==
+		    AS_PF_FAULT) {
+			do_fast_instruction_access_mmu_miss_fault(istate,
+			    istate->tpc, __func__);
+		}
 	}
 }
@@ -246,10 +256,12 @@
 		if (!tag.vpn) {
 			/* NULL access in kernel */
-			panic("NULL pointer dereference.");
+			do_fast_data_access_mmu_miss_fault(istate, tag,
+			    "Dereferencing NULL pointer.");
 		} else if (page_8k >= end_of_identity) {
 			/* Kernel non-identity. */
 			as = AS_KERNEL;
 		} else {
-			panic("Unexpected kernel page fault.");
+			do_fast_data_access_mmu_miss_fault(istate, tag,
+		    "Unexpected kernel page fault.");
 		}
 	}
@@ -271,5 +283,9 @@
 		 * handler.
 		 */
-		as_page_fault(page_16k, PF_ACCESS_READ, istate);
+		if (as_page_fault(page_16k, PF_ACCESS_READ, istate) ==
+		    AS_PF_FAULT) {
+			do_fast_data_access_mmu_miss_fault(istate, tag,
+			    __func__);
+		}
 	}
 }
@@ -316,5 +332,9 @@
 		 * handler.
 		 */		
-		as_page_fault(page_16k, PF_ACCESS_WRITE, istate);
+		if (as_page_fault(page_16k, PF_ACCESS_WRITE, istate) ==
+		    AS_PF_FAULT) {
+			do_fast_data_access_protection_fault(istate, tag,
+			    __func__);
+		}
 	}
 }
@@ -408,4 +428,33 @@
 
 #endif
+
+void do_fast_instruction_access_mmu_miss_fault(istate_t *istate,
+    uintptr_t va, const char *str)
+{
+	fault_if_from_uspace(istate, "%s, address=%p.", str, (void *) va);
+	panic_memtrap(istate, PF_ACCESS_EXEC, va, str);
+}
+
+void do_fast_data_access_mmu_miss_fault(istate_t *istate,
+    tlb_tag_access_reg_t tag, const char *str)
+{
+	uintptr_t va;
+
+	va = tag.vpn << MMU_PAGE_WIDTH;
+	fault_if_from_uspace(istate, "%s, page=%p (asid=%u).", str,
+	    (void *) va, tag.context);
+	panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, str);
+}
+
+void do_fast_data_access_protection_fault(istate_t *istate,
+    tlb_tag_access_reg_t tag, const char *str)
+{
+	uintptr_t va;
+
+	va = tag.vpn << MMU_PAGE_WIDTH;
+	fault_if_from_uspace(istate, "%s, page=%p (asid=%u).", str,
+	    (void *) va, tag.context);
+	panic_memtrap(istate, PF_ACCESS_WRITE, va, str);
+}
 
 void describe_dmmu_fault(void)
Index: kernel/arch/sparc64/src/mm/sun4v/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4v/tlb.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/sparc64/src/mm/sun4v/tlb.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -62,4 +62,10 @@
 static void itlb_pte_copy(pte_t *);
 static void dtlb_pte_copy(pte_t *, bool);
+static void do_fast_instruction_access_mmu_miss_fault(istate_t *, uintptr_t,
+    const char *);
+static void do_fast_data_access_mmu_miss_fault(istate_t *, uint64_t,
+    const char *);
+static void do_fast_data_access_protection_fault(istate_t *,
+    uint64_t, const char *);
 
 /*
@@ -229,5 +235,8 @@
 		 * handler.
 		 */
-		as_page_fault(va, PF_ACCESS_EXEC, istate);
+		if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
+			do_fast_instruction_access_mmu_miss_fault(istate,
+			    istate->tpc, __func__);
+		}
 	}
 }
@@ -255,7 +264,9 @@
 		if (va == 0) {
 			/* NULL access in kernel */
-			panic("NULL pointer dereference.");
+			do_fast_data_access_mmu_miss_fault(istate, page_and_ctx,
+			    __func__);
 		}
-		panic("Unexpected kernel page fault.");
+		do_fast_data_access_mmu_miss_fault(istate, page_and_ctx, "Unexpected "
+		    "kernel page fault.");
 	}
 
@@ -276,5 +287,8 @@
 		 * handler.
 		 */		
-		as_page_fault(va, PF_ACCESS_READ, istate);
+		if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
+			do_fast_data_access_mmu_miss_fault(istate, page_and_ctx,
+			    __func__);
+		}
 	}
 }
@@ -315,5 +329,8 @@
 		 * handler.
 		 */		
-		as_page_fault(va, PF_ACCESS_WRITE, istate);
+		if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
+			do_fast_data_access_protection_fault(istate, page_and_ctx,
+			    __func__);
+		}
 	}
 }
@@ -329,4 +346,30 @@
 }
 
+void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, uintptr_t va,
+    const char *str)
+{
+	fault_if_from_uspace(istate, "%s, address=%p.", str,
+	    (void *) va);
+	panic_memtrap(istate, PF_ACCESS_EXEC, va, str);
+}
+
+void do_fast_data_access_mmu_miss_fault(istate_t *istate,
+    uint64_t page_and_ctx, const char *str)
+{
+	fault_if_from_uspace(istate, "%s, page=%p (asid=%" PRId64 ").", str,
+	    (void *) DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx));
+	panic_memtrap(istate, PF_ACCESS_UNKNOWN, DMISS_ADDRESS(page_and_ctx),
+	    str);
+}
+
+void do_fast_data_access_protection_fault(istate_t *istate,
+    uint64_t page_and_ctx, const char *str)
+{
+	fault_if_from_uspace(istate, "%s, page=%p (asid=%" PRId64 ").", str,
+	    (void *) DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx));
+	panic_memtrap(istate, PF_ACCESS_WRITE, DMISS_ADDRESS(page_and_ctx),
+	    str);
+}
+
 /**
  * Describes the exact condition which caused the last DMMU fault.
Index: kernel/arch/sparc64/src/proc/sun4u/scheduler.c
===================================================================
--- kernel/arch/sparc64/src/proc/sun4u/scheduler.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/sparc64/src/proc/sun4u/scheduler.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -52,6 +52,4 @@
 {
 	if (THREAD->uspace) {
-		uint64_t sp;
-
 		/*
 		 * Write kernel stack address to %g6 of the alternate and
@@ -65,5 +63,6 @@
 		 *   before it explicitly uses %g7.
 		 */
-		sp = (uintptr_t) THREAD->kstack + STACK_SIZE - STACK_BIAS;
+		uint64_t sp = (uintptr_t) THREAD->kstack + STACK_SIZE -
+		    (STACK_BIAS + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT));
 		write_to_ig_g6(sp);
 		write_to_ag_g6(sp);
@@ -77,6 +76,5 @@
 	if (THREAD->uspace) {
 		/* sample the state of the userspace window buffer */
-		THREAD->arch.uspace_window_buffer =
-		    (uint8_t *) read_from_ag_g7();
+		THREAD->arch.uspace_window_buffer = (uint8_t *) read_from_ag_g7();
 	}
 }
Index: kernel/arch/sparc64/src/proc/sun4v/scheduler.c
===================================================================
--- kernel/arch/sparc64/src/proc/sun4v/scheduler.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/arch/sparc64/src/proc/sun4v/scheduler.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -55,7 +55,6 @@
 {
 	if (THREAD->uspace) {
-		uint64_t sp;
-
-		sp = (uintptr_t) THREAD->kstack + STACK_SIZE - STACK_BIAS;
+		uint64_t sp = (uintptr_t) THREAD->kstack + STACK_SIZE -
+		    (STACK_BIAS + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT));
 		asi_u64_write(ASI_SCRATCHPAD, SCRATCHPAD_KSTACK, sp);
 		asi_u64_write(ASI_SCRATCHPAD, SCRATCHPAD_WBUF,
Index: kernel/genarch/Makefile.inc
===================================================================
--- kernel/genarch/Makefile.inc	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/genarch/Makefile.inc	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -106,19 +106,4 @@
 endif
 
-ifeq ($(CONFIG_AM335X_UART),y)
-	GENARCH_SOURCES += \
-		genarch/src/drivers/am335x/uart.c
-endif
-
-ifeq ($(CONFIG_AM335X_TIMERS),y)
-	GENARCH_SOURCES += \
-		genarch/src/drivers/am335x/timer.c
-endif
-
-ifeq ($(CONFIG_AMDM37X_UART),y)
-	GENARCH_SOURCES += \
-		genarch/src/drivers/amdm37x/uart.c
-endif
-
 ifeq ($(CONFIG_VIA_CUDA),y)
 	GENARCH_SOURCES += \
Index: rnel/genarch/include/genarch/drivers/am335x/cm_dpll.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/cm_dpll.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/*
- * Copyright (c) 2013 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x DPLL.
- */
-
-#ifndef _KERN_AM335X_CM_DPLL_H_
-#define _KERN_AM335X_CM_DPLL_H_
-
-#include "cm_dpll_regs.h"
-#include "timer.h"
-
-#define AM335x_CM_DPLL_BASE_ADDRESS   0x44E00500
-#define AM335x_CM_DPLL_SIZE           256
-
-static ioport32_t *am335x_cm_dpll_timer_reg_get(am335x_cm_dpll_regs_t *cm,
-    am335x_timer_id_t id)
-{
-	switch (id) {
-	default:
-		return NULL;
-	case DMTIMER2:
-		return &cm->clksel_timer2;
-	case DMTIMER3:
-		return &cm->clksel_timer3;
-	case DMTIMER4:
-		return &cm->clksel_timer4;
-	case DMTIMER5:
-		return &cm->clksel_timer5;
-	case DMTIMER6:
-		return &cm->clksel_timer6;
-	case DMTIMER7:
-		return &cm->clksel_timer7;
-	}
-}
-
-static void am335x_clock_source_select(am335x_cm_dpll_regs_t *cm,
-    am335x_timer_id_t id, am335x_clk_src_t src)
-{
-	ioport32_t *reg = am335x_cm_dpll_timer_reg_get(cm, id);
-	if (!reg)
-		return;
-
-	*reg = (*reg & ~0x03) | src;
-}
-
-#endif
-
-/**
- * @}
- */
-
Index: rnel/genarch/include/genarch/drivers/am335x/cm_dpll_regs.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/cm_dpll_regs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/*
- * Copyright (c) 2013 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x DPLL registers.
- */
-
-#ifndef _KERN_AM335X_CM_DPLL_REGS_H_
-#define _KERN_AM335X_CM_DPLL_REGS_H_
-
-typedef enum {
-	CLK_SRC_TCLKIN = 0x00,
-	CLK_SRC_M_OSC,
-	CLK_SRC_32_KHZ
-} am335x_clk_src_t;
-
-typedef struct am335x_cm_dpll_regs {
-
-	ioport32_t const pad0;
-
-	ioport32_t clksel_timer7;
-	ioport32_t clksel_timer2;
-	ioport32_t clksel_timer3;
-	ioport32_t clksel_timer4;
-
-	ioport32_t clksel_mac;
-#define AM335x_CM_CLKSEL_MII_FLAG (1 << 2)
-
-	ioport32_t clksel_timer5;
-	ioport32_t clksel_timer6;
-
-	ioport32_t clksel_cpts_rft;
-
-	ioport32_t const pad1;
-
-	ioport32_t clksel_timer1ms;
-#define AM335x_CM_CLKSEL_TIMER1MS_CLKMOSC      0x00
-#define AM335x_CM_CLKSEL_TIMER1MS_CLK32KHZ     0x01
-#define AM335x_CM_CLKSEL_TIMER1MS_TCLKIN       0x02
-#define AM335x_CM_CLKSEL_TIMER1MS_CLKRC32KHZ   0x03
-#define AM335x_CM_CLKSEL_TIMER1MS_32KHZCRYSTAL 0x04
-
-	ioport32_t clksel_gfx_fclk;
-#define AM335x_CM_CLKSEL_GFX_FCLK_CLKDIV_FLAG  (1 << 0)
-#define AM335x_CM_CLKSEL_GFX_FCLK_CLKSEL_FLAG  (1 << 1)
-
-	ioport32_t clksel_pru_icss_ocp;
-	ioport32_t clksel_lcdc_pixel;
-	ioport32_t clksel_wdt1;
-	ioport32_t clksel_gpio0_db;
-
-} am335x_cm_dpll_regs_t;
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/am335x/cm_per.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/cm_per.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,87 +1,0 @@
-/*
- * Copyright (c) 2013 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x clock module.
- */
-
-#ifndef _KERN_AM335X_CM_PER_H_
-#define _KERN_AM335X_CM_PER_H_
-
-#include <typedefs.h>
-#include "cm_per_regs.h"
-#include "timer.h"
-
-#define AM335x_CM_PER_BASE_ADDRESS   0x44E00000
-#define AM335x_CM_PER_SIZE           1024
-
-static ioport32_t *am335x_clock_clkctrl_reg_get(am335x_cm_per_regs_t *cm,
-    am335x_timer_id_t id)
-{
-	switch (id) {
-	default:
-		return NULL;
-	case DMTIMER2:
-		return &cm->timer2_clkctrl;
-	case DMTIMER3:
-		return &cm->timer3_clkctrl;
-	case DMTIMER4:
-		return &cm->timer4_clkctrl;
-	case DMTIMER5:
-		return &cm->timer5_clkctrl;
-	case DMTIMER6:
-		return &cm->timer6_clkctrl;
-	case DMTIMER7:
-		return &cm->timer7_clkctrl;
-	}
-
-}
-
-static void am335x_clock_module_enable(am335x_cm_per_regs_t *cm,
-    am335x_timer_id_t timer_id)
-{
-	ioport32_t *tmr_reg = am335x_clock_clkctrl_reg_get(cm, timer_id);
-	if (tmr_reg == NULL)
-		return;
-
-	/* Enable the clock module */
-	*tmr_reg = (*tmr_reg & ~0x03) | 0x02;
-
-	/* Wait for completion */
-	while ((*tmr_reg & 0x03) != 0x02);
-}
-
-#endif
-
-/**
- * @}
- */
-
Index: rnel/genarch/include/genarch/drivers/am335x/cm_per_regs.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/cm_per_regs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,137 +1,0 @@
-/*
- * Copyright (c) 2013 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x clock module registers.
- */
-
-#ifndef _KERN_AM335X_CM_PER_REGS_H_
-#define _KERN_AM335X_CM_PER_REGS_H_
-
-#include <typedefs.h>
-
-typedef struct am335x_cm_per_regs {
-
-	ioport32_t l4ls_clkstctrl;
-	ioport32_t l3ls_clkstctrl;
-	ioport32_t l4fw_clkstctrl;
-	ioport32_t l3_clkstctrl;
-
-	ioport32_t const pad0;
-
-	ioport32_t cpgmac0_clkctrl;
-	ioport32_t lcdc_clkctrl;
-	ioport32_t usb0_clkctrl;
-
-	ioport32_t const pad1;
-
-	ioport32_t tptc0_clkctrl;
-	ioport32_t emif_clkctrl;
-	ioport32_t ocmcram_clkctrl;
-	ioport32_t gpmc_clkctrl;
-	ioport32_t mcasp0_clkctrl;
-	ioport32_t uart5_clkctrl;
-	ioport32_t mmc0_clkctrl;
-	ioport32_t elm_clkctrl;
-	ioport32_t i2c2_clkctrl;
-	ioport32_t i2c1_clkctrl;
-	ioport32_t spi0_clkctrl;
-	ioport32_t spi1_clkctrl;
-
-	ioport32_t const pad2[3];
-
-	ioport32_t l4ls_clkctrl;
-	ioport32_t l4fw_clkctrl;
-	ioport32_t mcasp1_clkctrl;
-	ioport32_t uart1_clkctrl;
-	ioport32_t uart2_clkctrl;
-	ioport32_t uart3_clkctrl;
-	ioport32_t uart4_clkctrl;
-	ioport32_t timer7_clkctrl;
-	ioport32_t timer2_clkctrl;
-	ioport32_t timer3_clkctrl;
-	ioport32_t timer4_clkctrl;
-
-	ioport32_t const pad3[8];
-
-	ioport32_t gpio1_clkctrl;
-	ioport32_t gpio2_clkctrl;
-	ioport32_t gpio3_clkctrl;
-
-	ioport32_t const pad4;
-
-	ioport32_t tpcc_clkctrl;
-	ioport32_t dcan0_clkctrl;
-	ioport32_t dcan1_clkctrl;
-	ioport32_t epwmss1_clkctrl;
-	ioport32_t emiffw_clkctrl;
-	ioport32_t epwmss0_clkctrl;
-	ioport32_t epwmss2_clkctrl;
-	ioport32_t l3instr_clkctrl;
-	ioport32_t l3_clkctrl;
-	ioport32_t ieee5000_clkctrl;
-	ioport32_t pruicss_clkctrl;
-	ioport32_t timer5_clkctrl;
-	ioport32_t timer6_clkctrl;
-	ioport32_t mmc1_clkctrl;
-	ioport32_t mmc2_clkctrl;
-	ioport32_t tptc1_clkctrl;
-	ioport32_t tptc2_clkctrl;
-
-	ioport32_t const pad5[2];
-
-	ioport32_t spinlock_clkctrl;
-	ioport32_t mailbox0_clkctrl;
-
-	ioport32_t const pad6[2];
-
-	ioport32_t l4hs_clkstctrl;
-	ioport32_t l4hs_clkctrl;
-
-	ioport32_t const pad7[2];
-
-	ioport32_t ocpwp_l3_clkstctrl;
-	ioport32_t ocpwp_clkctrl;
-
-	ioport32_t const pad8[3];
-
-	ioport32_t pruicss_clkstctrl;
-	ioport32_t cpsw_clkstctrl;
-	ioport32_t lcdc_clkstctrl;
-	ioport32_t clkdiv32_clkctrl;
-	ioport32_t clk24mhz_clkstctrl;
-} am335x_cm_per_regs_t;
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/am335x/ctrl_module.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/ctrl_module.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/*
- * Copyright (c) 2013 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x control module.
- */
-
-#ifndef _KERN_AM335X_CTRL_MODULE_H_
-#define _KERN_AM335X_CTRL_MODULE_H_
-
-#include <errno.h>
-#include <typedefs.h>
-#include "ctrl_module_regs.h"
-
-#define AM335x_CTRL_MODULE_BASE_ADDRESS  0x44E10000
-#define AM335x_CTRL_MODULE_SIZE          131072 /* 128 Kb */
-
-typedef ioport32_t am335x_ctrl_module_t;
-
-static int
-am335x_ctrl_module_clock_freq_get(am335x_ctrl_module_t *base, unsigned *freq)
-{
-	unsigned const control_status = AM335x_CTRL_MODULE_REG_VALUE(base,
-	    CONTROL_STATUS);
-
-	/* Get the sysboot1 field at control_status[22,23] */
-	unsigned const sysboot1 = (control_status >> 22) & 0x03;
-
-	switch (sysboot1) {
-	default:
-		return EINVAL;
-	case 0:
-		*freq = 19200000; /* 19.2 Mhz */
-		break;
-	case 1:
-		*freq = 24000000; /* 24 Mhz */
-		break;
-	case 2:
-		*freq = 25000000; /* 25 Mhz */
-		break;
-	case 3:
-		*freq = 26000000; /* 26 Mhz */
-		break;
-	}
-
-	return EOK;
-}
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/am335x/ctrl_module_regs.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/ctrl_module_regs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,280 +1,0 @@
-/*
- * Copyright (c) 2013 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x control module registers.
- */
-
-#ifndef _KERN_AM335X_CTRL_MODULE_REGS_H_
-#define _KERN_AM335X_CTRL_MODULE_REGS_H_
-
-#include <typedefs.h>
-
-#define AM335x_CTRL_MODULE_REG_VALUE(base, name) \
-	    (*((ioport32_t *)(AM335x_CTRL_MODULE_##name##_OFFSET + \
-	    ((ioport8_t *) base))))
-
-#define AM335x_CTRL_MODULE_CONTROL_REVISION_OFFSET          0x00
-#define AM335x_CTRL_MODULE_CONTROL_HWINFO_OFFSET            0x04
-#define AM335x_CTRL_MODULE_CONTROL_SYSCONFIG_OFFSET         0x10
-#define AM335x_CTRL_MODULE_CONTROL_STATUS_OFFSET            0x40
-#define AM335x_CTRL_MODULE_CONTROL_EMIF_SDRAM_CONFIG_OFFSET 0x110
-#define AM335x_CTRL_MODULE_CORTEX_VBBLDO_CTRL_OFFSET        0x41C
-#define AM335x_CTRL_MODULE_CORE_SLDO_CTRL_OFFSET            0x428
-#define AM335x_CTRL_MODULE_MPU_SLDO_CTRL_OFFSET             0x42C
-#define AM335x_CTRL_MODULE_CLK32KDIVRATIO_CTRL_OFFSET       0x444
-#define AM335x_CTRL_MODULE_BANDGAP_CTRL_OFFSET              0x448
-#define AM335x_CTRL_MODULE_BANDGAP_TRIM_OFFSET              0x44C
-#define AM335x_CTRL_MODULE_PLL_CLKINPULOW_CTRL_OFFSET       0x458
-#define AM335x_CTRL_MODULE_MOSC_CTRL_OFFSET                 0x468
-#define AM335x_CTRL_MODULE_ROSC_CTRL_OFFSET                 0x46C
-#define AM335x_CTRL_MODULE_DEEPSLEEP_CTRL_OFFSET            0x470
-#define AM335x_CTRL_MODULE_DEVICE_ID_OFFSET                 0x600
-#define AM335x_CTRL_MODULE_DEV_FEATURE_OFFSET               0x604
-#define AM335x_CTRL_MODULE_INIT_PRIORITY_0_OFFSET           0x608
-#define AM335x_CTRL_MODULE_INIT_PRIORITY_1_OFFSET           0x60C
-#define AM335x_CTRL_MODULE_MMU_CFG_OFFSET                   0x610
-#define AM335x_CTRL_MODULE_TPTC_CFG_OFFSET                  0x614
-#define AM335x_CTRL_MODULE_USB_CTRL0_OFFSET                 0x620
-#define AM335x_CTRL_MODULE_USB_STS0_OFFSET                  0x624
-#define AM335x_CTRL_MODULE_USB_CTRL1_OFFSET                 0x628
-#define AM335x_CTRL_MODULE_USB_STS1_OFFSET                  0x62C
-#define AM335x_CTRL_MODULE_MAC_ID0_LO_OFFSET                0x630
-#define AM335x_CTRL_MODULE_MAC_ID0_HI_OFFSET                0x634
-#define AM335x_CTRL_MODULE_MAC_ID1_LO_OFFSET                0x638
-#define AM335x_CTRL_MODULE_MAC_ID1_HI_OFFSET                0x63C
-#define AM335x_CTRL_MODULE_DCAN_RAMINIT_OFFSET              0x644
-#define AM335x_CTRL_MODULE_USB_WKUP_CTRL_OFFSET             0x648
-#define AM335x_CTRL_MODULE_GMII_SEL_OFFSET                  0x650
-#define AM335x_CTRL_MODULE_PWMSS_CTRL_OFFSET                0x664
-#define AM335x_CTRL_MODULE_MREQPRIO_0_OFFSET                0x670
-#define AM335x_CTRL_MODULE_MREQPRIO_1_OFFSET                0x674
-#define AM335x_CTRL_MODULE_HW_EVENT_SEL_GRP1_OFFSET         0x690
-#define AM335x_CTRL_MODULE_HW_EVENT_SEL_GRP2_OFFSET         0x694
-#define AM335x_CTRL_MODULE_HW_EVENT_SEL_GRP3_OFFSET         0x698
-#define AM335x_CTRL_MODULE_HW_EVENT_SEL_GRP4_OFFSET         0x69C
-#define AM335x_CTRL_MODULE_SMRT_CTRL_OFFSET                 0x6A0
-#define AM335x_CTRL_MODULE_MPUSS_HW_DEBUG_SEL_OFFSET        0x6A4
-#define AM335x_CTRL_MODULE_MPUSS_HW_DBG_INFO_OFFSET         0x6A8
-#define AM335x_CTRL_MODULE_VDD_MPU_OPP_050_OFFSET           0x770
-#define AM335x_CTRL_MODULE_VDD_MPU_OPP_100_OFFSET           0x774
-#define AM335x_CTRL_MODULE_VDD_MPU_OPP_120_OFFSET           0x778
-#define AM335x_CTRL_MODULE_VDD_MPU_OPP_TURBO_OFFSET         0x77C
-#define AM335x_CTRL_MODULE_VDD_CORE_OPP_050_OFFSET          0x7B8
-#define AM335x_CTRL_MODULE_VDD_CORE_OPP_100_OFFSET          0x7BC
-#define AM335x_CTRL_MODULE_BB_SCALE_OFFSET                  0x7D0
-#define AM335x_CTRL_MODULE_USB_VID_PID_OFFSET               0x7F4
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD0_OFFSET             0x800
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD1_OFFSET             0x804
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD2_OFFSET             0x808
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD3_OFFSET             0x80C
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD4_OFFSET             0x810
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD5_OFFSET             0x814
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD6_OFFSET             0x818
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD7_OFFSET             0x81C
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD8_OFFSET             0x820
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD9_OFFSET             0x824
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD10_OFFSET            0x828
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD11_OFFSET            0x82C
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD12_OFFSET            0x830
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD13_OFFSET            0x834
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD14_OFFSET            0x838
-#define AM335x_CTRL_MODULE_CONF_GPMC_AD15_OFFSET            0x83C
-#define AM335x_CTRL_MODULE_CONF_GPMC_A0_OFFSET              0x840
-#define AM335x_CTRL_MODULE_CONF_GPMC_A1_OFFSET              0x844
-#define AM335x_CTRL_MODULE_CONF_GPMC_A2_OFFSET              0x848
-#define AM335x_CTRL_MODULE_CONF_GPMC_A3_OFFSET              0x84C
-#define AM335x_CTRL_MODULE_CONF_GPMC_A4_OFFSET              0x850
-#define AM335x_CTRL_MODULE_CONF_GPMC_A5_OFFSET              0x854
-#define AM335x_CTRL_MODULE_CONF_GPMC_A6_OFFSET              0x858
-#define AM335x_CTRL_MODULE_CONF_GPMC_A7_OFFSET              0x85C
-#define AM335x_CTRL_MODULE_CONF_GPMC_A8_OFFSET              0x860
-#define AM335x_CTRL_MODULE_CONF_GPMC_A9_OFFSET              0x864
-#define AM335x_CTRL_MODULE_CONF_GPMC_A10_OFFSET             0x868
-#define AM335x_CTRL_MODULE_CONF_GPMC_A11_OFFSET             0x86C
-#define AM335x_CTRL_MODULE_CONF_GPMC_WAIT0_OFFSET           0x870
-#define AM335x_CTRL_MODULE_CONF_GPMC_WPN_OFFSET             0x874
-#define AM335x_CTRL_MODULE_CONF_GPMC_BEN1_OFFSET            0x878
-#define AM335x_CTRL_MODULE_CONF_GPMC_CSN0_OFFSET            0x87C
-#define AM335x_CTRL_MODULE_CONF_GPMC_CSN1_OFFSET            0x880
-#define AM335x_CTRL_MODULE_CONF_GPMC_CSN2_OFFSET            0x884
-#define AM335x_CTRL_MODULE_CONF_GPMC_CSN3_OFFSET            0x888
-#define AM335x_CTRL_MODULE_CONF_GPMC_CLK_OFFSET             0x88C
-#define AM335x_CTRL_MODULE_CONF_GPMC_ADVN_ALE_OFFSET        0x890
-#define AM335x_CTRL_MODULE_CONF_GPMC_OEN_REN_OFFSET         0x894
-#define AM335x_CTRL_MODULE_CONF_GPMC_WEN_OFFSET             0x898
-#define AM335x_CTRL_MODULE_CONF_GPMC_BEN0_CLE_OFFSET        0x89C
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA0_OFFSET            0x8A0
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA1_OFFSET            0x8A4
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA2_OFFSET            0x8A8
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA3_OFFSET            0x8AC
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA4_OFFSET            0x8B0
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA5_OFFSET            0x8B4
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA6_OFFSET            0x8B8
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA7_OFFSET            0x8BC
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA8_OFFSET            0x8C0
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA9_OFFSET            0x8C4
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA10_OFFSET           0x8C8
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA11_OFFSET           0x8CC
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA12_OFFSET           0x8D0
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA13_OFFSET           0x8D4
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA14_OFFSET           0x8D8
-#define AM335x_CTRL_MODULE_CONF_LCD_DATA15_OFFSET           0x8DC
-#define AM335x_CTRL_MODULE_CONF_LCD_VSYNC_OFFSET            0x8E0
-#define AM335x_CTRL_MODULE_CONF_LCD_HSYNC_OFFSET            0x8E4
-#define AM335x_CTRL_MODULE_CONF_LCD_PCLK_OFFSET             0x8E8
-#define AM335x_CTRL_MODULE_CONF_LCD_AC_BIAS_EN_OFFSET       0x8EC
-#define AM335x_CTRL_MODULE_CONF_MMC0_DAT3_OFFSET            0x8F0
-#define AM335x_CTRL_MODULE_CONF_MMC0_DAT2_OFFSET            0x8F4
-#define AM335x_CTRL_MODULE_CONF_MMC0_DAT1_OFFSET            0x8F8
-#define AM335x_CTRL_MODULE_CONF_MMC0_DAT0_OFFSET            0x8FC
-#define AM335x_CTRL_MODULE_CONF_MMC0_CLK_OFFSET             0x900
-#define AM335x_CTRL_MODULE_CONF_MMC0_CMD_OFFSET             0x904
-#define AM335x_CTRL_MODULE_CONF_MII1_COL_OFFSET             0x908
-#define AM335x_CTRL_MODULE_CONF_MII1_CRS_OFFSET             0x90C
-#define AM335x_CTRL_MODULE_CONF_MII1_RX_ER_OFFSET           0x910
-#define AM335x_CTRL_MODULE_CONF_MII1_TX_EN_OFFSET           0x914
-#define AM335x_CTRL_MODULE_CONF_MII1_RX_DV_OFFSET           0x918
-#define AM335x_CTRL_MODULE_CONF_MII1_TXD3_OFFSET            0x91C
-#define AM335x_CTRL_MODULE_CONF_MII1_TXD2_OFFSET            0x920
-#define AM335x_CTRL_MODULE_CONF_MII1_TXD1_OFFSET            0x924
-#define AM335x_CTRL_MODULE_CONF_MII1_TXD0_OFFSET            0x928
-#define AM335x_CTRL_MODULE_CONF_MII1_TX_CLK_OFFSET          0x92C
-#define AM335x_CTRL_MODULE_CONF_MII1_RX_CLK_OFFSET          0x930
-#define AM335x_CTRL_MODULE_CONF_MII1_RXD3_OFFSET            0x934
-#define AM335x_CTRL_MODULE_CONF_MII1_RXD2_OFFSET            0x938
-#define AM335x_CTRL_MODULE_CONF_MII1_RXD1_OFFSET            0x93C
-#define AM335x_CTRL_MODULE_CONF_MII1_RXD0_OFFSET            0x940
-#define AM335x_CTRL_MODULE_CONF_RMII1_REF_CLK_OFFSET        0x944
-#define AM335x_CTRL_MODULE_CONF_MDIO_OFFSET                 0x948
-#define AM335x_CTRL_MODULE_CONF_MDC_OFFSET                  0x94C
-#define AM335x_CTRL_MODULE_CONF_SPI0_SCLK_OFFSET            0x950
-#define AM335x_CTRL_MODULE_CONF_SPI0_D0_OFFSET              0x954
-#define AM335x_CTRL_MODULE_CONF_SPI0_D1_OFFSET              0x958
-#define AM335x_CTRL_MODULE_CONF_SPI0_CS0_OFFSET             0x95C
-#define AM335x_CTRL_MODULE_CONF_SPI0_CS1_OFFSET             0x960
-#define AM335x_CTRL_MODULE_CONF_ECAP0_IN_PWM0_OUT_OFFSET    0x964
-#define AM335x_CTRL_MODULE_CONF_UART0_CTSN_OFFSET           0x968
-#define AM335x_CTRL_MODULE_CONF_UART0_RTSN_OFFSET           0x96C
-#define AM335x_CTRL_MODULE_CONF_UART0_RXD_OFFSET            0x970
-#define AM335x_CTRL_MODULE_CONF_UART0_TXD_OFFSET            0x974
-#define AM335x_CTRL_MODULE_CONF_UART1_CTSN_OFFSET           0x978
-#define AM335x_CTRL_MODULE_CONF_UART1_RTSN_OFFSET           0x97C
-#define AM335x_CTRL_MODULE_CONF_UART1_RXD_OFFSET            0x980
-#define AM335x_CTRL_MODULE_CONF_UART1_TXD_OFFSET            0x984
-#define AM335x_CTRL_MODULE_CONF_I2C0_SDA_OFFSET             0x988
-#define AM335x_CTRL_MODULE_CONF_I2C0_SCL_OFFSET             0x98C
-#define AM335x_CTRL_MODULE_CONF_MCASP0_ACLKX_OFFSET         0x990
-#define AM335x_CTRL_MODULE_CONF_MCASP0_FSX_OFFSET           0x994
-#define AM335x_CTRL_MODULE_CONF_MCASP0_AXR0_OFFSET          0x998
-#define AM335x_CTRL_MODULE_CONF_MCASP0_AHCLKR_OFFSET        0x99C
-#define AM335x_CTRL_MODULE_CONF_MCASP0_ACLKR_OFFSET         0x9A0
-#define AM335x_CTRL_MODULE_CONF_MCASP0_FSR_OFFSET           0x9A4
-#define AM335x_CTRL_MODULE_CONF_MCASP0_AXR1_OFFSET          0x9A8
-#define AM335x_CTRL_MODULE_CONF_MCASP0_AHCLKX_OFFSET        0x9AC
-#define AM335x_CTRL_MODULE_CONF_XDMA_EVENT_INTR0_OFFSET     0x9B0
-#define AM335x_CTRL_MODULE_CONF_XDMA_EVENT_INTR1_OFFSET     0x9B4
-#define AM335x_CTRL_MODULE_CONF_WARMRSTN_OFFSET             0x9B8
-#define AM335x_CTRL_MODULE_CONF_PWRONRSTN_OFFSET            0x9BC
-#define AM335x_CTRL_MODULE_CONF_NNMI_OFFSET                 0x9C0
-#define AM335x_CTRL_MODULE_CONF_XTALIN_OFFSET               0x9C4
-#define AM335x_CTRL_MODULE_CONF_XTALOUT_OFFSET              0x9C8
-#define AM335x_CTRL_MODULE_CONF_TMS_OFFSET                  0x9D0
-#define AM335x_CTRL_MODULE_CONF_TDI_OFFSET                  0x9D4
-#define AM335x_CTRL_MODULE_CONF_TDO_OFFSET                  0x9D8
-#define AM335x_CTRL_MODULE_CONF_TCK_OFFSET                  0x9DC
-#define AM335x_CTRL_MODULE_CONF_TRSTN_OFFSET                0x9E0
-#define AM335x_CTRL_MODULE_CONF_EMU0_OFFSET                 0x9E4
-#define AM335x_CTRL_MODULE_CONF_EMU1_OFFSET                 0x9E8
-#define AM335x_CTRL_MODULE_CONF_RTC_XTALIN_OFFSET           0x9EC
-#define AM335x_CTRL_MODULE_CONF_RTC_XTALOUT_OFFSET          0x9F0
-#define AM335x_CTRL_MODULE_CONF_RTC_PWRONRSTN_OFFSET        0x9F8
-#define AM335x_CTRL_MODULE_CONF_PMIC_POWER_EN_OFFSET        0x9FC
-#define AM335x_CTRL_MODULE_CONF_EXT_WAKEUP_OFFSET           0xA00
-#define AM335x_CTRL_MODULE_CONF_RTC_KALDO_ENN_OFFSET        0xA04
-#define AM335x_CTRL_MODULE_CONF_USB0_DM_OFFSET              0xA08
-#define AM335x_CTRL_MODULE_CONF_USB0_DP_OFFSET              0xA0C
-#define AM335x_CTRL_MODULE_CONF_USB0_CE_OFFSET              0xA10
-#define AM335x_CTRL_MODULE_CONF_USB0_ID_OFFSET              0xA14
-#define AM335x_CTRL_MODULE_CONF_USB0_VBUS_OFFSET            0xA18
-#define AM335x_CTRL_MODULE_CONF_USB0_DRVVBUS_OFFSET         0xA1C
-#define AM335x_CTRL_MODULE_CONF_USB1_DM_OFFSET              0xA20
-#define AM335x_CTRL_MODULE_CONF_USB1_DP_OFFSET              0xA24
-#define AM335x_CTRL_MODULE_CONF_USB1_CE_OFFSET              0xA28
-#define AM335x_CTRL_MODULE_CONF_USB1_ID_OFFSET              0xA2C
-#define AM335x_CTRL_MODULE_CONF_USB1_VBUS_OFFSET            0xA30
-#define AM335x_CTRL_MODULE_CONF_USB1_DRVVBUS_OFFSET         0xA34
-#define AM335x_CTRL_MODULE_CQDETECT_STATUS_OFFSET           0xE00
-#define AM335x_CTRL_MODULE_DDR_IO_CTRL_OFFSET               0xE04
-#define AM335x_CTRL_MODULE_VTP_CTRL_OFFSET                  0xE0C
-#define AM335x_CTRL_MODULE_VREF_CTRL_OFFSET                 0xE14
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_0_3_OFFSET          0xF90
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_4_7_OFFSET          0xF94
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_8_11_OFFSET         0xF98
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_12_15_OFFSET        0xF9C
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_16_19_OFFSET        0xFA0
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_20_23_OFFSET        0xFA4
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_24_27_OFFSET        0xFA8
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_28_31_OFFSET        0xFAC
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_32_35_OFFSET        0xFB0
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_36_39_OFFSET        0xFB4
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_40_43_OFFSET        0xFB8
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_44_47_OFFSET        0xFBC
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_48_51_OFFSET        0xFC0
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_52_55_OFFSET        0xFC4
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_56_59_OFFSET        0xFC8
-#define AM335x_CTRL_MODULE_TPCC_EVT_MUX_60_63_OFFSET        0xFCC
-#define AM335x_CTRL_MODULE_TIMER_EVT_CAPT_OFFSET            0xFD0
-#define AM335x_CTRL_MODULE_ECAP_EVT_CAPT_OFFSET             0xFD4
-#define AM335x_CTRL_MODULE_ADC_EVT_CAPT_OFFSET              0xFD8
-#define AM335x_CTRL_MODULE_RESET_ISO_OFFSET                 0x1000
-#define AM335x_CTRL_MODULE_DDR_CKE_CTRL_OFFSET              0x131C
-#define AM335x_CTRL_MODULE_SMA2_OFFSET                      0x1320
-#define AM335x_CTRL_MODULE_M3_TXEV_EOI_OFFSET               0x1324
-#define AM335x_CTRL_MODULE_IPC_MSG_REG0_OFFSET              0x1328
-#define AM335x_CTRL_MODULE_IPC_MSG_REG1_OFFSET              0x132C
-#define AM335x_CTRL_MODULE_IPC_MSG_REG2_OFFSET              0x1330
-#define AM335x_CTRL_MODULE_IPC_MSG_REG3_OFFSET              0x1334
-#define AM335x_CTRL_MODULE_IPC_MSG_REG4_OFFSET              0x1338
-#define AM335x_CTRL_MODULE_IPC_MSG_REG5_OFFSET              0x133C
-#define AM335x_CTRL_MODULE_IPC_MSG_REG6_OFFSET              0x1340
-#define AM335x_CTRL_MODULE_IPC_MSG_REG7_OFFSET              0x1344
-#define AM335x_CTRL_MODULE_DDR_CMD0_IOCTRL_OFFSET           0x1404
-#define AM335x_CTRL_MODULE_DDR_CMD1_IOCTRL_OFFSET           0x1408
-#define AM335x_CTRL_MODULE_DDR_CMD2_IOCTRL_OFFSET           0x140C
-#define AM335x_CTRL_MODULE_DDR_DATA0_IOCTRL_OFFSET          0x1440
-#define AM335x_CTRL_MODULE_DDR_DATA1_IOCTRL_OFFSET          0x1444
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/am335x/iomux.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/iomux.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,268 +1,0 @@
-/*
- * Copyright (c) 2012 Matteo Facchinetti
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 Texas Instruments AM335x CONTROL_MODULE: I/O multiplexing.
- */
-
-#ifndef KERN_AM335X_IOMUX_H_
-#define KERN_AM335X_IOMUX_H_
-
-#include <typedefs.h>
-
-/* Pad Control Register for each configurable pin p. 876 */
-#define AM335X_IOMUX_SLEWRATE_SLOW_FLAG  (1 << 6)
-#define AM335X_IOMUX_RX_ENABLE_FLAG  (1 << 5)
-#define AM335X_IOMUX_PULLUP_FLAG  (1 << 4)
-#define AM335X_IOMUX_PULLUPDOWN_ENABLE_FLAG  (1 << 3)
-#define AM335X_IOMUX_MODE0  0
-#define AM335X_IOMUX_MODE1  1
-#define AM335X_IOMUX_MODE2  2
-#define AM335X_IOMUX_MODE3  3
-#define AM335X_IOMUX_MODE4  4
-#define AM335X_IOMUX_MODE5  5
-#define AM335X_IOMUX_MODE6  6
-#define AM335X_IOMUX_MODE7  7
-
-/* AM335X CONTROL_MODULE configurable I/O pin. Table 9-10 at p. 886 */
-#define AM335X_IOMUX_CONF_BASE_ADDRESS 0x44E10800
-
-typedef struct {
-	ioport32_t gpmc_ad1;
-	ioport32_t gpmc_ad2;
-	ioport32_t gpmc_ad3;
-	ioport32_t gpmc_ad4;
-	ioport32_t gpmc_ad5;
-	ioport32_t gpmc_ad6;
-	ioport32_t gpmc_ad7;
-	ioport32_t gpmc_ad8;
-	ioport32_t gpmc_ad9;
-	ioport32_t gpmc_ad10;
-	ioport32_t gpmc_ad11;
-	ioport32_t gpmc_ad12;
-	ioport32_t gpmc_ad13;
-	ioport32_t gpmc_ad14;
-	ioport32_t gpmc_ad15;
-	ioport32_t gpmc_a0;
-	ioport32_t gpmc_a1;
-	ioport32_t gpmc_a2;
-	ioport32_t gpmc_a3;
-	ioport32_t gpmc_a4;
-	ioport32_t gpmc_a5;
-	ioport32_t gpmc_a6;
-	ioport32_t gpmc_a7;
-	ioport32_t gpmc_a8;
-	ioport32_t gpmc_a9;
-	ioport32_t gpmc_a10;
-	ioport32_t gpmc_a11;
-	ioport32_t gpmc_wait0;
-	ioport32_t gpmc_wpn;
-	ioport32_t gpmc_be1n;
-	ioport32_t gpmc_csn0;
-	ioport32_t gpmc_csn1;
-	ioport32_t gpmc_csn2;
-	ioport32_t gpmc_csn3;
-	ioport32_t gpmc_clk;
-	ioport32_t gpmc_advn_ale;
-	ioport32_t gpmc_oen_ren;
-	ioport32_t gpmc_wen;
-	ioport32_t gpmc_be0n_cle;
-	ioport32_t lcd_data0;
-	ioport32_t lcd_data1;
-	ioport32_t lcd_data2;
-	ioport32_t lcd_data3;
-	ioport32_t lcd_data4;
-	ioport32_t lcd_data5;
-	ioport32_t lcd_data6;
-	ioport32_t lcd_data7;
-	ioport32_t lcd_data8;
-	ioport32_t lcd_data9;
-	ioport32_t lcd_data10;
-	ioport32_t lcd_data11;
-	ioport32_t lcd_data12;
-	ioport32_t lcd_data13;
-	ioport32_t lcd_data14;
-	ioport32_t lcd_data15;
-	ioport32_t lcd_vsync;
-	ioport32_t lcd_hsync;
-	ioport32_t lcd_pclk;
-	ioport32_t lcd_ac_bias_en;
-	ioport32_t mmc0_dat3;
-	ioport32_t mmc0_dat2;
-	ioport32_t mmc0_dat1;
-	ioport32_t mmc0_dat0;
-	ioport32_t mmc0_clk;
-	ioport32_t mmc0_cmd;
-	ioport32_t mii1_col;
-	ioport32_t mii1_crs;
-	ioport32_t mii1_rxerr;
-	ioport32_t mii1_txen;
-	ioport32_t mii1_rxdv;
-	ioport32_t mii1_txd3;
-	ioport32_t mii1_txd2;
-	ioport32_t mii1_txd1;
-	ioport32_t mii1_txd0;
-	ioport32_t mii1_txclk;
-	ioport32_t mii1_rxclk;
-	ioport32_t mii1_rxd3;
-	ioport32_t mii1_rxd2;
-	ioport32_t mii1_rxd1;
-	ioport32_t mii1_rxd0;
-	ioport32_t rmii1_refclk;
-	ioport32_t mdio_data;
-	ioport32_t mdio_clk;
-	ioport32_t spi0_sclk;
-	ioport32_t spi0_d0;
-	ioport32_t spi0_d1;
-	ioport32_t spi0_cs0;
-	ioport32_t spi0_cs1;
-	ioport32_t ecap0_in_pwm0_out;
-	ioport32_t uart0_ctsn;
-	ioport32_t uart0_rtsn;
-	ioport32_t uart0_rxd;
-	ioport32_t uart0_txd;
-	ioport32_t uart1_ctsn;
-	ioport32_t uart1_rtsn;
-	ioport32_t uart1_rxd;
-	ioport32_t uart1_txd;
-	ioport32_t i2c0_sda;
-	ioport32_t i2c0_scl;
-	ioport32_t mcasp0_aclkx;
-	ioport32_t mcasp0_fsx;
-	ioport32_t mcasp0_axr0;
-	ioport32_t mcasp0_ahclkr;
-	ioport32_t mcasp0_aclkr;
-	ioport32_t mcasp0_fsr;
-	ioport32_t mcasp0_axr1;
-	ioport32_t mcasp0_ahclkx;
-	ioport32_t xdma_event_intr0;
-	ioport32_t xdma_event_intr1;
-	ioport32_t nresetin_out;
-	ioport32_t porz;
-	ioport32_t nnmi;
-	ioport32_t osc0_in;
-	ioport32_t osc0_out;
-	ioport32_t osc0_vss;
-	ioport32_t tms;
-	ioport32_t tdi;
-	ioport32_t tdo;
-	ioport32_t tck;
-	ioport32_t ntrst;
-	ioport32_t emu0;
-	ioport32_t emu1;
-	ioport32_t osc1_in;
-	ioport32_t osc1_out;
-	ioport32_t osc1_vss;
-	ioport32_t rtc_porz;
-	ioport32_t pmic_power_en;
-	ioport32_t ext_wakeup;
-	ioport32_t enz_kaldo_1p8v;
-	ioport32_t usb0_dm;
-	ioport32_t usb0_dp;
-	ioport32_t usb0_ce;
-	ioport32_t usb0_id;
-	ioport32_t usb0_vbus;
-	ioport32_t usb0_drvvbus;
-	ioport32_t usb1_dm;
-	ioport32_t usb1_dp;
-	ioport32_t usb1_ce;
-	ioport32_t usb1_id;
-	ioport32_t usb1_vbus;
-	ioport32_t usb1_drvvbus;
-	ioport32_t ddr_resetn;
-	ioport32_t ddr_csn0;
-	ioport32_t ddr_cke;
-	ioport32_t ddr_ck;
-	ioport32_t ddr_nck;
-	ioport32_t ddr_casn;
-	ioport32_t ddr_rasn;
-	ioport32_t ddr_wen;
-	ioport32_t ddr_ba0;
-	ioport32_t ddr_ba1;
-	ioport32_t ddr_ba2;
-	ioport32_t ddr_a0;
-	ioport32_t ddr_a1;
-	ioport32_t ddr_a2;
-	ioport32_t ddr_a3;
-	ioport32_t ddr_a4;
-	ioport32_t ddr_a5;
-	ioport32_t ddr_a6;
-	ioport32_t ddr_a7;
-	ioport32_t ddr_a8;
-	ioport32_t ddr_a9;
-	ioport32_t ddr_a10;
-	ioport32_t ddr_a11;
-	ioport32_t ddr_a12;
-	ioport32_t ddr_a13;
-	ioport32_t ddr_a14;
-	ioport32_t ddr_a15;
-	ioport32_t ddr_odt;
-	ioport32_t ddr_d0;
-	ioport32_t ddr_d1;
-	ioport32_t ddr_d2;
-	ioport32_t ddr_d3;
-	ioport32_t ddr_d4;
-	ioport32_t ddr_d5;
-	ioport32_t ddr_d6;
-	ioport32_t ddr_d7;
-	ioport32_t ddr_d8;
-	ioport32_t ddr_d9;
-	ioport32_t ddr_d10;
-	ioport32_t ddr_d11;
-	ioport32_t ddr_d12;
-	ioport32_t ddr_d13;
-	ioport32_t ddr_d14;
-	ioport32_t ddr_d15;
-	ioport32_t ddr_dqm0;
-	ioport32_t ddr_dqm1;
-	ioport32_t ddr_dqs0;
-	ioport32_t ddr_dqsn0;
-	ioport32_t ddr_dqs1;
-	ioport32_t ddr_dqsn1;
-	ioport32_t ddr_vref;
-	ioport32_t ddr_vtp;
-	ioport32_t ain7;
-	ioport32_t ain6;
-	ioport32_t ain5;
-	ioport32_t ain4;
-	ioport32_t ain3;
-	ioport32_t ain2;
-	ioport32_t ain1;
-	ioport32_t ain0;
-	ioport32_t vrefp;
-	ioport32_t vrefn;
-	ioport32_t avdd;
-	ioport32_t avss;
-	ioport32_t iforce;
-	ioport32_t vsense;
-	ioport32_t testout;
-} am335x_iomux_conf_regs_t;
-#endif /* KERN_AM335X_IOMUX_H_ */
Index: rnel/genarch/include/genarch/drivers/am335x/irc.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/irc.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,255 +1,0 @@
-/*
- * Copyright (c) 2012 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-
-/**
- * @file
- * @brief Texas Instruments AM335x MPU on-chip interrupt controller driver.
- */
-
-#ifndef KERN_AM335x_IRQC_H_
-#define KERN_AM335x_IRQC_H_
-
-#define AM335x_IRC_BASE_ADDRESS 0x48200000
-#define AM335x_IRC_SIZE         4096
-
-#define AM335x_IRC_IRQ_COUNT    128
-
-#include <typedefs.h>
-
-typedef struct {
-	const ioport32_t revision;
-#define AM335x_IRC_REV_MASK 0xFF
-
-	const uint8_t padd0[12];
-
-	/* This register controls the various parameters
-	 * of the OCP interface.
-	 */
-	ioport32_t sysconfig;
-#define AM335x_IRC_SYSCONFIG_AUTOIDLE_FLAG   (1 << 0)
-#define AM335x_IRC_SYSCONFIG_SOFTRESET_FLAG  (1 << 1)
-
-	/* This register provides status information about the module */
-	const ioport32_t sysstatus;
-#define AM335x_IRC_SYSSTATUS_RESET_DONE_FLAG (1 << 0)
-
-	const uint8_t padd1[40];
-
-	/* This register supplies the currently active IRQ interrupt number */
-	ioport32_t sir_irq;
-#define AM335x_IRC_SIR_IRQ_ACTIVEIRQ_MASK       0x7F
-#define AM335x_IRC_SIR_IRQ_SPURIOUSIRQFLAG_MASK 0xFFFFFFF8
-
-	/* This register supplies the currently active FIQ interrupt number */
-	const ioport32_t sir_fiq;
-#define AM335x_IRC_FIQ_IRQ_ACTIVEFIQ_MASK       0x7F
-#define AM335x_IRC_FIQ_IRQ_SPURIOUSFIQFLAG_MASK 0xFFFFFFF8
-
-	/* This register contains the new interrupt agreement bits */
-	ioport32_t control;
-#define AM335x_IRC_CONTROL_NEWIRQAGR_FLAG       (1 << 0)
-#define AM335x_IRC_CONTROL_NEWFIQAGR_FLAG       (1 << 1)
-
-	/* This register controls protection of the other registers.
-	 * This register can only be accessed in priviledged mode, regardless
-	 * of the current value of the protection bit.
-	 */
-	ioport32_t protection;
-#define AM335x_IRC_PROTECTION_FLAG              (1 << 0)
-
-	/* This register controls the clock auto-idle for the functional
-	 * clock and the input synchronizers.
-	 */
-	ioport32_t idle;
-#define AM335x_IRC_IDLE_FUNCIDLE_FLAG           (1 << 0)
-#define AM335x_IRC_IDLE_TURBO_FLAG              (1 << 1)
-
-	const uint8_t padd2[12];
-
-	/* This register supplies the currently active IRQ priority level */
-	const ioport32_t irq_priority;
-#define AM335x_IRC_IRQ_PRIORITY_IRQPRIORITY_MASK     0x7F
-#define AM335x_IRC_IRQ_PRIORITY_SPURIOUSIRQFLAG_MASK 0xFFFFFFF8
-
-	/* This register supplies the currently active FIQ priority level */
-	const ioport32_t fiq_priority;
-#define AM335x_IRC_FIQ_PRIORITY_FIQPRIORITY_MASK     0x7F
-#define AM335x_IRC_FIQ_PRIORITY_SPURIOUSIRQFLAG_MASK 0xFFFFFFF8
-
-	/* This register sets the priority threshold */
-	ioport32_t threshold;
-#define AM335x_IRC_THRESHOLD_PRIORITYTHRESHOLD_MASK     0xFF
-#define AM335x_IRC_THRESHOLD_PRIORITYTHRESHOLD_ENABLED  0x00
-#define AM335x_IRC_THRESHOLD_PRIORITYTHRESHOLD_DISABLED 0xFF
-
-	const uint8_t padd[20];
-
-	struct {
-		/* Raw interrupt input status before masking */
-		const ioport32_t itr;
-
-		/* Interrupt mask */
-		ioport32_t mir;
-
-		/* This register is used to clear the interrupt mask bits,
-		 * Write 1 clears the mask bit to 0.
-		 */
-		ioport32_t mir_clear;
-
-		/* This register is used to set the interrupt mask bits,
-		 * Write 1 sets the mask bit to 1.
-		 */
-		ioport32_t mir_set;
-
-		/* This register is used to set the software interrupt bits,
-		 * it is also used to read the current active software
-		 * interrupts.
-		 * Write 1 sets the software interrups bits to 1.
-		 */
-		ioport32_t isr_set;
-
-		/* This register is used to clear the software interrups bits.
-		 * Write 1 clears the software interrupt bits to 0.
-		 */
-		ioport32_t isr_clear;
-
-		/* This register contains the IRQ status after masking. */
-		const ioport32_t pending_irq;
-
-		/* This register contains the FIQ status after masking. */
-		const ioport32_t pending_fiq;
-	} interrupts[4];
-
-	/* These registers contain the priority for the interrups and
-	 * the FIQ/IRQ steering.
-	 */
-	ioport32_t ilr[AM335x_IRC_IRQ_COUNT];
-/* 0 = Interrupt routed to IRQ, 1 = interrupt routed to FIQ */
-#define AM335x_IRC_ILR_FIQNIRQ_FLAG    (1 << 0)
-#define AM335x_IRC_ILR_PRIORITY_MASK   0x3F
-#define AM335x_IRC_ILR_PRIORITY_SHIFT  2
-
-} am335x_irc_regs_t;
-
-static inline void am335x_irc_init(am335x_irc_regs_t *regs)
-{
-	int i;
-
-	/* Initialization sequence */
-
-	/* 1 - Program the SYSCONFIG register: if necessary, enable the
-	 *     autogating by setting the AUTOIDLE bit.
-	 */
-	regs->sysconfig &= ~AM335x_IRC_SYSCONFIG_AUTOIDLE_FLAG;
-
-	/* 2 - Program the IDLE register: if necessary, disable functional
-	 *     clock autogating or enable synchronizer autogating by setting
-	 *     the FUNCIDLE bit or the TURBO bit accordingly.
-	 */
-	regs->idle &= ~AM335x_IRC_IDLE_FUNCIDLE_FLAG;
-	regs->idle &= ~AM335x_IRC_IDLE_TURBO_FLAG;
-
-	/* 3 - Program ILRm register for each interrupt line: Assign a
-	 *     priority level and set the FIQNIRQ bit for an FIQ interrupt
-	 *     (by default, interrupts are mapped to IRQ and
-	 *     priority is 0 (highest).
-	 */
-
-	for (i = 0; i < AM335x_IRC_IRQ_COUNT; ++i)
-		regs->ilr[i] = 0;
-
-	/* 4 - Program the MIRn register: Enable interrupts (by default,
-	 *     all interrupt lines are masked).
-	 */
-	for (i = 0; i < 4; ++i)
-		regs->interrupts[i].mir_set = 0xFFFFFFFF;
-}
-
-/** Get the currently active IRQ interrupt number
- *
- * @param regs     Pointer to the irc memory mapped registers
- *
- * @return         The active IRQ interrupt number
- */
-static inline unsigned am335x_irc_inum_get(am335x_irc_regs_t *regs)
-{
-	return regs->sir_irq & AM335x_IRC_SIR_IRQ_ACTIVEIRQ_MASK;
-}
-
-/** Reset IRQ output and enable new IRQ generation
- *
- * @param regs    Pointer to the irc memory mapped registers
- */
-static inline void am335x_irc_irq_ack(am335x_irc_regs_t *regs)
-{
-	regs->control = AM335x_IRC_CONTROL_NEWIRQAGR_FLAG;
-}
-
-/** Reset FIQ output and enable new FIQ generation
- *
- * @param regs    Pointer to the irc memory mapped registers
- */
-static inline void am335x_irc_fiq_ack(am335x_irc_regs_t *regs)
-{
-	regs->control = AM335x_IRC_CONTROL_NEWFIQAGR_FLAG;
-}
-
-/** Clear an interrupt mask bit
- *
- * @param regs    Pointer to the irc memory mapped registers
- * @param inum    The interrupt to be enabled
- */
-static inline void am335x_irc_enable(am335x_irc_regs_t *regs, unsigned inum)
-{
-	ASSERT(inum < AM335x_IRC_IRQ_COUNT);
-	const unsigned set = inum / 32;
-	const unsigned pos = inum % 32;
-	regs->interrupts[set].mir_clear = (1 << pos);
-}
-
-/** Set an interrupt mask bit
- *
- * @param regs    Pointer to the irc memory mapped registers
- * @param inum    The interrupt to be disabled
- */
-static inline void am335x_irc_disable(am335x_irc_regs_t *regs, unsigned inum)
-{
-	ASSERT(inum < AM335x_IRC_IRQ_COUNT);
-	const unsigned set = inum / 32;
-	const unsigned pos = inum % 32;
-	regs->interrupts[set].mir_set = (1 << pos);
-}
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/am335x/timer.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/timer.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,100 +1,0 @@
-/*
- * Copyright (c) 2012 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x timer driver.
- */
-
-#ifndef _KERN_AM335X_TIMER_H_
-#define _KERN_AM335X_TIMER_H_
-
-#include <genarch/drivers/am335x/timer_regs.h>
-
-#define AM335x_DMTIMER0_BASE_ADDRESS    0x44E05000
-#define AM335x_DMTIMER0_SIZE            4096
-#define AM335x_DMTIMER0_IRQ             66
-
-#define AM335x_DMTIMER2_BASE_ADDRESS    0x48040000
-#define AM335x_DMTIMER2_SIZE            4096
-#define AM335x_DMTIMER2_IRQ             68
-
-#define AM335x_DMTIMER3_BASE_ADDRESS    0x48042000
-#define AM335x_DMTIMER3_SIZE            4096
-#define AM335x_DMTIMER3_IRQ             69
-
-#define AM335x_DMTIMER4_BASE_ADDRESS    0x48044000
-#define AM335x_DMTIMER4_SIZE            4096
-#define AM335x_DMTIMER4_IRQ             92
-
-#define AM335x_DMTIMER5_BASE_ADDRESS    0x48046000
-#define AM335x_DMTIMER5_SIZE            4096
-#define AM335x_DMTIMER5_IRQ             93
-
-#define AM335x_DMTIMER6_BASE_ADDRESS    0x48048000
-#define AM335x_DMTIMER6_SIZE            4096
-#define AM335x_DMTIMER6_IRQ             94
-
-#define AM335x_DMTIMER7_BASE_ADDRESS    0x4804A000
-#define AM335x_DMTIMER7_SIZE            4096
-#define AM335x_DMTIMER7_IRQ             95
-
-typedef enum {
-	DMTIMER0 = 0,
-	DMTIMER1_1MS,
-	DMTIMER2,
-	DMTIMER3,
-	DMTIMER4,
-	DMTIMER5,
-	DMTIMER6,
-	DMTIMER7,
-
-	TIMERS_MAX
-} am335x_timer_id_t;
-
-typedef struct am335x_timer {
-	am335x_timer_regs_t *regs;
-	am335x_timer_id_t id;
-} am335x_timer_t;
-
-extern int am335x_timer_init(am335x_timer_t *timer, am335x_timer_id_t id,
-    unsigned hz, unsigned srcclk_hz);
-extern void am335x_timer_intr_ack(am335x_timer_t *timer);
-extern void am335x_timer_reset(am335x_timer_t *timer);
-extern void am335x_timer_start(am335x_timer_t *timer);
-extern void am335x_timer_stop(am335x_timer_t *timer);
-
-
-#endif
-
-/**
- * @}
- */
-
Index: rnel/genarch/include/genarch/drivers/am335x/timer_regs.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/timer_regs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,159 +1,0 @@
-/*
- * Copyright (c) 2012 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x DMTIMER memory mapped registers.
- */
-
-#ifndef _KERN_AM335X_TIMER_REGS_H_
-#define _KERN_AM335X_TIMER_REGS_H_
-
-#include <typedefs.h>
-
-typedef struct am335x_timer_regs {
-
-	/* This read only register contains the
-	 * revision number of the module
-	 */
-	ioport32_t const tidr;
-#define AM335x_TIMER_TIDR_MINOR_MASK     0x3F
-#define AM335x_TIMER_TIDR_MINOR_SHIFT    0
-#define AM335x_TIMER_TIDR_CUSTOM_MASK    0x03
-#define AM335x_TIMER_TIDR_CUSTOM_SHIFT   6
-#define AM335x_TIMER_TIDR_MAJOR_MASK     0x07
-#define AM335x_TIMER_TIDR_MAJOR_SHIFT    8
-#define AM335x_TIMER_TIDR_RTL_MASK       0x1F
-#define AM335x_TIMER_TIDR_RTL_SHIFT      11
-#define AM335x_TIMER_TIDR_FUNC_MASK      0xFFF
-#define AM335x_TIMER_TIDR_FUNC_SHIFT     16
-#define AM335x_TIMER_TIDR_SCHEME_MASK    0x03
-#define AM335x_TIMER_TIDR_SCHEME_SHIFT   30
-
-	ioport32_t const pad1[3];
-
-	/* This register allows controlling various
-	 * parameters of the OCP interface.
-	 */
-	ioport32_t tiocp_cfg;
-#define AM335x_TIMER_TIOCPCFG_SOFTRESET_FLAG    (1 << 0)
-#define AM335x_TIMER_TIOCPCFG_EMUFREE_FLAG      (1 << 1)
-
-#define AM335x_TIMER_TIOCPCFG_IDLEMODE_MASK            0x02
-#define AM335x_TIMER_TIOCPCFG_IDLEMODE_SHIFT           2
-#  define AM335x_TIMER_TIOCCPCFG_IDLEMODE_FORCE        0x00
-#  define AM335x_TIMER_TIOCCPCFG_IDLEMODE_DISABLED     0x01
-#  define AM335x_TIMER_TIOCCPCFG_IDLEMODE_SMART        0x02
-#  define AM335x_TIMER_TIOCCPCFG_IDLEMODE_SMART_WAKEUP 0x03
-
-	ioport32_t const pad2[4];
-
-	ioport32_t irqstatus_raw;
-#define AM335x_TIMER_IRQSTATUS_RAW_MAT_FLAG     (1 << 0)
-#define AM335x_TIMER_IRQSTATUS_RAW_OVF_FLAG     (1 << 1)
-#define AM335x_TIMER_IRQSTATUS_RAW_TCAR_FLAG    (1 << 2)
-
-	ioport32_t irqstatus;
-#define AM335x_TIMER_IRQSTATUS_MAT_FLAG     (1 << 0)
-#define AM335x_TIMER_IRQSTATUS_OVF_FLAG     (1 << 1)
-#define AM335x_TIMER_IRQSTATUS_TCAR_FLAG    (1 << 2)
-
-	ioport32_t irqenable_set;
-#define AM335x_TIMER_IRQENABLE_SET_MAT_FLAG (1 << 0)
-#define AM335x_TIMER_IRQENABLE_SET_OVF_FLAG (1 << 1)
-#define AM335x_TIMER_IRQENABLE_SET_TCAR_FLAG (1 << 2)
-
-	ioport32_t irqenable_clr;
-#define AM335x_TIMER_IRQENABLE_CLR_MAT_FLAG (1 << 0)
-#define AM335x_TIMER_IRQENABLE_CLR_OVF_FLAG (1 << 1)
-#define AM335x_TIMER_IRQENABLE_CLR_TCAR_FLAG (1 << 2)
-
-	/* Timer IRQ wakeup enable register */
-	ioport32_t irqwakeen;
-#define AM335x_TIMER_IRQWAKEEN_MAT_FLAG     (1 << 0)
-#define AM335x_TIMER_IRQWAKEEN_OVF_FLAG     (1 << 1)
-#define AM335x_TIMER_IRQWAKEEN_TCAR_FLAG    (1 << 2)
-
-	/* Timer control register */
-	ioport32_t tclr;
-#define AM335x_TIMER_TCLR_ST_FLAG           (1 << 0)
-#define AM335x_TIMER_TCLR_AR_FLAG           (1 << 1)
-#define AM335x_TIMER_TCLR_PTV_MASK          0x07
-#define AM335x_TIMER_TCLR_PTV_SHIFT         2
-#define AM335x_TIMER_TCLR_PRE_FLAG          (1 << 5)
-#define AM335x_TIMER_TCLR_CE_FLAG           (1 << 6)
-#define AM335x_TIMER_TCLR_SCPWM_FLAG        (1 << 7)
-#define AM335x_TIMER_TCLR_TCM_MASK          0x03
-#define AM335x_TIMER_TCLR_TCM_SHIFT         8
-#define AM335x_TIMER_TCLR_TGR_MASK          0x03
-#define AM335x_TIMER_TCLR_TGR_SHIFT         10
-#define AM335x_TIMER_TCLR_PT_FLAG           (1 << 12)
-#define AM335x_TIMER_TCLR_CAPT_MODE_FLAG    (1 << 13)
-#define AM335x_TIMER_TCLR_GPO_CFG_FLAG      (1 << 14)
-
-	/* Timer counter register */
-	ioport32_t tcrr;
-
-	/* Timer load register */
-	ioport32_t tldr;
-
-	/* Timer trigger register */
-	ioport32_t const ttgr;
-
-	/* Timer write posted status register */
-	ioport32_t twps;
-#define AM335x_TIMER_TWPS_PEND_TCLR         (1 << 0)
-#define AM335x_TIMER_TWPS_PEND_TCRR         (1 << 1)
-#define AM335x_TIMER_TWPS_PEND_TLDR         (1 << 2)
-#define AM335x_TIMER_TWPS_PEND_TTGR         (1 << 3)
-#define AM335x_TIMER_TWPS_PEND_TMAR         (1 << 4)
-
-	/* Timer match register */
-	ioport32_t tmar;
-
-	/* Timer capture register */
-	ioport32_t tcar1;
-
-	/* Timer synchronous interface control register */
-	ioport32_t tsicr;
-#define AM335x_TIMER_TSICR_SFT_FLAG         (1 << 1)
-#define AM335x_TIMER_TSICR_POSTED_FLAG      (1 << 2)
-
-	/* Timer capture register */
-	ioport32_t tcar2;
-
-} am335x_timer_regs_t;
-
-#endif
-
-/**
- * @}
- */
-
Index: rnel/genarch/include/genarch/drivers/am335x/uart.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/uart.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*
- * Copyright (c) Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x UART driver.
- */
-
-#ifndef _KERN_AM335X_UART_H_
-#define _KERN_AM335X_UART_H_
-
-#include "uart_regs.h"
-
-#define AM335x_UART0_BASE_ADDRESS    0x44E09000
-#define AM335x_UART0_SIZE            4096
-#define AM335x_UART0_IRQ             72
-
-#define AM335x_UART1_BASE_ADDRESS    0x48022000
-#define AM335x_UART1_SIZE            4096
-#define AM335x_UART1_IRQ             73
-
-#define AM335x_UART2_BASE_ADDRESS    0x48024000
-#define AM335x_UART2_SIZE            4096
-#define AM335x_UART2_IRQ             74
-
-#define AM335x_UART3_BASE_ADDRESS    0x481A6000
-#define AM335x_UART3_SIZE            4096
-#define AM335x_UART3_IRQ             44
-
-#define AM335x_UART4_BASE_ADDRESS    0x481A8000
-#define AM335x_UART4_SIZE            4096
-#define AM335x_UART4_IRQ             45
-
-#define AM335x_UART5_BASE_ADDRESS    0x481AA000
-#define AM335x_UART5_SIZE            4096
-#define AM335x_UART5_IRQ             46
-
-typedef struct {
-	am335x_uart_regs_t *regs;
-	indev_t *indev;
-	outdev_t outdev;
-	irq_t irq;
-} am335x_uart_t;
-
-#ifdef CONFIG_AM335X_UART
-extern bool am335x_uart_init(am335x_uart_t *uart, inr_t interrupt,
-    uintptr_t addr, size_t size);
-
-extern void am335x_uart_input_wire(am335x_uart_t *uart, indev_t *indev);
-#else
-static bool am335x_uart_init(am335x_uart_t *uart, inr_t interrupt,
-    uintptr_t addr, size_t size)
-{ return true; }
-
-static void am335x_uart_input_wire(am335x_uart_t *uart, indev_t *indev) {}
-#endif
-
-#endif
-
-/**
- * @}
- */
-
Index: rnel/genarch/include/genarch/drivers/am335x/uart_regs.h
===================================================================
--- kernel/genarch/include/genarch/drivers/am335x/uart_regs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,431 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * Copyright (c) 2012 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x UART memory mapped registers.
- */
-
-#ifndef _KERN_AM335X_UART_REGS_H_
-#define _KERN_AM335X_UART_REGS_H_
-
-#include <typedefs.h>
-#include <console/chardev.h>
-#include <ddi/irq.h>
-
-typedef struct {
-	union {
-		/** Stores lower part of the 14-bit baud divisor */
-		ioport32_t dll;
-#define AM335x_UART_DLL_MASK   (0xff)
-
-		/** Receive holding register */
-		const ioport32_t rhr;
-#define AM335x_UART_RHR_MASK   (0xff)
-
-		/** Transmit holding register */
-		ioport32_t thr;
-#define AM335x_UART_THR_MASK   (0xff)
-	};
-
-	union {
-		/** Stores higher part of the 14-bit baud divisor */
-		ioport32_t dlh;
-#define AM335x_UART_DLH_MASK   (0x1f)
-
-		/** Interrupt enable registers */
-		ioport32_t ier;
-#define AM335x_UART_IER_RHR_IRQ_FLAG   (1 << 0)
-#define AM335x_UART_IER_THR_IRQ_FLAG   (1 << 1)
-#define AM335x_UART_IER_LINE_STS_IRQ_FLAG   (1 << 2)
-#define AM335x_UART_IER_MODEM_STS_IRQ_FLAG   (1 << 3)
-#define AM335x_UART_IER_SLEEP_MODE_FLAG   (1 << 4)
-#define AM335x_UART_IER_XOFF_IRQ_FLAG   (1 << 5)
-#define AM335x_UART_IER_RTS_IRQ_FLAG   (1 << 6)
-#define AM335x_UART_IER_CTS_IRQ_FLAG   (1 << 7)
-
-#define AM335x_CIR_IER_RHR_IRQ_FLAG   (1 << 0)
-#define AM335x_CIR_IER_THR_IRQ_FLAG   (1 << 1)
-#define AM335x_CIR_IER_RX_STOP_IRQ_FLAG   (1 << 2)
-#define AM335x_CIR_IER_RX_OVERRUN_IRQ_FLAG   (1 << 3)
-#define AM335x_CIR_IER_TX_STS_IRQ_FLAG   (1 << 5)
-
-#define AM335x_IRDA_IER_RHR_IRQ_FLAG   (1 << 0)
-#define AM335x_IRDA_IER_THR_IRQ_FLAG   (1 << 1)
-#define AM335x_IRDA_IER_LAST_RX_BYTE_IRQ_FLAG   (1 << 2)
-#define AM335x_IRDA_IER_RX_OVERRUN_IRQ_FLAG   (1 << 3)
-#define AM335x_IRDA_IER_STS_FIFO_TRIG_IRQ_FLAG   (1 << 4)
-#define AM335x_IRDA_IER_TX_STS_IRQ_FLAG   (1 << 5)
-#define AM335x_IRDA_IER_LINE_STS_IRQ_FLAG   (1 << 6)
-#define AM335x_IRDA_IER_EOF_IRQ_FLAG   (1 << 7)
-	};
-
-	union {
-		/** Interrupt identification register */
-		const ioport32_t iir;
-#define AM335x_UART_IIR_IRQ_PENDING_FLAG   (1 << 0)
-#define AM335x_UART_IIR_TYPE_MASK   (0x1f)
-#define AM335x_UART_IIR_TYPE_SHIFT   (1)
-#define AM335x_UART_IIR_FCR_MASK   (0x3)
-#define AM335x_UART_IIR_FCR_SHIFT   (6)
-
-#define AM335x_CIR_IIR_RHR_IRQ_FLAG   (1 << 0)
-#define AM335x_CIR_IIR_THR_IRQ_FLAG   (1 << 1)
-#define AM335x_CIR_IIR_RX_STOP_IRQ_FLAG   (1 << 2)
-#define AM335x_CIR_IIR_RX_OE_IRQ_FLAG   (1 << 3)
-#define AM335x_CIR_IIR_TX_STS_IRQ_FLAG   (1 << 5)
-
-#define AM335x_IRDA_IIR_RHR_IRQ_FLAG   (1 << 0)
-#define AM335x_IRDA_IIR_THR_IRQ_FLAG   (1 << 1)
-#define AM335x_IRDA_IIR_RX_FIFO_LB_IRQ_FLAG   (1 << 2)
-#define AM335x_IRDA_IIR_RX_OE_IRQ_FLAG   (1 << 3)
-#define AM335x_IRDA_IIR_STS_FIFO_IRQ_FLAG   (1 << 4)
-#define AM335x_IRDA_IIR_TX_STS_IRQ_FLAG   (1 << 5)
-#define AM335x_IRDA_IIR_LINE_STS_IRQ_FLAG   (1 << 6)
-#define AM335x_IRDA_IIR_EOF_IRQ_FLAG   (1 << 7)
-
-		/** FIFO control register */
-		ioport32_t fcr;
-#define AM335x_UART_FCR_FIFO_EN_FLAG   (1 << 0)
-#define AM335x_UART_FCR_RX_FIFO_CLR_FLAG   (1 << 1)
-#define AM335x_UART_FCR_TX_FIFO_CLR_FLAG   (1 << 3)
-#define AM335x_UART_FCR_DMA_MODE_FLAG   (1 << 4)
-
-#define AM335x_UART_FCR_TX_FIFO_TRIG_MASK   (0x3)
-#define AM335x_UART_FCR_TX_FIFO_TRIG_SHIFT   (4)
-
-#define AM335x_UART_FCR_RX_FIFO_TRIG_MASK   (0x3)
-#define AM335x_UART_FCR_RX_FIFO_TRIG_SHIFT   (6)
-
-		/** Enhanced feature register */
-		ioport32_t efr;
-#define AM335x_UART_EFR_SW_FLOW_CTRL_RX_MASK   (0x3)
-#define AM335x_UART_EFR_SW_FLOW_CTRL_RX_SHIFT   (0)
-#define AM335x_UART_EFR_SW_FLOW_CTRL_TX_MASK   (0x3)
-#define AM335x_UART_EFR_SW_FLOW_CTRL_TX_SHIFT   (2)
-
-#define AM335x_UART_EFR_SW_FLOW_CTRL_NONE   (0x0)
-#define AM335x_UART_EFR_SW_FLOW_CTRL_X2   (0x1)
-#define AM335x_UART_EFR_SW_FLOW_CTRL_X1   (0x2)
-#define AM335x_UART_EFR_SW_FLOW_CTRL_XBOTH   (0x3)
-
-#define AM335x_UART_EFR_ENH_FLAG   (1 << 4)
-#define AM335x_UART_EFR_SPEC_CHAR_FLAG   (1 << 5)
-#define AM335x_UART_EFR_AUTO_RTS_EN_FLAG   (1 << 6)
-#define AM335x_UART_EFR_AUTO_CTS_EN_FLAG   (1 << 7)
-	};
-
-	/** Line control register */
-	ioport32_t lcr;
-#define AM335x_UART_LCR_CHAR_LENGTH_MASK   (0x3)
-#define AM335x_UART_LCR_CHAR_LENGTH_SHIFT   (0)
-#define AM335x_UART_LCR_CHAR_LENGTH_5BITS   (0x0)
-#define AM335x_UART_LCR_CHAR_LENGTH_6BITS   (0x1)
-#define AM335x_UART_LCR_CHAR_LENGTH_7BITS   (0x2)
-#define AM335x_UART_LCR_CHAR_LENGTH_8BITS   (0x3)
-#define AM335x_UART_LCR_NB_STOP_FLAG   (1 << 2)
-#define AM335x_UART_LCR_PARITY_EN_FLAG   (1 << 3)
-#define AM335x_UART_LCR_PARITY_TYPE1_FLAG   (1 << 4)
-#define AM335x_UART_LCR_PARITY_TYPE2_FLAG   (1 << 5)
-#define AM335x_UART_LCR_BREAK_EN_FLAG   (1 << 6)
-#define AM335x_UART_LCR_DIV_EN_FLAG   (1 << 7)
-
-
-	union {
-		/** Modem control register */
-		ioport32_t mcr;
-#define AM335x_UART_MCR_DTR_FLAG   (1 << 0)
-#define AM335x_UART_MCR_RTS_FLAG   (1 << 1)
-#define AM335x_UART_MCR_RI_STS_CH_FLAG   (1 << 2)
-#define AM335x_UART_MCR_CD_STS_CH_FLAG   (1 << 3)
-#define AM335x_UART_MCR_LOOPBACK_EN_FLAG   (1 << 4)
-#define AM335x_UART_MCR_XON_EN_FLAG   (1 << 5)
-#define AM335x_UART_MCR_TCR_TLR_FLAG   (1 << 6)
-
-		/** UART: XON1 char, IRDA: ADDR1 address */
-		ioport32_t xon1_addr1;
-#define AM335x_UART_XON1_ADDR1_MASK   (0xff)
-	};
-
-	union {
-		/** Line status register */
-		const ioport32_t lsr;
-#define AM335x_UART_LSR_RX_FIFO_E_FLAG   (1 << 0)
-#define AM335x_UART_LSR_RX_OE_FLAG   (1 << 1)
-#define AM335x_UART_LSR_RX_PE_FLAG   (1 << 2)
-#define AM335x_UART_LSR_RX_FE_FLAG   (1 << 3)
-#define AM335x_UART_LSR_RX_BI_FLAG   (1 << 4)
-#define AM335x_UART_LSR_TX_FIFO_E_FLAG   (1 << 5)
-#define AM335x_UART_LSR_TX_SR_E_FLAG   (1 << 6)
-#define AM335x_UART_LSR_RX_FIFO_STS_FLAG   (1 << 7)
-
-#define AM335x_CIR_LSR_RX_FIFO_E_FLAG   (1 << 0)
-#define AM335x_CIR_LSR_RX_STOP_FLAG   (1 << 5)
-#define AM335x_CIR_LSR_THR_EMPTY_FLAG   (1 << 7)
-
-#define AM335x_IRDA_LSR_RX_FIFO_E_FLAG   (1 << 0)
-#define AM335x_IRDA_LSR_STS_FIFO_E_FLAG   (1 << 1)
-#define AM335x_IRDA_LSR_CRC_FLAG   (1 << 2)
-#define AM335x_IRDA_LSR_ABORT_FLAG   (1 << 3)
-#define AM335x_IRDA_LSR_FTL_FLAG   (1 << 4)
-#define AM335x_IRDA_LSR_RX_LAST_FLAG   (1 << 5)
-#define AM335x_IRDA_LSR_STS_FIFO_FULL_FLAG   (1 << 6)
-#define AM335x_IRDA_LSR_THR_EMPTY_FLAG   (1 << 7)
-
-		/** UART: XON2 char, IRDA: ADDR2 address */
-		ioport32_t xon2_addr2;
-	};
-
-	union {
-		/** Modem status register */
-		const ioport32_t msr;
-#define AM335x_UART_MSR_CTS_STS_FLAG   (1 << 0)
-#define AM335x_UART_MSR_DSR_STS_FLAG   (1 << 1)
-#define AM335x_UART_MSR_RI_STS_FLAG   (1 << 2)
-#define AM335x_UART_MSR_DCD_STS_FLAG   (1 << 3)
-#define AM335x_UART_MSR_NCTS_STS_FLAG   (1 << 4)
-#define AM335x_UART_MSR_NDSR_STS_FLAG   (1 << 5)
-#define AM335x_UART_MSR_NRI_STS_FLAG   (1 << 6)
-#define AM335x_UART_MSR_NCD_STS_FLAG   (1 << 7)
-
-		/** Transmission control register */
-		ioport32_t tcr;
-#define AM335x_UART_TCR_FIFO_TRIG_MASK   (0xf)
-#define AM335x_UART_TCR_FIFO_TRIG_HALT_SHIFT   (0)
-#define AM335x_UART_TCR_FIFO_TRIG_START_SHIFT   (4)
-
-		/** UART: XOFF1 char */
-		ioport32_t xoff1;
-#define AM335x_UART_XOFF1_MASK   (0xff)
-	};
-
-	union {
-		/* Scratchpad register, does nothing */
-		ioport32_t spr;
-#define AM335x_UART_SPR_MASK   (0xff)
-
-		/* Trigger level register */
-		ioport32_t tlr;
-#define AM335x_UART_TLR_LEVEL_MASK   (0xf)
-#define AM335x_UART_TLR_TX_FIFO_TRIG_SHIFT   (0)
-#define AM335x_UART_TLR_RX_FIFO_TRIG_SHIFT   (4)
-
-		/** UART: XOFF2 char */
-		ioport32_t xoff2;
-#define AM335x_UART_XOFF2_MASK   (0xff)
-	};
-
-	/** Mode definition register. */
-	ioport32_t mdr1;
-#define AM335x_UART_MDR_MS_MASK   (0x7)
-#define AM335x_UART_MDR_MS_SHIFT   (0)
-#define AM335x_UART_MDR_MS_UART16   (0x0)
-#define AM335x_UART_MDR_MS_SIR   (0x1)
-#define AM335x_UART_MDR_MS_UART16_AUTO   (0x2)
-#define AM335x_UART_MDR_MS_UART13   (0x3)
-#define AM335x_UART_MDR_MS_MIR   (0x4)
-#define AM335x_UART_MDR_MS_FIR   (0x5)
-#define AM335x_UART_MDR_MS_CIR   (0x6)
-#define AM335x_UART_MDR_MS_DISABLE   (0x7)
-
-#define AM335x_UART_MDR_IR_SLEEP_FLAG   (1 << 3)
-#define AM335x_UART_MDR_SET_TXIR_FLAG   (1 << 4)
-#define AM335x_UART_MDR_SCT_FLAG   (1 << 5)
-#define AM335x_UART_MDR_SIP_FLAG   (1 << 6)
-#define AM335x_UART_MDR_FRAME_END_MODE_FLAG   (1 << 7)
-
-	/** Mode definition register */
-	ioport32_t mdr2;
-#define AM335x_UART_MDR_IRTX_UNDERRUN_FLAG   (1 << 0)
-#define AM335x_UART_MDR_STS_FIFO_TRIG_MASK   (0x3)
-#define AM335x_UART_MDR_STS_FIFO_TRIG_SHIFT   (1)
-#define AM335x_UART_MDR_PULSE_SHAPING_FLAG   (1 << 3)
-#define AM335x_UART_MDR_CIR_PULSE_MODE_MASK   (0x3)
-#define AM335x_UART_MDR_CIR_PULSE_MODE_SHIFT   (4)
-#define AM335x_UART_MDR_IRRXINVERT_FLAG   (1 << 6)
-
-	union {
-		/** Status FIFO line status register (IrDA only) */
-		const ioport32_t sflsr;
-#define AM335x_IRDA_SFLSR_CRC_ERROR_FLAG   (1 << 1)
-#define AM335x_IRDA_SFLSR_ABORT_FLAG   (1 << 2)
-#define AM335x_IRDA_SFLSR_FTL_FLAG   (1 << 3)
-#define AM335x_IRDA_SFLSR_OE_FLAG   (1 << 4)
-
-		/** Transmit frame length low (IrDA only) */
-		ioport32_t txfll;
-#define AM335x_UART_TXFLL_MASK   (0xff)
-	};
-
-	union {
-		/** Dummy register to restart TX or RX (IrDA only) */
-		const ioport32_t resume;
-		/** Transmit frame length high (IrDA only) */
-		ioport32_t txflh;
-#define AM335x_UART_TXFLH_MASK   (0xff)
-	};
-
-	union {
-		/** Status FIFO register low (IrDA only) */
-		const ioport32_t sfregl;
-#define AM335x_UART_SFREGL_MASK   (0xff)
-		/** Received frame length low (IrDA only) */
-		ioport32_t rxfll;
-#define AM335x_UART_RXFLL_MASK   (0xff)
-	};
-
-	union {
-		/** Status FIFO register high (IrDA only) */
-		const ioport32_t sfregh;
-#define AM335x_UART_SFREGH_MASK   (0xf)
-		/** Received frame length high (IrDA only) */
-		ioport32_t rxflh;
-#define AM335x_UART_RXFLH_MASK   (0xf)
-	};
-
-	union {
-		/** UART autobauding status register */
-		const ioport32_t uasr;
-#define AM335x_UART_UASR_SPEED_MASK   (0x1f)
-#define AM335x_UART_UASR_SPEED_SHIFT   (0)
-#define AM335x_UART_UASR_8BIT_CHAR_FLAG   (1 << 5)
-#define AM335x_UART_UASR_PARITY_MASK   (0x3)
-#define AM335x_UART_UASR_PARITY_SHIFT   (6)
-
-		/** BOF control register (IrDA only) */
-		ioport32_t blr;
-#define AM335x_IRDA_BLR_XBOF_TYPE_FLAG   (1 << 6)
-#define AM335x_IRDA_BLR_STS_FIFO_RESET   (1 << 7)
-	};
-
-	/** Auxiliary control register (IrDA only) */
-	ioport32_t acreg;
-#define AM335x_IRDA_ACREG_EOT_EN_FLAG   (1 << 0)
-#define AM335x_IRDA_ACREG_ABORT_EN_FLAG   (1 << 1)
-#define AM335x_IRDA_ACREG_SCTX_EN_FLAG   (1 << 2)
-#define AM335x_IRDA_ACREG_SEND_SIP_FLAG   (1 << 3)
-#define AM335x_IRDA_ACREG_DIS_TX_UNDERRUN_FLAG   (1 << 4)
-#define AM335x_IRDA_ACREG_DIS_IR_RX_FLAG   (1 << 5)
-#define AM335x_IRDA_ACREG_SD_MOD_FLAG   (1 << 6)
-#define AM335x_IRDA_ACREG_PULSE_TYPE_FLAG   (1 << 7)
-
-	/** Supplementary control register */
-	ioport32_t scr;
-#define AM335x_UART_SCR_DMA_MODE_CTL_FLAG   (1 << 0)
-#define AM335x_UART_SCR_DMA_MODE_MASK   (0x3)
-#define AM335x_UART_SCR_DMA_MODE_SHIFT   (1)
-#define AM335x_UART_SCR_TX_EMPTY_CTL_IRQ_FLAG   (1 << 3)
-#define AM335x_UART_SCR_RX_CTS_WU_EN_FLAG   (1 << 4)
-#define AM335x_UART_SCR_TX_TRIG_GRANU1_FLAG   (1 << 6)
-#define AM335x_UART_SCR_RX_TRIG_GRANU1_FLAG   (1 << 7)
-
-	/** Supplementary status register */
-	const ioport32_t ssr;
-#define AM335x_UART_SSR_TX_FIFO_FULL_FLAG   (1 << 0)
-#define AM335x_UART_SSR_RX_CTS_WU_STS_FLAG   (1 << 1)
-#define AM335x_UART_SSR_DMA_COUNTER_RESET_FLAG   (1 << 2)
-
-	/** BOF Length register (IrDA only)*/
-	ioport32_t eblr;
-#define AM335x_IRDA_EBLR_DISABLED   (0x00)
-#define AM335x_IRDA_EBLR_RX_STOP_BITS(bits)   (bits & 0xff)
-
-	uint32_t padd0_;
-
-	/** Module version register */
-	const ioport32_t mvr;
-#define AM335x_UART_MVR_MINOR_MASK   (0xf)
-#define AM335x_UART_MVR_MINOR_SHIFT   (0)
-#define AM335x_UART_MVR_MAJOR_MASK   (0xf)
-#define AM335x_UART_MVR_MAJOR_SHIFT   (4)
-
-	/** System configuration register */
-	ioport32_t sysc;
-#define AM335x_UART_SYSC_AUTOIDLE_FLAG   (1 << 0)
-#define AM335x_UART_SYSC_SOFTRESET_FLAG   (1 << 1)
-#define AM335x_UART_SYSC_ENWAKEUP_FLAG   (1 << 2)
-#define AM335x_UART_SYSC_IDLE_MODE_MASK   (0x3)
-#define AM335x_UART_SYSC_IDLE_MODE_SHIFT   (3)
-#define AM335x_UART_SYSC_IDLE_MODE_FORCE   (0x0)
-#define AM335x_UART_SYSC_IDLE_MODE_NO   (0x1)
-#define AM335x_UART_SYSC_IDLE_MODE_SMART   (0x2)
-
-	/** System status register */
-	const ioport32_t syss;
-#define AM335x_UART_SYSS_RESETDONE_FLAG   (1 << 0)
-
-	/** Wake-up enable register */
-	ioport32_t wer;
-#define AM335x_UART_WER_CTS_ACTIVITY_FLAG  (1 << 0)
-#define AM335x_UART_WER_RI_ACTIVITY_FLAG  (1 << 2)
-#define AM335x_UART_WER_RX_ACTIVITY_FLAG  (1 << 4)
-#define AM335x_UART_WER_RHR_IRQ_FLAG  (1 << 5)
-#define AM335x_UART_WER_RLS_IRQ_FLAG  (1 << 6)
-#define AM335x_UART_WER_TX_WAKEUP_EN_FLAG  (1 << 7)
-
-	/** Carrier frequency prescaler */
-	ioport32_t cfps;
-#define AM335x_UART_CFPS_MASK   (0xff)
-
-	/** Number of bytes in RX fifo */
-	const ioport32_t rx_fifo_lvl;
-#define AM335x_UART_RX_FIFO_LVL_MASK   (0xff)
-
-	/** Number of bytes in TX fifo */
-	const ioport32_t tx_fifo_lvl;
-#define AM335x_UART_TX_FIFO_LVL_MASK   (0xff)
-
-	/** RX/TX empty interrupts */
-	ioport32_t ier2;
-#define AM335x_UART_IER2_RX_FIFO_EMPTY_IRQ_EN_FLAG  (1 << 0)
-#define AM335x_UART_IER2_TX_FIFO_EMPTY_IRQ_EN_FLAG  (1 << 1)
-
-	/** RX/TX empty status */
-	ioport32_t isr2;
-#define AM335x_UART_ISR2_RX_FIFO_EMPTY_FLAG  (1 << 0)
-#define AM335x_UART_ISR2_TX_FIFO_EMPTY_FLAG  (1 << 1)
-
-	/** Set the sample per bit if non default frequency is used */
-	ioport32_t freq_sel;
-#define AM335x_UART_FREQ_SEL_MASK  (0x000000FF)
-
-	uint32_t padd2_[2];
-
-	/** Mode definition register 3 */
-	ioport32_t mdr3;
-#define AM335x_UART_MDR3_DIS_CIR_RX_DEMOD_FLAG   (1 << 0)
-} am335x_uart_regs_t;
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/amdm37x/gpt.h
===================================================================
--- kernel/genarch/include/genarch/drivers/amdm37x/gpt.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,255 +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 genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM/DM37x MPU general purpose timer driver.
- */
-
-#ifndef KERN_AMDM37x_GPT_H_
-#define KERN_AMDM37x_GPT_H_
-
-#include <typedefs.h>
-#include <mm/km.h>
-
-/* AMDM37x TRM p. 2740 */
-#define AMDM37x_GPT1_BASE_ADDRESS  0x48318000
-#define AMDM37x_GPT1_SIZE  4096
-#define AMDM37x_GPT1_IRQ  37
-#define AMDM37x_GPT2_BASE_ADDRESS  0x49032000
-#define AMDM37x_GPT2_SIZE  4096
-#define AMDM37x_GPT2_IRQ  38
-#define AMDM37x_GPT3_BASE_ADDRESS  0x49034000
-#define AMDM37x_GPT3_SIZE  4096
-#define AMDM37x_GPT3_IRQ  39
-#define AMDM37x_GPT4_BASE_ADDRESS  0x49036000
-#define AMDM37x_GPT4_SIZE  4096
-#define AMDM37x_GPT4_IRQ  40
-#define AMDM37x_GPT5_BASE_ADDRESS  0x49038000
-#define AMDM37x_GPT5_SIZE  4096
-#define AMDM37x_GPT5_IRQ  41
-#define AMDM37x_GPT6_BASE_ADDRESS  0x4903a000
-#define AMDM37x_GPT6_SIZE  4096
-#define AMDM37x_GPT6_IRQ  42
-#define AMDM37x_GPT7_BASE_ADDRESS  0x4903c000
-#define AMDM37x_GPT7_SIZE  4096
-#define AMDM37x_GPT7_IRQ  43
-#define AMDM37x_GPT8_BASE_ADDRESS  0x4903e000
-#define AMDM37x_GPT8_SIZE  4096
-#define AMDM37x_GPT8_IRQ  44
-#define AMDM37x_GPT9_BASE_ADDRESS  0x49040000
-#define AMDM37x_GPT9_SIZE  4096
-#define AMDM37x_GPT9_IRQ  45
-#define AMDM37x_GPT10_BASE_ADDRESS  0x48086000
-#define AMDM37x_GPT10_SIZE  4096
-#define AMDM37x_GPT10_IRQ  46
-#define AMDM37x_GPT11_BASE_ADDRESS  0x48088000
-#define AMDM37x_GPT11_SIZE  4096
-#define AMDM37x_GPT11_IRQ  47
-
-
-/** GPT register map AMDM37x TRM p. 2740 */
-typedef struct {
-	/** IP revision */
-	const ioport32_t tidr;
-#define AMDM37x_GPT_TIDR_MINOR_MASK  (0xf)
-#define AMDM37x_GPT_TIDR_MINOR_SHIFT  (0)
-#define AMDM37x_GPT_TIDR_MAJOR_MASK  (0xf)
-#define AMDM37x_GPT_TIDR_MAJOR_SHIFT  (4)
-	uint32_t padd0_[3];
-
-	/** L4 Interface parameters */
-	ioport32_t tiocp_cfg;
-#define AMDM37x_GPT_TIOCP_CFG_AUTOIDLE_FLAG  (1 << 0)
-#define AMDM37x_GPT_TIOCP_CFG_SOFTRESET_FLAG  (1 << 1)
-#define AMDM37x_GPT_TIOCP_CFG_ENWAKEUP_FLAG  (1 << 2)
-#define AMDM37x_GPT_TIOCP_CFG_IDLEMODE_MASK  (0x3)
-#define AMDM37x_GPT_TIOCP_CFG_IDLEMODE_SHIFT  (3)
-#define AMDM37x_GPT_TIOCP_CFG_EMUFREE_FlAG  (1 << 5)
-#define AMDM37x_GPT_TIOCP_CFG_CLOCKACTIVITY_MASK  (0x3)
-#define AMDM37x_GPT_TIOCP_CFG_CLOCKACTIVITY_SHIFT (8)
-
-	/** Module status information, excluding irq */
-	const ioport32_t tistat;
-#define AMDM37x_GPT_TISTAT_RESET_DONE_FLAG  (1 << 0)
-
-	/** Interrupt status register */
-	ioport32_t tisr;
-#define AMDM37x_GPT_TISR_MAT_IRQ_FLAG  (1 << 0)
-#define AMDM37x_GPT_TISR_OVF_IRQ_FLAG  (1 << 1)
-#define AMDM37x_GPT_TISR_TCAR_IRQ_FLAG  (1 << 2)
-
-	/* Interrupt enable register */
-	ioport32_t tier;
-#define AMDM37x_GPT_TIER_MAT_IRQ_FLAG  (1 << 0)
-#define AMDM37x_GPT_TIER_OVF_IRQ_FLAG  (1 << 1)
-#define AMDM37x_GPT_TIER_TCAR_IRQ_FLAG  (1 << 2)
-
-	/** Wakeup enable register */
-	ioport32_t twer;
-#define AMDM37x_GPT_TWER_MAT_IRQ_FLAG  (1 << 0)
-#define AMDM37x_GPT_TWER_OVF_IRQ_FLAG  (1 << 1)
-#define AMDM37x_GPT_TWER_TCAR_IRQ_FLAG  (1 << 2)
-
-	/** Optional features control register */
-	ioport32_t tclr;
-#define AMDM37x_GPT_TCLR_ST_FLAG  (1 << 0)
-#define AMDM37x_GPT_TCLR_AR_FLAG  (1 << 1)
-#define AMDM37x_GPT_TCLR_PTV_MASK  (0x7)
-#define AMDM37x_GPT_TCLR_PTV_SHIFT  (2)
-#define AMDM37x_GPT_TCLR_PRE_FLAG  (1 << 5)
-#define AMDM37x_GPT_TCLR_CE_FLAG  (1 << 6)
-#define AMDM37x_GPT_TCLR_SCPWM  (1 << 7)
-#define AMDM37x_GPT_TCLR_TCM_MASK  (0x3)
-#define AMDM37x_GPT_TCLR_TCM_SHIFT  (8)
-#define AMDM37x_GPT_TCLR_TRG_MASK  (0x3)
-#define AMDM37x_GPT_TCLR_TRG_SHIFT (10)
-#define AMDM37x_GPT_TCLR_PT_FLAG  (1 << 12)
-#define AMDM37x_GPT_TCLR_CAPT_MODE_FLAG  (1 << 13)
-#define AMDM37x_GPT_TCLR_GPO_CFG_FLAG  (1 << 14)
-
-	/** Value of timer counter */
-	ioport32_t tccr;
-
-	/** Timer load register */
-	ioport32_t tldr;
-
-	/** Timer trigger register */
-	ioport32_t ttgr;
-
-	/** Write-posted pending register */
-	const ioport32_t twps;
-#define AMDM37x_GPT_TWPS_TCLR_FLAG  (1 << 0)
-#define AMDM37x_GPT_TWPS_TCRR_FLAG  (1 << 1)
-#define AMDM37x_GPT_TWPS_TLDR_FLAG  (1 << 2)
-#define AMDM37x_GPT_TWPS_TTGR_FLAG  (1 << 3)
-#define AMDM37x_GPT_TWPS_TMAR_FLAG  (1 << 4)
-#define AMDM37x_GPT_TWPS_TPIR_FLAG  (1 << 5)
-#define AMDM37x_GPT_TWPS_TNIR_FLAG  (1 << 6)
-#define AMDM37x_GPT_TWPS_TCVR_FLAG  (1 << 7)
-#define AMDM37x_GPT_TWPS_TOCR_FLAG  (1 << 8)
-#define AMDM37x_GPT_TWPS_TOWR_FLAG  (1 << 9)
-
-	/** Timer match register */
-	ioport32_t tmar;
-
-	/** Capture value 1 register */
-	const ioport32_t tcar1;
-
-	/** Software interface control register */
-	ioport32_t tsicr;
-#define AMDM37x_GPT_TSICR_SFT_FLAG  (1 << 1)
-#define AMDM37x_GPT_TSICR_POSTED_FLAG  (1 << 2)
-
-	/** Capture value 2 register */
-	const ioport32_t tcar2;
-
-	/* GPT1,2,10 only (used for 1ms time period generation)*/
-
-	/** Positive increment register */
-	ioport32_t tpir;
-
-	/** Negative increment register */
-	ioport32_t tnir;
-
-	/** Counter value register */
-	ioport32_t tcvr;
-
-	/** Mask the tick interrupt for selected number of ticks */
-	ioport32_t tocr;
-
-	/** Number of masked overflow interrupts */
-	ioport32_t towr;
-} amdm37x_gpt_regs_t;
-
-typedef struct {
-	amdm37x_gpt_regs_t *regs;
-	bool special_available;
-} amdm37x_gpt_t;
-
-static inline void amdm37x_gpt_timer_ticks_init(
-    amdm37x_gpt_t* timer, uintptr_t ioregs, size_t iosize, unsigned hz)
-{
-	/* Set 32768 Hz clock as source */
-	// TODO find a nicer way to setup 32kHz clock source for timer1
-	// reg 0x48004C40 is CM_CLKSEL_WKUP see page 485 of the manual
-	ioport32_t *clksel = (void*) km_map(0x48004C40, 4, PAGE_NOT_CACHEABLE);
-	*clksel &= ~1;
-	km_unmap((uintptr_t)clksel, 4);
-
-	ASSERT(timer);
-	/* Map control register */
-	timer->regs = (void*) km_map(ioregs, iosize, PAGE_NOT_CACHEABLE);
-
-	/* Set autoreload */
-	timer->regs->tclr = AMDM37x_GPT_TCLR_AR_FLAG;
-
-	timer->special_available = (
-	    (ioregs == AMDM37x_GPT1_BASE_ADDRESS) ||
-	    (ioregs == AMDM37x_GPT2_BASE_ADDRESS) ||
-	    (ioregs == AMDM37x_GPT10_BASE_ADDRESS));
-	timer->regs->tldr = 0xffffffff - (32768 / hz) + 1;
-	timer->regs->tccr = 0xffffffff - (32768 / hz) + 1;
-	if (timer->special_available) {
-		/* Set values for according to formula (manual p. 2733) */
-		/* Use temporary variables for easier debugging */
-		const uint32_t tpir =
-		    ((32768 / hz + 1) * 1000000) - (32768000L * (1000 / hz));
-		const uint32_t tnir =
-		    ((32768 / hz) * 1000000) - (32768000 * (1000 / hz));
-		timer->regs->tpir = tpir;
-		timer->regs->tnir = tnir;
-	}
-
-}
-
-static inline void amdm37x_gpt_timer_ticks_start(amdm37x_gpt_t* timer)
-{
-	ASSERT(timer);
-	ASSERT(timer->regs);
-	/* Enable overflow interrupt */
-	timer->regs->tier |= AMDM37x_GPT_TIER_OVF_IRQ_FLAG;
-	/* Start timer */
-	timer->regs->tclr |= AMDM37x_GPT_TCLR_ST_FLAG;
-}
-
-static inline void amdm37x_gpt_irq_ack(amdm37x_gpt_t* timer)
-{
-	ASSERT(timer);
-	ASSERT(timer->regs);
-	/* Clear all pending interrupts */
-	timer->regs->tisr = timer->regs->tisr;
-}
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/amdm37x/irc.h
===================================================================
--- kernel/genarch/include/genarch/drivers/amdm37x/irc.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,206 +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 genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM/DM37x MPU on-chip interrupt controller driver.
- */
-
-#ifndef KERN_AMDM37x_IRQC_H_
-#define KERN_AMDM37x_IRQC_H_
-
-/* AMDM37x TRM p. 1079 */
-#define AMDM37x_IRC_BASE_ADDRESS 0x48200000
-#define AMDM37x_IRC_SIZE 4096
-
-#define AMDM37x_IRC_IRQ_COUNT 96
-
-#include <typedefs.h>
-
-typedef struct {
-	const ioport32_t revision; /**< Revision */
-#define AMDM37x_IRC_REV_MASK (0xff)
-
-	uint8_t padd0_[12];
-
-	ioport32_t sysconfig; /**< SYS config */
-#define AMDM37x_IRC_SYSCONFIG_AUTOIDLE_FLAG (1 << 0)
-#define AMDM37x_IRC_SYSCONFIG_SOFTRESET_FLAG (1 << 1)
-
-	const ioport32_t sysstatus; /**< SYS status */
-#define AMDM37x_IRC_SYSSTATUS_RESET_DONE_FLAG (1 << 0)
-
-	uint8_t padd1_[40];
-
-	const ioport32_t sir_irq;   /**< Currently active irq number */
-#define AMDM37x_IRC_SIR_IRQ_ACTIVEIRQ_MASK (0x7f)
-#define AMDM37x_IRC_SIR_IRQ_SPURIOUSIRQFLAG_MASK (0xfffffff8)
-
-	const ioport32_t sir_fiq;
-#define AMDM37x_IRC_SIR_FIQ_ACTIVEIRQ_MASK (0x7f)
-#define AMDM37x_IRC_SIR_FIQ_SPURIOUSIRQFLAG_MASK (0xfffffff8)
-
-	ioport32_t control;   /**< New interrupt agreement. */
-#define AMDM37x_IRC_CONTROL_NEWIRQAGR_FLAG (1 << 0)
-#define AMDM37x_IRC_CONTROL_NEWFIQAGR_FLAG (1 << 1)
-
-	ioport32_t protection;  /**< Protect other registers. */
-#define AMDM37x_IRC_PROTECTION_PROETCTION_FLAG (1 << 0)
-
-	ioport32_t idle;   /**< Idle and autogating */
-#define AMDM37x_IRC_IDLE_FUNCIDLE_FLAG (1 << 0)
-#define AMDM37x_IRC_IDLE_TURBO_FLAG (1 << 1)
-
-	uint8_t padd2_[12];
-
-	ioport32_t irq_priority; /**< Active IRQ priority */
-#define AMDM37x_IRC_IRQ_PRIORITY_IRQPRIORITY_MASK (0x7f)
-#define AMDM37x_IRC_IRQ_PRIORITY_SPURIOUSIRQFLAG_MASK (0xfffffff8)
-
-	ioport32_t fiq_priority; /**< Active FIQ priority */
-#define AMDM37x_IRC_FIQ_PRIORITY_FIQPRIORITY_MASK (0x7f)
-#define AMDM37x_IRC_FIQ_PRIORITY_SPURIOUSFIQFLAG_MASK (0xfffffff8)
-
-	ioport32_t threshold; /**< Priority threshold */
-#define AMDM37x_IRC_THRESHOLD_PRIORITYTHRESHOLD_MASK (0xff)
-#define AMDM37x_IRC_THRESHOLD_PRIORITYTHRESHOLD_ENABLED (0x00)
-#define AMDM37x_IRC_THRESHOLD_PRIORITYTHRESHOLD_DISABLED (0xff)
-
-	uint8_t padd3__[20];
-
-	struct {
-		const ioport32_t itr;   /**< Interrupt input status before masking */
-		ioport32_t mir;   /**< Interrupt mask */
-		ioport32_t mir_clear; /**< Clear mir mask bits */
-		ioport32_t mir_set;   /**< Set mir mask bits */
-		ioport32_t isr_set;   /**< Set software interrupt bits */
-		ioport32_t isr_clear; /**< Clear software interrupt bits */
-		const ioport32_t pending_irq; /**< IRQ status after masking */
-		const ioport32_t pending_fiq; /**< FIQ status after masking */
-	} interrupts[3];
-
-	uint8_t padd4_[32];
-
-	ioport32_t ilr[96];   /**< FIQ/IRQ steering */
-#define AMDM37x_IRC_ILR_FIQNIRQ (1 << 0)
-#define AMDM37x_IRC_ILR_PRIORITY_MASK (0x3f)
-#define AMDM37x_IRC_ILR_PRIORITY_SHIFT (2)
-
-} amdm37x_irc_regs_t;
-
-static inline void amdm37x_irc_dump(amdm37x_irc_regs_t *regs)
-{
-#define DUMP_REG(name) \
-	printf("%s %p(%x).\n", #name, &regs->name, regs->name);
-
-	DUMP_REG(revision);
-	DUMP_REG(sysconfig);
-	DUMP_REG(sysstatus);
-	DUMP_REG(sir_irq);
-	DUMP_REG(sir_fiq);
-	DUMP_REG(control);
-	DUMP_REG(protection);
-	DUMP_REG(idle);
-	DUMP_REG(irq_priority);
-	DUMP_REG(fiq_priority);
-	DUMP_REG(threshold);
-
-	for (int i = 0; i < 3; ++i) {
-		DUMP_REG(interrupts[i].itr);
-		DUMP_REG(interrupts[i].mir);
-		DUMP_REG(interrupts[i].isr_set);
-		DUMP_REG(interrupts[i].pending_irq);
-		DUMP_REG(interrupts[i].pending_fiq);
-	}
-	for (int i = 0; i < AMDM37x_IRC_IRQ_COUNT; ++i) {
-		DUMP_REG(ilr[i]);
-	}
-
-#undef DUMP_REG
-}
-
-static inline void amdm37x_irc_init(amdm37x_irc_regs_t *regs)
-{
-	/* AMDM37x TRM sec 12.5.1 p. 2425 */
-	/* Program system config register */
-	//TODO enable this when you know the meaning
-	//regs->sysconfig |= AMDM37x_IRC_SYSCONFIG_AUTOIDLE_FLAG;
-
-	/* Program idle register */
-	//TODO enable this when you know the meaning
-	//regs->sysconfig |= AMDM37x_IRC_IDLE_TURBO_FLAG;
-
-	/* Program ilr[m] assign priority, decide fiq */
-	for (unsigned i = 0; i < AMDM37x_IRC_IRQ_COUNT; ++i) {
-		regs->ilr[i] = 0; /* highest prio(default) route to irq */
-	}
-
-	/* Disable all interrupts */
-	regs->interrupts[0].mir_set = 0xffffffff;
-	regs->interrupts[1].mir_set = 0xffffffff;
-	regs->interrupts[2].mir_set = 0xffffffff;
-}
-
-static inline unsigned amdm37x_irc_inum_get(amdm37x_irc_regs_t *regs)
-{
-	return regs->sir_irq & AMDM37x_IRC_SIR_IRQ_ACTIVEIRQ_MASK;
-}
-
-static inline void amdm37x_irc_irq_ack(amdm37x_irc_regs_t *regs)
-{
-	regs->control = AMDM37x_IRC_CONTROL_NEWIRQAGR_FLAG;
-}
-
-static inline void amdm37x_irc_fiq_ack(amdm37x_irc_regs_t *regs)
-{
-	regs->control = AMDM37x_IRC_CONTROL_NEWFIQAGR_FLAG;
-}
-
-static inline void amdm37x_irc_enable(amdm37x_irc_regs_t *regs, unsigned inum)
-{
-	ASSERT(inum < AMDM37x_IRC_IRQ_COUNT);
-	const unsigned set = inum / 32;
-	const unsigned pos = inum % 32;
-	regs->interrupts[set].mir_clear = (1 << pos);
-}
-
-static inline void amdm37x_irc_disable(amdm37x_irc_regs_t *regs, unsigned inum)
-{
-	ASSERT(inum < AMDM37x_IRC_IRQ_COUNT);
-	const unsigned set = inum / 32;
-	const unsigned pos = inum % 32;
-	regs->interrupts[set].mir_set = (1 << pos);
-}
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/amdm37x/uart.h
===================================================================
--- kernel/genarch/include/genarch/drivers/amdm37x/uart.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,73 +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 genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AMDM37x UART driver
- */
-
-#ifndef _AMDM37x_UART_H_
-#define _AMDM37x_UART_H_
-
-#include "uart_regs.h"
-
-/* AMDM37x TRM p. 2950 */
-#define AMDM37x_UART1_BASE_ADDRESS   0x4806a000
-#define AMDM37x_UART1_SIZE   1024
-#define AMDM37x_UART1_IRQ   72 /* AMDM37x TRM p. 2418 */
-
-#define AMDM37x_UART2_BASE_ADDRESS   0x4806b000
-#define AMDM37x_UART2_SIZE   1024
-#define AMDM37x_UART2_IRQ   73 /* AMDM37x TRM p. 2418 */
-
-#define AMDM37x_UART3_BASE_ADDRESS   0x49020000
-#define AMDM37x_UART3_SIZE   1024
-#define AMDM37x_UART3_IRQ   74 /* AMDM37x TRM p. 2418 */
-
-#define AMDM37x_UART4_BASE_ADDRESS   0x49042000
-#define AMDM37x_UART4_SIZE   1024
-#define AMDM37x_UART4_IRQ   80 /* AMDM37x TRM p. 2418 */
-
-typedef struct {
-	amdm37x_uart_regs_t *regs;
-	indev_t *indev;
-	outdev_t outdev;
-	irq_t irq;
-} amdm37x_uart_t;
-
-
-bool amdm37x_uart_init(amdm37x_uart_t *, inr_t, uintptr_t, size_t);
-void amdm37x_uart_input_wire(amdm37x_uart_t *, indev_t *);
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/include/genarch/drivers/amdm37x/uart_regs.h
===================================================================
--- kernel/genarch/include/genarch/drivers/amdm37x/uart_regs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,431 +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 genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AMDM37x UART memory mapped registers.
- */
-
-#ifndef KERN_AMDM37x_UART_H_
-#define KERN_AMDM37x_UART_H_
-
-#include <typedefs.h>
-#include <console/chardev.h>
-#include <ddi/irq.h>
-
-typedef struct {
-	union {
-		/** Stores lower part of the 14-bit baud divisor */
-		ioport32_t dll;
-#define AMDM37x_UART_DLL_MASK   (0xff)
-
-		/** Receive holding register */
-		const ioport32_t rhr;
-#define AMDM37x_UART_RHR_MASK   (0xff)
-
-		/** Transmit holding register */
-		ioport32_t thr;
-#define AMDM37x_UART_THR_MASK   (0xff)
-	};
-
-	union {
-		/** Stores higher part of the 14-bit baud divisor */
-		ioport32_t dlh;
-#define AMDM37x_UART_DLH_MASK   (0x1f)
-
-		/** Interrupt enable registers */
-		ioport32_t ier;
-#define AMDM37x_UART_IER_RHR_IRQ_FLAG   (1 << 0)
-#define AMDM37x_UART_IER_THR_IRQ_FLAG   (1 << 1)
-#define AMDM37x_UART_IER_LINE_STS_IRQ_FLAG   (1 << 2)
-#define AMDM37x_UART_IER_MODEM_STS_IRQ_FLAG   (1 << 3)
-#define AMDM37x_UART_IER_SLEEP_MODE_FLAG   (1 << 4)
-#define AMDM37x_UART_IER_XOFF_IRQ_FLAG   (1 << 5)
-#define AMDM37x_UART_IER_RTS_IRQ_FLAG   (1 << 6)
-#define AMDM37x_UART_IER_CTS_IRQ_FLAG   (1 << 7)
-
-#define AMDM37x_CIR_IER_RHR_IRQ_FLAG   (1 << 0)
-#define AMDM37x_CIR_IER_THR_IRQ_FLAG   (1 << 1)
-#define AMDM37x_CIR_IER_RX_STOP_IRQ_FLAG   (1 << 2)
-#define AMDM37x_CIR_IER_RX_OVERRUN_IRQ_FLAG   (1 << 3)
-#define AMDM37x_CIR_IER_TX_STS_IRQ_FLAG   (1 << 5)
-
-#define AMDM37x_IRDA_IER_RHR_IRQ_FLAG   (1 << 0)
-#define AMDM37x_IRDA_IER_THR_IRQ_FLAG   (1 << 1)
-#define AMDM37x_IRDA_IER_LAST_RX_BYTE_IRQ_FLAG   (1 << 2)
-#define AMDM37x_IRDA_IER_RX_OVERRUN_IRQ_FLAG   (1 << 3)
-#define AMDM37x_IRDA_IER_STS_FIFO_TRIG_IRQ_FLAG   (1 << 4)
-#define AMDM37x_IRDA_IER_TX_STS_IRQ_FLAG   (1 << 5)
-#define AMDM37x_IRDA_IER_LINE_STS_IRQ_FLAG   (1 << 6)
-#define AMDM37x_IRDA_IER_EOF_IRQ_FLAG   (1 << 7)
-	};
-
-	union {
-		/** Interrupt identification register */
-		const ioport32_t iir;
-#define AMDM37x_UART_IIR_IRQ_PENDING_FLAG   (1 << 0)
-#define AMDM37x_UART_IIR_TYPE_MASK   (0x1f)
-#define AMDM37x_UART_IIR_TYPE_SHIFT   (1)
-#define AMDM37x_UART_IIR_FCR_MASK   (0x3)
-#define AMDM37x_UART_IIR_FCR_SHIFT   (6)
-
-#define AMDM37x_CIR_IIR_RHR_IRQ_FLAG   (1 << 0)
-#define AMDM37x_CIR_IIR_THR_IRQ_FLAG   (1 << 1)
-#define AMDM37x_CIR_IIR_RX_STOP_IRQ_FLAG   (1 << 2)
-#define AMDM37x_CIR_IIR_RX_OE_IRQ_FLAG   (1 << 3)
-#define AMDM37x_CIR_IIR_TX_STS_IRQ_FLAG   (1 << 5)
-
-#define AMDM37x_IRDA_IIR_RHR_IRQ_FLAG   (1 << 0)
-#define AMDM37x_IRDA_IIR_THR_IRQ_FLAG   (1 << 1)
-#define AMDM37x_IRDA_IIR_RX_FIFO_LB_IRQ_FLAG   (1 << 2)
-#define AMDM37x_IRDA_IIR_RX_OE_IRQ_FLAG   (1 << 3)
-#define AMDM37x_IRDA_IIR_STS_FIFO_IRQ_FLAG   (1 << 4)
-#define AMDM37x_IRDA_IIR_TX_STS_IRQ_FLAG   (1 << 5)
-#define AMDM37x_IRDA_IIR_LINE_STS_IRQ_FLAG   (1 << 6)
-#define AMDM37x_IRDA_IIR_EOF_IRQ_FLAG   (1 << 7)
-
-		/** FIFO control register */
-		ioport32_t fcr;
-#define AMDM37x_UART_FCR_FIFO_EN_FLAG   (1 << 0)
-#define AMDM37x_UART_FCR_RX_FIFO_CLR_FLAG   (1 << 1)
-#define AMDM37x_UART_FCR_TX_FIFO_CLR_FLAG   (1 << 3)
-#define AMDM37x_UART_FCR_DMA_MODE_FLAG   (1 << 4)
-
-#define AMDM37x_UART_FCR_TX_FIFO_TRIG_MASK   (0x3)
-#define AMDM37x_UART_FCR_TX_FIFO_TRIG_SHIFT   (4)
-
-#define AMDM37x_UART_FCR_RX_FIFO_TRIG_MASK   (0x3)
-#define AMDM37x_UART_FCR_RX_FIFO_TRIG_SHIFT   (6)
-
-		/** Enhanced feature register */
-		ioport32_t efr;
-#define AMDM37x_UART_EFR_SW_FLOW_CTRL_RX_MASK   (0x3)
-#define AMDM37x_UART_EFR_SW_FLOW_CTRL_RX_SHIFT   (0)
-#define AMDM37x_UART_EFR_SW_FLOW_CTRL_TX_MASK   (0x3)
-#define AMDM37x_UART_EFR_SW_FLOW_CTRL_TX_SHIFT   (2)
-
-#define AMDM37x_UART_EFR_SW_FLOW_CTRL_NONE   (0x0)
-#define AMDM37x_UART_EFR_SW_FLOW_CTRL_X2   (0x1)
-#define AMDM37x_UART_EFR_SW_FLOW_CTRL_X1   (0x2)
-#define AMDM37x_UART_EFR_SW_FLOW_CTRL_XBOTH   (0x3)
-
-#define AMDM37x_UART_EFR_ENH_FLAG   (1 << 4)
-#define AMDM37x_UART_EFR_SPEC_CHAR_FLAG   (1 << 5)
-#define AMDM37x_UART_EFR_AUTO_RTS_EN_FLAG   (1 << 6)
-#define AMDM37x_UART_EFR_AUTO_CTS_EN_FLAG   (1 << 7)
-	};
-
-	/** Line control register */
-	ioport32_t lcr;
-#define AMDM37x_UART_LCR_CHAR_LENGTH_MASK   (0x3)
-#define AMDM37x_UART_LCR_CHAR_LENGTH_SHIFT   (0)
-#define AMDM37x_UART_LCR_CHAR_LENGTH_5BITS   (0x0)
-#define AMDM37x_UART_LCR_CHAR_LENGTH_6BITS   (0x1)
-#define AMDM37x_UART_LCR_CHAR_LENGTH_7BITS   (0x2)
-#define AMDM37x_UART_LCR_CHAR_LENGTH_8BITS   (0x3)
-#define AMDM37x_UART_LCR_NB_STOP_FLAG   (1 << 2)
-#define AMDM37x_UART_LCR_PARITY_EN_FLAG   (1 << 3)
-#define AMDM37x_UART_LCR_PARITY_TYPE1_FLAG   (1 << 4)
-#define AMDM37x_UART_LCR_PARITY_TYPE2_FLAG   (1 << 5)
-#define AMDM37x_UART_LCR_BREAK_EN_FLAG   (1 << 6)
-#define AMDM37x_UART_LCR_DIV_EN_FLAG   (1 << 7)
-
-
-	union {
-		/** Modem control register */
-		ioport32_t mcr;
-#define AMDM37x_UART_MCR_DTR_FLAG   (1 << 0)
-#define AMDM37x_UART_MCR_RTS_FLAG   (1 << 1)
-#define AMDM37x_UART_MCR_RI_STS_CH_FLAG   (1 << 2)
-#define AMDM37x_UART_MCR_CD_STS_CH_FLAG   (1 << 3)
-#define AMDM37x_UART_MCR_LOOPBACK_EN_FLAG   (1 << 4)
-#define AMDM37x_UART_MCR_XON_EN_FLAG   (1 << 5)
-#define AMDM37x_UART_MCR_TCR_TLR_FLAG   (1 << 6)
-
-		/** UART: XON1 char, IRDA: ADDR1 address */
-		ioport32_t xon1_addr1;
-#define AMDM37x_UART_XON1_ADDR1_MASK   (0xff)
-	};
-
-	union {
-		/** Line status register */
-		const ioport32_t lsr;
-#define AMDM37x_UART_LSR_RX_FIFO_E_FLAG   (1 << 0)
-#define AMDM37x_UART_LSR_RX_OE_FLAG   (1 << 1)
-#define AMDM37x_UART_LSR_RX_PE_FLAG   (1 << 2)
-#define AMDM37x_UART_LSR_RX_FE_FLAG   (1 << 3)
-#define AMDM37x_UART_LSR_RX_BI_FLAG   (1 << 4)
-#define AMDM37x_UART_LSR_TX_FIFO_E_FLAG   (1 << 5)
-#define AMDM37x_UART_LSR_TX_SR_E_FLAG   (1 << 6)
-#define AMDM37x_UART_LSR_RX_FIFO_STS_FLAG   (1 << 7)
-
-#define AMDM37x_CIR_LSR_RX_FIFO_E_FLAG   (1 << 0)
-#define AMDM37x_CIR_LSR_RX_STOP_FLAG   (1 << 5)
-#define AMDM37x_CIR_LSR_THR_EMPTY_FLAG   (1 << 7)
-
-#define AMDM37x_IRDA_LSR_RX_FIFO_E_FLAG   (1 << 0)
-#define AMDM37x_IRDA_LSR_STS_FIFO_E_FLAG   (1 << 1)
-#define AMDM37x_IRDA_LSR_CRC_FLAG   (1 << 2)
-#define AMDM37x_IRDA_LSR_ABORT_FLAG   (1 << 3)
-#define AMDM37x_IRDA_LSR_FTL_FLAG   (1 << 4)
-#define AMDM37x_IRDA_LSR_RX_LAST_FLAG   (1 << 5)
-#define AMDM37x_IRDA_LSR_STS_FIFO_FULL_FLAG   (1 << 6)
-#define AMDM37x_IRDA_LSR_THR_EMPTY_FLAG   (1 << 7)
-
-		/** UART: XON2 char, IRDA: ADDR2 address */
-		ioport32_t xon2_addr2;
-	};
-
-	union {
-		/** Modem status register */
-		const ioport32_t msr;
-#define AMDM37x_UART_MSR_CTS_STS_FLAG   (1 << 0)
-#define AMDM37x_UART_MSR_DSR_STS_FLAG   (1 << 1)
-#define AMDM37x_UART_MSR_RI_STS_FLAG   (1 << 2)
-#define AMDM37x_UART_MSR_DCD_STS_FLAG   (1 << 3)
-#define AMDM37x_UART_MSR_NCTS_STS_FLAG   (1 << 4)
-#define AMDM37x_UART_MSR_NDSR_STS_FLAG   (1 << 5)
-#define AMDM37x_UART_MSR_NRI_STS_FLAG   (1 << 6)
-#define AMDM37x_UART_MSR_NCD_STS_FLAG   (1 << 7)
-
-		/** Transmission control register */
-		ioport32_t tcr;
-#define AMDM37x_UART_TCR_FIFO_TRIG_MASK   (0xf)
-#define AMDM37x_UART_TCR_FIFO_TRIG_HALT_SHIFT   (0)
-#define AMDM37x_UART_TCR_FIFO_TRIG_START_SHIFT   (4)
-
-		/** UART: XOFF1 char */
-		ioport32_t xoff1;
-#define AMDM37x_UART_XOFF1_MASK   (0xff)
-	};
-
-	union {
-		/* Scratchpad register, does nothing */
-		ioport32_t spr;
-#define AMDM37x_UART_SPR_MASK   (0xff)
-
-		/* Trigger level register */
-		ioport32_t tlr;
-#define AMDM37x_UART_TLR_LEVEL_MASK   (0xf)
-#define AMDM37x_UART_TLR_TX_FIFO_TRIG_SHIFT   (0)
-#define AMDM37x_UART_TLR_RX_FIFO_TRIG_SHIFT   (4)
-
-		/** UART: XOFF2 char */
-		ioport32_t xoff2;
-#define AMDM37x_UART_XOFF2_MASK   (0xff)
-	};
-
-	/** Mode definition register. */
-	ioport32_t mdr1;
-#define AMDM37x_UART_MDR_MS_MASK   (0x7)
-#define AMDM37x_UART_MDR_MS_SHIFT   (0)
-#define AMDM37x_UART_MDR_MS_UART16   (0x0)
-#define AMDM37x_UART_MDR_MS_SIR   (0x1)
-#define AMDM37x_UART_MDR_MS_UART16_AUTO   (0x2)
-#define AMDM37x_UART_MDR_MS_UART13   (0x3)
-#define AMDM37x_UART_MDR_MS_MIR   (0x4)
-#define AMDM37x_UART_MDR_MS_FIR   (0x5)
-#define AMDM37x_UART_MDR_MS_CIR   (0x6)
-#define AMDM37x_UART_MDR_MS_DISABLE   (0x7)
-
-#define AMDM37x_UART_MDR_IR_SLEEP_FLAG   (1 << 3)
-#define AMDM37x_UART_MDR_SET_TXIR_FLAG   (1 << 4)
-#define AMDM37x_UART_MDR_SCT_FLAG   (1 << 5)
-#define AMDM37x_UART_MDR_SIP_FLAG   (1 << 6)
-#define AMDM37x_UART_MDR_FRAME_END_MODE_FLAG   (1 << 7)
-
-	/** Mode definition register */
-	ioport32_t mdr2;
-#define AMDM37x_UART_MDR_IRTX_UNDERRUN_FLAG   (1 << 0)
-#define AMDM37x_UART_MDR_STS_FIFO_TRIG_MASK   (0x3)
-#define AMDM37x_UART_MDR_STS_FIFO_TRIG_SHIFT   (1)
-#define AMDM37x_UART_MDR_PULSE_SHAPING_FLAG   (1 << 3)
-#define AMDM37x_UART_MDR_CIR_PULSE_MODE_MASK   (0x3)
-#define AMDM37x_UART_MDR_CIR_PULSE_MODE_SHIFT   (4)
-#define AMDM37x_UART_MDR_IRRXINVERT_FLAG   (1 << 6)
-
-
-	/* UART3 specific */
-	union {
-		/** Status FIFO line status register (IrDA only) */
-		const ioport32_t sflsr;
-#define AMDM37x_IRDA_SFLSR_CRC_ERROR_FLAG   (1 << 1)
-#define AMDM37x_IRDA_SFLSR_ABORT_FLAG   (1 << 2)
-#define AMDM37x_IRDA_SFLSR_FTL_FLAG   (1 << 3)
-#define AMDM37x_IRDA_SFLSR_OE_FLAG   (1 << 4)
-
-		/** Transmit frame length low (IrDA only) */
-		ioport32_t txfll;
-#define AMDM37x_UART_TXFLL_MASK   (0xff)
-	};
-
-	/* UART3 specific */
-	union {
-		/** Dummy register to restart TX or RX (IrDA only) */
-		const ioport32_t resume;
-		/** Transmit frame length high (IrDA only) */
-		ioport32_t txflh;
-#define AMDM37x_UART_TXFLH_MASK   (0xff)
-	};
-
-	/* UART3 specific */
-	union {
-		/** Status FIFO register low (IrDA only) */
-		const ioport32_t sfregl;
-#define AMDM37x_UART_SFREGL_MASK   (0xff)
-		/** Received frame length low (IrDA only) */
-		ioport32_t rxfll;
-#define AMDM37x_UART_RXFLL_MASK   (0xff)
-	};
-
-	/* UART3 specific */
-	union {
-		/** Status FIFO register high (IrDA only) */
-		const ioport32_t sfregh;
-#define AMDM37x_UART_SFREGH_MASK   (0xf)
-		/** Received frame length high (IrDA only) */
-		ioport32_t rxflh;
-#define AMDM37x_UART_RXFLH_MASK   (0xf)
-	};
-
-	union {
-		/** UART autobauding status register */
-		const ioport32_t uasr;
-#define AMDM37x_UART_UASR_SPEED_MASK   (0x1f)
-#define AMDM37x_UART_UASR_SPEED_SHIFT   (0)
-#define AMDM37x_UART_UASR_8BIT_CHAR_FLAG   (1 << 5)
-#define AMDM37x_UART_UASR_PARITY_MASK   (0x3)
-#define AMDM37x_UART_UASR_PARITY_SHIFT   (6)
-
-		/** BOF control register (IrDA only) */
-		ioport32_t blr; /* UART3 specific */
-#define AMDM37x_IRDA_BLR_XBOF_TYPE_FLAG   (1 << 6)
-#define AMDM37x_IRDA_BLR_STS_FIFO_RESET   (1 << 7)
-	};
-
-	/** Auxiliary control register (IrDA only) */
-	ioport32_t acreg; /* UART3 specific */
-#define AMDM37x_IRDA_ACREG_EOT_EN_FLAG   (1 << 0)
-#define AMDM37x_IRDA_ACREG_ABORT_EN_FLAG   (1 << 1)
-#define AMDM37x_IRDA_ACREG_SCTX_EN_FLAG   (1 << 2)
-#define AMDM37x_IRDA_ACREG_SEND_SIP_FLAG   (1 << 3)
-#define AMDM37x_IRDA_ACREG_DIS_TX_UNDERRUN_FLAG   (1 << 4)
-#define AMDM37x_IRDA_ACREG_DIS_IR_RX_FLAG   (1 << 5)
-#define AMDM37x_IRDA_ACREG_SD_MOD_FLAG   (1 << 6)
-#define AMDM37x_IRDA_ACREG_PULSE_TYPE_FLAG   (1 << 7)
-
-	/** Supplementary control register */
-	ioport32_t scr;
-#define AMDM37x_UART_SCR_DMA_MODE_CTL_FLAG   (1 << 0)
-#define AMDM37x_UART_SCR_DMA_MODE_MASK   (0x3)
-#define AMDM37x_UART_SCR_DMA_MODE_SHIFT   (1)
-#define AMDM37x_UART_SCR_TX_EMPTY_CTL_IRQ_FLAG   (1 << 3)
-#define AMDM37x_UART_SCR_RX_CTS_WU_EN_FLAG   (1 << 4)
-#define AMDM37x_UART_SCR_TX_TRIG_GRANU1_FLAG   (1 << 6)
-#define AMDM37x_UART_SCR_RX_TRIG_GRANU1_FLAG   (1 << 7)
-
-	/** Supplementary status register */
-	const ioport32_t ssr;
-#define AMDM37x_UART_SSR_TX_FIFO_FULL_FLAG   (1 << 0)
-#define AMDM37x_UART_SSR_RX_CTS_WU_STS_FLAG   (1 << 1)
-#define AMDM37x_UART_SSR_DMA_COUNTER_RESET_FLAG   (1 << 2)
-
-	/** BOF Length register (IrDA only)*/
-	ioport32_t eblr; /* UART3 specific */
-#define AMDM37x_IRDA_EBLR_DISABLED   (0x00)
-#define AMDM37x_IRDA_EBLR_RX_STOP_BITS(bits)   (bits & 0xff)
-
-	uint32_t padd0_;
-
-	/** Module version register */
-	const ioport32_t mvr;
-#define AMDM37x_UART_MVR_MINOR_MASK   (0xf)
-#define AMDM37x_UART_MVR_MINOR_SHIFT   (0)
-#define AMDM37x_UART_MVR_MAJOR_MASK   (0xf)
-#define AMDM37x_UART_MVR_MAJOR_SHIFT   (4)
-
-	/** System configuration register */
-	ioport32_t sysc;
-#define AMDM37x_UART_SYSC_AUTOIDLE_FLAG   (1 << 0)
-#define AMDM37x_UART_SYSC_SOFTRESET_FLAG   (1 << 1)
-#define AMDM37x_UART_SYSC_ENWAKEUP_FLAG   (1 << 2)
-#define AMDM37x_UART_SYSC_IDLE_MODE_MASK   (0x3)
-#define AMDM37x_UART_SYSC_IDLE_MODE_SHIFT   (3)
-#define AMDM37x_UART_SYSC_IDLE_MODE_FORCE   (0x0)
-#define AMDM37x_UART_SYSC_IDLE_MODE_NO   (0x1)
-#define AMDM37x_UART_SYSC_IDLE_MODE_SMART   (0x2)
-
-	/** System status register */
-	const ioport32_t syss;
-#define AMDM37x_UART_SYSS_RESETDONE_FLAG   (1 << 0)
-
-	/** Wake-up enable register */
-	ioport32_t wer;
-#define AMDM37x_UART_WER_CTS_ACTIVITY_FLAG  (1 << 0)
-#define AMDM37x_UART_WER_RI_ACTIVITY_FLAG  (1 << 2)
-#define AMDM37x_UART_WER_RX_ACTIVITY_FLAG  (1 << 4)
-#define AMDM37x_UART_WER_RHR_IRQ_FLAG  (1 << 5)
-#define AMDM37x_UART_WER_RLS_IRQ_FLAG  (1 << 6)
-#define AMDM37x_UART_WER_TX_WAKEUP_EN_FLAG  (1 << 7)
-
-	/** Carrier frequency prescaler */
-	ioport32_t cfps;	/* UART3 specific */
-#define AMDM37x_UART_CFPS_MASK   (0xff)
-
-	/** Number of bytes in RX fifo */
-	const ioport32_t rx_fifo_lvl;
-#define AMDM37x_UART_RX_FIFO_LVL_MASK   (0xff)
-
-	/** Number of bytes in TX fifo */
-	const ioport32_t tx_fifo_lvl;
-#define AMDM37x_UART_TX_FIFO_LVL_MASK   (0xff)
-
-	/** RX/TX empty interrupts */
-	ioport32_t ier2;
-#define AMDM37x_UART_IER2_RX_FIFO_EMPTY_IRQ_EN_FLAG  (1 << 0)
-#define AMDM37x_UART_IER2_TX_FIFO_EMPTY_IRQ_EN_FLAG  (1 << 1)
-
-	/** RX/TX empty status */
-	ioport32_t isr2;
-#define AMDM37x_UART_ISR2_RX_FIFO_EMPTY_FLAG  (1 << 0)
-#define AMDM37x_UART_ISR2_TX_FIFO_EMPTY_FLAG  (1 << 1)
-
-	uint32_t padd2_[3];
-
-	/** Mode definition register 3 */
-	ioport32_t mdr3;
-#define AMDM37x_UART_MDR3_DIS_CIR_RX_DEMOD_FLAG   (1 << 0)
-} amdm37x_uart_regs_t;
-
-#endif
-
-/**
- * @}
- */
Index: rnel/genarch/src/drivers/am335x/timer.c
===================================================================
--- kernel/genarch/src/drivers/am335x/timer.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,180 +1,0 @@
-/*
- * Copyright (c) 2012 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x timer driver.
- */
-
-#include <genarch/drivers/am335x/timer.h>
-#include <mm/km.h>
-#include <errno.h>
-
-typedef enum {
-	REG_TCLR = 0x00,
-	REG_TCRR = 0x01,
-	REG_TLDR = 0x02,
-	REG_TTGR = 0x04
-} timer_reg_t;
-
-typedef struct timer_regs_mmap {
-        uintptr_t base;
-        size_t size;
-} timer_regs_mmap_t;
-
-static const timer_regs_mmap_t regs_map[TIMERS_MAX] = {
-	{ .base = AM335x_DMTIMER0_BASE_ADDRESS, .size = AM335x_DMTIMER0_SIZE },
-	{0, 0}, /* DMTIMER1 is not supported by this driver */
-	{ .base = AM335x_DMTIMER2_BASE_ADDRESS, .size = AM335x_DMTIMER2_SIZE },
-	{ .base = AM335x_DMTIMER3_BASE_ADDRESS, .size = AM335x_DMTIMER3_SIZE },
-	{ .base = AM335x_DMTIMER4_BASE_ADDRESS, .size = AM335x_DMTIMER4_SIZE },
-	{ .base = AM335x_DMTIMER5_BASE_ADDRESS, .size = AM335x_DMTIMER5_SIZE },
-	{ .base = AM335x_DMTIMER6_BASE_ADDRESS, .size = AM335x_DMTIMER6_SIZE },
-	{ .base = AM335x_DMTIMER7_BASE_ADDRESS, .size = AM335x_DMTIMER7_SIZE },
-};
-
-static void
-write_register_posted(am335x_timer_t *timer, timer_reg_t reg, uint32_t value)
-{
-	am335x_timer_regs_t *regs = timer->regs;
-
-	while (regs->twps & reg);
-
-	switch (reg) {
-	default:
-		return;
-	case REG_TCLR:
-		regs->tclr = value;
-		break;
-	case REG_TCRR:
-		regs->tcrr = value;
-		break;
-	case REG_TLDR:
-		regs->tldr = value;
-		break;
-	}
-}
-
-int
-am335x_timer_init(am335x_timer_t *timer, am335x_timer_id_t id, unsigned hz,
-    unsigned srcclk_hz)
-{
-	uintptr_t base_addr;
-	size_t size;
-
-	ASSERT(id < TIMERS_MAX);
-	ASSERT(timer != NULL);
-
-	if (id == DMTIMER1_1MS)
-		return ENOTSUP; /* Not supported yet */
-
-	base_addr = regs_map[id].base;
-	size = regs_map[id].size;
-
-	timer->regs = (void *) km_map(base_addr, size, PAGE_NOT_CACHEABLE);
-	ASSERT(timer->regs != NULL);
-
-	timer->id = id;
-
-	am335x_timer_regs_t *regs = timer->regs;
-
-	/* Enable the posted mode of operation */
-	regs->tsicr |= AM335x_TIMER_TSICR_POSTED_FLAG;
-
-	/* Stop the timer */
-	am335x_timer_stop(timer);
-
-	/* Perform a soft reset */
-	am335x_timer_reset(timer);
-
-	unsigned tclr = regs->tclr;
-
-	/* Disable compare mode */
-	tclr &= ~AM335x_TIMER_TCLR_CE_FLAG;
-	/* Enable the prescaler, divisor = 2 */
-	tclr |= AM335x_TIMER_TCLR_PRE_FLAG;
-	tclr &= ~(AM335x_TIMER_TCLR_PTV_MASK << AM335x_TIMER_TCLR_PTV_SHIFT);
-	/* Enable auto-reload mode */
-	tclr |= AM335x_TIMER_TCLR_AR_FLAG;
-
-	write_register_posted(timer, REG_TCLR, tclr);
-
-	/* Disable the emulation mode */
-	regs->tiocp_cfg |= AM335x_TIMER_TIOCPCFG_EMUFREE_FLAG;
-
-	unsigned const count = 0xFFFFFFFF - (srcclk_hz / hz + 1);
-	write_register_posted(timer, REG_TCRR, count);
-	write_register_posted(timer, REG_TLDR, count);
-
-	return EOK;
-}
-
-void
-am335x_timer_intr_ack(am335x_timer_t *timer)
-{
-	/* Clear pending OVF event */
-	timer->regs->irqstatus |= AM335x_TIMER_IRQSTATUS_OVF_FLAG;
-}
-
-void
-am335x_timer_reset(am335x_timer_t *timer)
-{
-	/* Initiate soft reset */
-	timer->regs->tiocp_cfg |= AM335x_TIMER_TIOCPCFG_SOFTRESET_FLAG;
-	/* Wait until the reset is done */
-	while (timer->regs->tiocp_cfg & AM335x_TIMER_TIOCPCFG_SOFTRESET_FLAG);
-}
-
-void
-am335x_timer_stop(am335x_timer_t *timer)
-{
-	/* Disable the interrupt */
-	timer->regs->irqenable_clr |= AM335x_TIMER_IRQENABLE_CLR_OVF_FLAG;
-	timer->regs->irqwakeen &= ~AM335x_TIMER_IRQWAKEEN_OVF_FLAG;
-	/* Stop the timer */
-	write_register_posted(timer, REG_TCLR,
-	    timer->regs->tclr & ~AM335x_TIMER_TCLR_ST_FLAG);
-}
-
-void
-am335x_timer_start(am335x_timer_t *timer)
-{
-	/* Enable the interrupt */
-	timer->regs->irqenable_set |= AM335x_TIMER_IRQENABLE_SET_OVF_FLAG;
-	timer->regs->irqwakeen |= AM335x_TIMER_IRQWAKEEN_OVF_FLAG;
-	/* Start the clock */
-	write_register_posted(timer, REG_TCLR,
-	    timer->regs->tclr | AM335x_TIMER_TCLR_ST_FLAG);
-}
-
-/**
- * @}
- */
-
Index: rnel/genarch/src/drivers/am335x/uart.c
===================================================================
--- kernel/genarch/src/drivers/am335x/uart.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,183 +1,0 @@
-/*
- * Copyright (c) 2012 Jan Vesely
- * Copyright (c) 2013 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM335x on-chip uart serial line driver.
- */
-
-#include <genarch/drivers/am335x/uart.h>
-#include <ddi/device.h>
-#include <str.h>
-#include <mm/km.h>
-
-static void am335x_uart_txb(am335x_uart_t *uart, uint8_t b)
-{
-	/* Wait for buffer */
-	while (uart->regs->ssr & AM335x_UART_SSR_TX_FIFO_FULL_FLAG);
-	/* Write to the outgoing fifo */
-	uart->regs->thr = b;
-}
-
-static void am335x_uart_putchar(outdev_t *dev, wchar_t ch)
-{
-	am335x_uart_t *uart = dev->data;
-	if (!ascii_check(ch)) {
-		am335x_uart_txb(uart, U_SPECIAL);
-	} else {
-		if (ch == '\n')
-			am335x_uart_txb(uart, '\r');
-		am335x_uart_txb(uart, ch);
-	}
-}
-
-static outdev_operations_t am335x_uart_ops = {
-	.redraw = NULL,
-	.write = am335x_uart_putchar,
-};
-
-static irq_ownership_t am335x_uart_claim(irq_t *irq)
-{
-	return IRQ_ACCEPT;
-}
-
-static void am335x_uart_handler(irq_t *irq)
-{
-	am335x_uart_t *uart = irq->instance;
-	while ((uart->regs->rx_fifo_lvl)) {
-		const uint8_t val = uart->regs->rhr;
-		if (uart->indev && val) {
-			indev_push_character(uart->indev, val);
-		}
-	}
-}
-
-bool am335x_uart_init(
-    am335x_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size)
-{
-	ASSERT(uart);
-	uart->regs = (void *)km_map(addr, size, PAGE_NOT_CACHEABLE);
-
-	ASSERT(uart->regs);
-
-	/* Soft reset the port */
-	uart->regs->sysc = AM335x_UART_SYSC_SOFTRESET_FLAG;
-	while (!(uart->regs->syss & AM335x_UART_SYSS_RESETDONE_FLAG));
-
-	/* Disable the UART module */
-	uart->regs->mdr1 |= AM335x_UART_MDR_MS_DISABLE;
-
-	/* Enable access to EFR register */
-	uart->regs->lcr = 0xbf;              /* Sets config mode B */
-
-	/* Enable access to TCL_TLR register */
-	const bool enhanced = uart->regs->efr & AM335x_UART_EFR_ENH_FLAG;
-	uart->regs->efr |= AM335x_UART_EFR_ENH_FLAG; /* Turn on enh. */
-	uart->regs->lcr = 0x80;              /* Config mode A */
-
-	/* Set default (val 0) triggers, disable DMA enable FIFOs */
-	const bool tcl_tlr = uart->regs->mcr & AM335x_UART_MCR_TCR_TLR_FLAG;
-	/* Enable access to tcr and tlr registers */
-	uart->regs->mcr |= AM335x_UART_MCR_TCR_TLR_FLAG;
-
-	/* Enable FIFOs */
-	uart->regs->fcr = AM335x_UART_FCR_FIFO_EN_FLAG;
-
-	/* Enable fine granularity for RX FIFO and set trigger level to 1,
-	 * TX FIFO, trigger level is irrelevant*/
-	uart->regs->lcr = 0xBF;              /* Sets config mode B */
-	uart->regs->scr = AM335x_UART_SCR_RX_TRIG_GRANU1_FLAG;
-	uart->regs->tlr = 1 << AM335x_UART_TLR_RX_FIFO_TRIG_SHIFT;
-
-	/* Sets config mode A */
-	uart->regs->lcr = 0x80;
-	/* Restore tcl_tlr access flag */
-	if (!tcl_tlr)
-		uart->regs->mcr &= ~AM335x_UART_MCR_TCR_TLR_FLAG;
-	/* Sets config mode B */
-	uart->regs->lcr = 0xBF;
-
-	/* Set the divisor value to get a baud rate of 115200 bps */
-	uart->regs->dll = 0x1A;
-	uart->regs->dlh = 0x00;
-
-	/* Restore enhanced */
-	if (!enhanced)
-		uart->regs->efr &= ~AM335x_UART_EFR_ENH_FLAG;
-
-	/* Set the DIV_EN bit to 0 */
-	uart->regs->lcr &= ~AM335x_UART_LCR_DIV_EN_FLAG;
-	/* Set the BREAK_EN bit to 0 */
-	uart->regs->lcr &= ~AM335x_UART_LCR_BREAK_EN_FLAG;
-	/* No parity */
-	uart->regs->lcr &= ~AM335x_UART_LCR_PARITY_EN_FLAG;
-	/* Stop = 1 bit */
-	uart->regs->lcr &= ~AM335x_UART_LCR_NB_STOP_FLAG;
-	/* Char length = 8 bits */
-	uart->regs->lcr |= AM335x_UART_LCR_CHAR_LENGTH_8BITS;
-
-	/* Enable the UART module */
-	uart->regs->mdr1 &= (AM335x_UART_MDR_MS_UART16 &
-	    ~AM335x_UART_MDR_MS_MASK);
-
-	/* Disable interrupts */
-	uart->regs->ier = 0;
-
-	/* Setup outdev */
-	outdev_initialize("am335x_uart_dev", &uart->outdev, &am335x_uart_ops);
-	uart->outdev.data = uart;
-
-	/* Initialize IRQ */
-	irq_initialize(&uart->irq);
-	uart->irq.devno = device_assign_devno();
-	uart->irq.inr = interrupt;
-	uart->irq.claim = am335x_uart_claim;
-	uart->irq.handler = am335x_uart_handler;
-	uart->irq.instance = uart;
-
-	return true;
-}
-
-void am335x_uart_input_wire(am335x_uart_t *uart, indev_t *indev)
-{
-	ASSERT(uart);
-	/* Set indev */
-	uart->indev = indev;
-	/* Register interrupt. */
-	irq_register(&uart->irq);
-	/* Enable interrupt on receive */
-	uart->regs->ier |= AM335x_UART_IER_RHR_IRQ_FLAG;
-}
-
-/**
- * @}
- */
-
Index: rnel/genarch/src/drivers/amdm37x/uart.c
===================================================================
--- kernel/genarch/src/drivers/amdm37x/uart.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,163 +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 genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AMDM37x on-chip uart serial line driver.
- */
-
-#include <genarch/drivers/amdm37x/uart.h>
-#include <ddi/device.h>
-#include <str.h>
-#include <mm/km.h>
-
-static void amdm37x_uart_txb(amdm37x_uart_t *uart, uint8_t b)
-{
-	/* Wait for buffer */
-	while (uart->regs->ssr & AMDM37x_UART_SSR_TX_FIFO_FULL_FLAG);
-	/* Write to the outgoing fifo */
-	uart->regs->thr = b;
-}
-
-static void amdm37x_uart_putchar(outdev_t *dev, wchar_t ch)
-{
-	amdm37x_uart_t *uart = dev->data;
-	if (!ascii_check(ch)) {
-		amdm37x_uart_txb(uart, U_SPECIAL);
-	} else {
-		if (ch == '\n')
-			amdm37x_uart_txb(uart, '\r');
-		amdm37x_uart_txb(uart, ch);
-	}
-}
-
-static outdev_operations_t amdm37x_uart_ops = {
-	.redraw = NULL,
-	.write = amdm37x_uart_putchar,
-};
-
-static irq_ownership_t amdm37x_uart_claim(irq_t *irq)
-{
-	return IRQ_ACCEPT;
-}
-
-static void amdm37x_uart_handler(irq_t *irq)
-{
-	amdm37x_uart_t *uart = irq->instance;
-	while ((uart->regs->rx_fifo_lvl)) {
-		const uint8_t val = uart->regs->rhr;
-		if (uart->indev && val) {
-			indev_push_character(uart->indev, val);
-		}
-	}
-}
-
-bool amdm37x_uart_init(
-    amdm37x_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size)
-{
-	ASSERT(uart);
-	uart->regs = (void *)km_map(addr, size, PAGE_NOT_CACHEABLE);
-
-	ASSERT(uart->regs);
-
-	/* See TI OMAP35X TRM ch 17.5.1.1 p. 2732 for startup routine */
-#if 0
-	/* Soft reset the port */
-	uart->regs->sysc = AMDM37x_UART_SYSC_SOFTRESET_FLAG;
-	while (!(uart->regs->syss & AMDM37x_UART_SYSS_RESETDONE_FLAG)) ;
-#endif
-
-	/* Enable access to EFR register */
-	const uint8_t lcr = uart->regs->lcr; /* Save old value */
-	uart->regs->lcr = 0xbf;              /* Sets config mode B */
-
-	/* Enable access to TCL_TLR register */
-	const bool enhanced = uart->regs->efr & AMDM37x_UART_EFR_ENH_FLAG;
-	uart->regs->efr |= AMDM37x_UART_EFR_ENH_FLAG; /* Turn on enh. */
-	uart->regs->lcr = 0x80;              /* Config mode A */
-
-	/* Set default (val 0) triggers, disable DMA enable FIFOs */
-	const bool tcl_tlr = uart->regs->mcr & AMDM37x_UART_MCR_TCR_TLR_FLAG;
-	/* Enable access to tcr and tlr registers */
-	uart->regs->mcr |= AMDM37x_UART_MCR_TCR_TLR_FLAG;
-
-	/* Enable FIFOs */
-	uart->regs->fcr = AMDM37x_UART_FCR_FIFO_EN_FLAG;
-
-	/* Eneble fine granularity for RX FIFO and set trigger level to 1,
-	 * TX FIFO, trigger level is irelevant*/
-	uart->regs->lcr = 0xbf;              /* Sets config mode B */
-	uart->regs->scr = AMDM37x_UART_SCR_RX_TRIG_GRANU1_FLAG;
-	uart->regs->tlr = 1 << AMDM37x_UART_TLR_RX_FIFO_TRIG_SHIFT;
-
-	/* Restore enhanced */
-	if (!enhanced)
-		uart->regs->efr &= ~AMDM37x_UART_EFR_ENH_FLAG;
-
-	uart->regs->lcr = 0x80;              /* Config mode A */
-	/* Restore tcl_lcr access flag*/
-	if (!tcl_tlr)
-		uart->regs->mcr &= ~AMDM37x_UART_MCR_TCR_TLR_FLAG;
-
-	/* Restore lcr */
-	uart->regs->lcr = lcr;
-
-	/* Disable interrupts */
-	uart->regs->ier = 0;
-
-	/* Setup outdev */
-	outdev_initialize("amdm37x_uart_dev", &uart->outdev, &amdm37x_uart_ops);
-	uart->outdev.data = uart;
-
-	/* Initialize IRQ */
-	irq_initialize(&uart->irq);
-	uart->irq.devno = device_assign_devno();
-	uart->irq.inr = interrupt;
-	uart->irq.claim = amdm37x_uart_claim;
-	uart->irq.handler = amdm37x_uart_handler;
-	uart->irq.instance = uart;
-
-	return true;
-}
-
-void amdm37x_uart_input_wire(amdm37x_uart_t *uart, indev_t *indev)
-{
-	ASSERT(uart);
-	/* Set indev */
-	uart->indev = indev;
-	/* Register interrupt. */
-	irq_register(&uart->irq);
-	/* Enable interrupt on receive */
-	uart->regs->ier |= AMDM37x_UART_IER_RHR_IRQ_FLAG;
-}
-
-/**
- * @}
- */
Index: kernel/genarch/src/mm/page_ht.c
===================================================================
--- kernel/genarch/src/mm/page_ht.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/genarch/src/mm/page_ht.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -209,8 +209,4 @@
 		pte->frame = ALIGN_DOWN(frame, FRAME_SIZE);
 
-		/*
-		 * Make sure that a concurrent ht_mapping_find() will see the
-		 * new entry only after it is fully initialized.
-		 */
 		write_barrier();
 		
Index: kernel/genarch/src/mm/page_pt.c
===================================================================
--- kernel/genarch/src/mm/page_pt.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/genarch/src/mm/page_pt.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -89,9 +89,4 @@
 		    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
 		    PAGE_WRITE);
-		/*
-		 * Make sure that a concurrent hardware page table walk or
-		 * pt_mapping_find() will see the new PTL1 only after it is
-		 * fully initialized.
-		 */
 		write_barrier();
 		SET_PTL1_PRESENT(ptl0, PTL0_INDEX(page));
@@ -108,7 +103,4 @@
 		    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
 		    PAGE_WRITE);
-		/*
-		 * Make the new PTL2 visible only after it is fully initialized.
-		 */
 		write_barrier();
 		SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page));	
@@ -125,7 +117,4 @@
 		    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
 		    PAGE_WRITE);
-		/*
-		 * Make the new PTL3 visible only after it is fully initialized.
-		 */
 		write_barrier();
 		SET_PTL3_PRESENT(ptl2, PTL2_INDEX(page));
@@ -136,7 +125,4 @@
 	SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame);
 	SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags | PAGE_NOT_PRESENT);
-	/*
-	 * Make the new mapping visible only after it is fully initialized.
-	 */
 	write_barrier();
 	SET_FRAME_PRESENT(ptl3, PTL3_INDEX(page));
@@ -310,7 +296,4 @@
 
 #if (PTL1_ENTRIES != 0)
-	/*
-	 * Always read ptl2 only after we are sure it is present.
-	 */
 	read_barrier();
 #endif
@@ -321,7 +304,4 @@
 
 #if (PTL2_ENTRIES != 0)
-	/*
-	 * Always read ptl3 only after we are sure it is present.
-	 */
 	read_barrier();
 #endif
Index: kernel/generic/include/config.h
===================================================================
--- kernel/generic/include/config.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/include/config.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,6 +44,4 @@
 #define STACK_FRAMES  TWO_FRAMES
 #define STACK_SIZE    ((1 << STACK_FRAMES) << PAGE_WIDTH)
-
-#define STACK_SIZE_USER	(1 * 1024 * 1024)
 
 #define CONFIG_INIT_TASKS        32
Index: kernel/generic/include/console/console.h
===================================================================
--- kernel/generic/include/console/console.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/include/console/console.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -67,5 +67,5 @@
 extern wchar_t getc(indev_t *indev);
 extern size_t gets(indev_t *indev, char *buf, size_t buflen);
-extern sysarg_t sys_klog(int cmd, const void *buf, size_t size);
+extern sysarg_t sys_klog(int fd, const void *buf, size_t size);
 
 extern void grab_console(void);
Index: kernel/generic/include/macros.h
===================================================================
--- kernel/generic/include/macros.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/include/macros.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -52,19 +52,8 @@
     uint64_t sz2)
 {
-	uint64_t e1 = s1 + sz1 - 1;
-	uint64_t e2 = s2 + sz2 - 1;
-
-	/* both sizes are non-zero */
-	if (sz1 && sz2)
-		return ((s1 <= e2) && (s2 <= e1));
-
-	/* one size is non-zero */
-	if (sz2)
-		return ((s1 >= s2) && (s1 <= e2));
-	if (sz1)
-		return ((s2 >= s1) && (s2 <= e1));
-
-	/* both are zero */
-	return (s1 == s2);
+	uint64_t e1 = s1 + sz1;
+	uint64_t e2 = s2 + sz2;
+	
+	return ((s1 < e2) && (s2 < e1));
 }
 
@@ -130,12 +119,4 @@
 	    | ((((uint64_t) (up)) & UINT32_C(0xffffffff)) << 32))
 
-/* Test for sum overflow. */
-#define overflows(a, b) \
-	((a) + (b) < (a))
-
-/* Test for sum overflow into positive numbers. */
-#define overflows_into_positive(a, b)	\
-	(overflows((a), (b)) && ((a) + (b) > 0))
-
 /** Pseudorandom generator
  *
Index: kernel/generic/include/mm/as.h
===================================================================
--- kernel/generic/include/mm/as.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/include/mm/as.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -61,4 +61,10 @@
 #define USER_ADDRESS_SPACE_END      USER_ADDRESS_SPACE_END_ARCH
 
+#ifdef USTACK_ADDRESS_ARCH
+	#define USTACK_ADDRESS  USTACK_ADDRESS_ARCH
+#else
+	#define USTACK_ADDRESS  (USER_ADDRESS_SPACE_END - (STACK_SIZE - 1))
+#endif
+
 /** Kernel address space. */
 #define FLAG_AS_KERNEL  (1 << 0)
@@ -68,15 +74,12 @@
 #define AS_AREA_ATTR_PARTIAL  1  /**< Not fully initialized area. */
 
+/** The page fault was not resolved by as_page_fault(). */
+#define AS_PF_FAULT  0
+
 /** The page fault was resolved by as_page_fault(). */
-#define AS_PF_OK     0 
+#define AS_PF_OK  1
 
 /** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
-#define AS_PF_DEFER  1
-
-/** The page fault was not resolved by as_page_fault(). */
-#define AS_PF_FAULT  2
-
-/** The page fault was not resolved by as_page_fault(). Non-verbose version. */
-#define AS_PF_SILENT 3
+#define AS_PF_DEFER  2
 
 /** Address space structure.
@@ -221,7 +224,4 @@
 	void (* destroy)(as_area_t *);
 
-	bool (* is_resizable)(as_area_t *);
-	bool (* is_shareable)(as_area_t *);
-
 	int (* page_fault)(as_area_t *, uintptr_t, pf_access_t);
 	void (* frame_free)(as_area_t *, uintptr_t, uintptr_t);
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/console/cmd.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -56,5 +56,4 @@
 #include <cpu.h>
 #include <mm/tlb.h>
-#include <mm/km.h>
 #include <arch/mm/tlb.h>
 #include <mm/frame.h>
@@ -82,79 +81,4 @@
 	.func = cmd_help,
 	.argc = 0
-};
-
-/* Data and methods for pio_read_8 command */
-static int cmd_pio_read_8(cmd_arg_t *argv);
-static cmd_arg_t pio_read_8_argv[] = { { .type = ARG_TYPE_INT } };
-static cmd_info_t pio_read_8_info = {
-	.name = "pio_read_8",
-	.description = "pio_read_8 <address> Read 1 byte from memory (or port).",
-	.func = cmd_pio_read_8,
-	.argc = 1,
-	.argv = pio_read_8_argv
-};
-
-/* Data and methods for pio_read_16 command */
-static int cmd_pio_read_16(cmd_arg_t *argv);
-static cmd_arg_t pio_read_16_argv[] = { { .type = ARG_TYPE_INT } };
-static cmd_info_t pio_read_16_info = {
-	.name = "pio_read_16",
-	.description = "pio_read_16 <address> Read 2 bytes from memory (or port).",
-	.func = cmd_pio_read_16,
-	.argc = 1,
-	.argv = pio_read_16_argv
-};
-
-/* Data and methods for pio_read_32 command */
-static int cmd_pio_read_32(cmd_arg_t *argv);
-static cmd_arg_t pio_read_32_argv[] = { { .type = ARG_TYPE_INT } };
-static cmd_info_t pio_read_32_info = {
-	.name = "pio_read_32",
-	.description = "pio_read_32 <address> Read 4 bytes from memory (or port).",
-	.func = cmd_pio_read_32,
-	.argc = 1,
-	.argv = pio_read_32_argv
-};
-
-/* Data and methods for pio_write_8 command */
-static int cmd_pio_write_8(cmd_arg_t *argv);
-static cmd_arg_t pio_write_8_argv[] = {
-	{ .type = ARG_TYPE_INT },
-	{ .type = ARG_TYPE_INT }
-};
-static cmd_info_t pio_write_8_info = {
-	.name = "pio_write_8",
-	.description = "pio_write_8 <address> <value> Write 1 byte to memory (or port).",
-	.func = cmd_pio_write_8,
-	.argc = 2,
-	.argv = pio_write_8_argv
-};
-
-/* Data and methods for pio_write_16 command */
-static int cmd_pio_write_16(cmd_arg_t *argv);
-static cmd_arg_t pio_write_16_argv[] = {
-	{ .type = ARG_TYPE_INT },
-	{ .type = ARG_TYPE_INT }
-};
-static cmd_info_t pio_write_16_info = {
-	.name = "pio_write_16",
-	.description = "pio_write_16 <address> <value> Write 2 bytes to memory (or port).",
-	.func = cmd_pio_write_16,
-	.argc = 2,
-	.argv = pio_write_16_argv
-};
-
-/* Data and methods for pio_write_32 command */
-static int cmd_pio_write_32(cmd_arg_t *argv);
-static cmd_arg_t pio_write_32_argv[] = {
-	{ .type = ARG_TYPE_INT },
-	{ .type = ARG_TYPE_INT }
-};
-static cmd_info_t pio_write_32_info = {
-	.name = "pio_write_32",
-	.description = "pio_write_32 <address> <value> Write 4 bytes to memory (or port).",
-	.func = cmd_pio_write_32,
-	.argc = 2,
-	.argv = pio_write_32_argv
 };
 
@@ -607,10 +531,4 @@
 	&btrace_info,
 #endif
-	&pio_read_8_info,
-	&pio_read_16_info,
-	&pio_read_32_info,
-	&pio_write_8_info,
-	&pio_write_16_info,
-	&pio_write_32_info,
 	NULL
 };
@@ -683,187 +601,4 @@
 	spinlock_unlock(&cmd_lock);
 	
-	return 1;
-}
-
-/** Read 1 byte from phys memory or io port.
- *
- * @param argv Argument vector.
- *
- * @return 0 on failure, 1 on success.
- */
-static int cmd_pio_read_8(cmd_arg_t *argv)
-{
-	uint8_t *ptr = NULL;
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		ptr = (void *) argv[0].intval;
-	else
-#endif
-		ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
-		    PAGE_NOT_CACHEABLE);
-	
-	const uint8_t val = pio_read_8(ptr);
-	printf("read %" PRIxn ": %" PRIx8 "\n", argv[0].intval, val);
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		return 1;
-#endif
-	
-	km_unmap((uintptr_t) ptr, sizeof(uint8_t));
-	return 1;
-}
-
-/** Read 2 bytes from phys memory or io port.
- *
- * @param argv Argument vector.
- *
- * @return 0 on failure, 1 on success.
- */
-static int cmd_pio_read_16(cmd_arg_t *argv)
-{
-	uint16_t *ptr = NULL;
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		ptr = (void *) argv[0].intval;
-	else
-#endif
-		ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
-		    PAGE_NOT_CACHEABLE);
-	
-	const uint16_t val = pio_read_16(ptr);
-	printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val);
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		return 1;
-#endif
-	
-	km_unmap((uintptr_t) ptr, sizeof(uint16_t));
-	return 1;
-}
-
-/** Read 4 bytes from phys memory or io port.
- *
- * @param argv Argument vector.
- *
- * @return 0 on failure, 1 on success.
- */
-static int cmd_pio_read_32(cmd_arg_t *argv)
-{
-	uint32_t *ptr = NULL;
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		ptr = (void *) argv[0].intval;
-	else
-#endif
-		ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
-		    PAGE_NOT_CACHEABLE);
-	
-	const uint32_t val = pio_read_32(ptr);
-	printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val);
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		return 1;
-#endif
-	
-	km_unmap((uintptr_t) ptr, sizeof(uint32_t));
-	return 1;
-}
-
-/** Write 1 byte to phys memory or io port.
- *
- * @param argv Argument vector.
- *
- * @return 0 on failure, 1 on success.
- */
-static int cmd_pio_write_8(cmd_arg_t *argv)
-{
-	uint8_t *ptr = NULL;
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		ptr = (void *) argv[0].intval;
-	else
-#endif
-		ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
-		    PAGE_NOT_CACHEABLE);
-	
-	printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval,
-	    (uint8_t) argv[1].intval);
-	pio_write_8(ptr, (uint8_t) argv[1].intval);
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		return 1;
-#endif
-	
-	km_unmap((uintptr_t) ptr, sizeof(uint8_t));
-	return 1;
-}
-
-/** Write 2 bytes to phys memory or io port.
- *
- * @param argv Argument vector.
- *
- * @return 0 on failure, 1 on success.
- */
-static int cmd_pio_write_16(cmd_arg_t *argv)
-{
-	uint16_t *ptr = NULL;
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		ptr = (void *) argv[0].intval;
-	else
-#endif
-		ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
-		    PAGE_NOT_CACHEABLE);
-	
-	printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval,
-	    (uint16_t) argv[1].intval);
-	pio_write_16(ptr, (uint16_t) argv[1].intval);
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		return 1;
-#endif
-	
-	km_unmap((uintptr_t) ptr, sizeof(uint16_t));
-	return 1;
-}
-
-/** Write 4 bytes to phys memory or io port.
- *
- * @param argv Argument vector.
- *
- * @return 0 on failure, 1 on success.
- */
-static int cmd_pio_write_32(cmd_arg_t *argv)
-{
-	uint32_t *ptr = NULL;
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		ptr = (void *) argv[0].intval;
-	else
-#endif
-		ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
-		    PAGE_NOT_CACHEABLE);
-	
-	printf("write %" PRIxn ": %" PRIx32 "\n", argv[0].intval,
-	    (uint32_t) argv[1].intval);
-	pio_write_32(ptr, (uint32_t) argv[1].intval);
-	
-#ifdef IO_SPACE_BOUNDARY
-	if ((void *) argv->intval < IO_SPACE_BOUNDARY)
-		return 1;
-#endif
-	
-	km_unmap((uintptr_t) ptr, sizeof(uint32_t));
 	return 1;
 }
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/console/console.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -52,5 +52,4 @@
 #include <errno.h>
 #include <str.h>
-#include <abi/klog.h>
 
 #define KLOG_PAGES    8
@@ -336,20 +335,9 @@
  *
  */
-sysarg_t sys_klog(int cmd, const void *buf, size_t size)
+sysarg_t sys_klog(int fd, const void *buf, size_t size)
 {
 	char *data;
 	int rc;
-
-	switch (cmd) {
-	case KLOG_UPDATE:
-		klog_update(NULL);
-		return EOK;
-	case KLOG_WRITE:
-	case KLOG_COMMAND:
-		break;
-	default:
-		return ENOTSUP;
-	}
-
+	
 	if (size > PAGE_SIZE)
 		return (sysarg_t) ELIMIT;
@@ -367,20 +355,9 @@
 		data[size] = 0;
 		
-		switch (cmd) {
-		case KLOG_WRITE:
-			printf("%s", data);
-			break;
-		case KLOG_COMMAND:
-			if (!stdin)
-				break;
-			for (unsigned int i = 0; i < size; i++)
-				indev_push_character(stdin, data[i]);
-			indev_push_character(stdin, '\n');
-			break;
-		}
-
+		printf("%s", data);
 		free(data);
-	}
-
+	} else
+		klog_update(NULL);
+	
 	return size;
 }
Index: kernel/generic/src/console/kconsole.c
===================================================================
--- kernel/generic/src/console/kconsole.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/console/kconsole.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -524,14 +524,11 @@
 		/* It's a number - convert it */
 		uint64_t value;
-		char *end;
-		int rc = str_uint64_t(text, &end, 0, false, &value);
-		if (end != text + len)
-			rc = EINVAL;
+		int rc = str_uint64_t(text, NULL, 0, true, &value);
 		switch (rc) {
 		case EINVAL:
-			printf("Invalid number '%s'.\n", text);
+			printf("Invalid number.\n");
 			return false;
 		case EOVERFLOW:
-			printf("Integer overflow in '%s'.\n", text);
+			printf("Integer overflow.\n");
 			return false;
 		case EOK:
@@ -541,5 +538,5 @@
 			break;
 		default:
-			printf("Unknown error parsing '%s'.\n", text);
+			printf("Unknown error.\n");
 			return false;
 		}
Index: kernel/generic/src/interrupt/interrupt.c
===================================================================
--- kernel/generic/src/interrupt/interrupt.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/interrupt/interrupt.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -166,6 +166,5 @@
 }
 
-static NO_TRACE
-void fault_from_uspace_core(istate_t *istate, const char *fmt, va_list args)
+static NO_TRACE void fault_from_uspace_core(istate_t *istate, const char *fmt, va_list args)
 {
 	printf("Task %s (%" PRIu64 ") killed due to an exception at "
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/main/kinit.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -172,10 +172,4 @@
 #endif /* CONFIG_KCONSOLE */
 	
-	/*
-	 * Store the default stack size in sysinfo so that uspace can create
-	 * stack with this default size.
-	 */
-	sysinfo_set_item_val("default.stack_size", NULL, STACK_SIZE_USER);
-	
 	interrupts_enable();
 	
@@ -250,14 +244,6 @@
 				    CAP_IO_MANAGER | CAP_IRQ_REG);
 				
-				if (!ipc_phone_0) {
+				if (!ipc_phone_0)
 					ipc_phone_0 = &programs[i].task->answerbox;
-					/*
-					 * Hold the first task so that the
-					 * ipc_phone_0 remains a valid pointer
-					 * even if the first task exits for
-					 * whatever reason.
-					 */
-					task_hold(programs[i].task);
-				}
 			}
 			
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/mm/as.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -79,5 +79,4 @@
 #include <syscall/copy.h>
 #include <arch/interrupt.h>
-#include <interrupt.h>
 
 /**
@@ -286,9 +285,8 @@
 /** Check area conflicts with other areas.
  *
- * @param as      Address space.
- * @param addr    Starting virtual address of the area being tested.
- * @param count   Number of pages in the area being tested.
- * @param guarded True if the area being tested is protected by guard pages.
- * @param avoid   Do not touch this area.
+ * @param as    Address space.
+ * @param addr  Starting virtual address of the area being tested.
+ * @param count Number of pages in the area being tested.
+ * @param avoid Do not touch this area.
  *
  * @return True if there is no conflict, false otherwise.
@@ -296,15 +294,8 @@
  */
 NO_TRACE static bool check_area_conflicts(as_t *as, uintptr_t addr,
-    size_t count, bool guarded, as_area_t *avoid)
+    size_t count, as_area_t *avoid)
 {
 	ASSERT((addr % PAGE_SIZE) == 0);
 	ASSERT(mutex_locked(&as->lock));
-
-	/*
-	 * If the addition of the supposed area address and size overflows,
-	 * report conflict.
-	 */
-	if (overflows_into_positive(addr, P2SZ(count)))
-		return false;
 	
 	/*
@@ -313,5 +304,5 @@
 	if (overlaps(addr, P2SZ(count), (uintptr_t) NULL, PAGE_SIZE))
 		return false;
-
+	
 	/*
 	 * The leaf node is found in O(log n), where n is proportional to
@@ -337,51 +328,6 @@
 		if (area != avoid) {
 			mutex_lock(&area->lock);
-
-			/*
-			 * If at least one of the two areas are protected
-			 * by the AS_AREA_GUARD flag then we must be sure
-			 * that they are separated by at least one unmapped
-			 * page.
-			 */
-			int const gp = (guarded || 
-			    (area->flags & AS_AREA_GUARD)) ? 1 : 0;
-			
-			/*
-			 * The area comes from the left neighbour node, which
-			 * means that there already are some areas in the leaf
-			 * node, which in turn means that adding gp is safe and
-			 * will not cause an integer overflow.
-			 */
+			
 			if (overlaps(addr, P2SZ(count), area->base,
-			    P2SZ(area->pages + gp))) {
-				mutex_unlock(&area->lock);
-				return false;
-			}
-			
-			mutex_unlock(&area->lock);
-		}
-	}
-	
-	node = btree_leaf_node_right_neighbour(&as->as_area_btree, leaf);
-	if (node) {
-		area = (as_area_t *) node->value[0];
-		
-		if (area != avoid) {
-			int gp;
-
-			mutex_lock(&area->lock);
-
-			gp = (guarded || (area->flags & AS_AREA_GUARD)) ? 1 : 0;
-			if (gp && overflows(addr, P2SZ(count))) {
-				/*
-				 * Guard page not needed if the supposed area
-				 * is adjacent to the end of the address space.
-				 * We already know that the following test is
-				 * going to fail...
-				 */
-				gp--;
-			}
-			
-			if (overlaps(addr, P2SZ(count + gp), area->base,
 			    P2SZ(area->pages))) {
 				mutex_unlock(&area->lock);
@@ -393,10 +339,25 @@
 	}
 	
+	node = btree_leaf_node_right_neighbour(&as->as_area_btree, leaf);
+	if (node) {
+		area = (as_area_t *) node->value[0];
+		
+		if (area != avoid) {
+			mutex_lock(&area->lock);
+			
+			if (overlaps(addr, P2SZ(count), area->base,
+			    P2SZ(area->pages))) {
+				mutex_unlock(&area->lock);
+				return false;
+			}
+			
+			mutex_unlock(&area->lock);
+		}
+	}
+	
 	/* Second, check the leaf node. */
 	btree_key_t i;
 	for (i = 0; i < leaf->keys; i++) {
 		area = (as_area_t *) leaf->value[i];
-		int agp;
-		int gp;
 		
 		if (area == avoid)
@@ -404,18 +365,7 @@
 		
 		mutex_lock(&area->lock);
-
-		gp = (guarded || (area->flags & AS_AREA_GUARD)) ? 1 : 0;
-		agp = gp;
-
-		/*
-		 * Sanitize the two possible unsigned integer overflows.
-		 */
-		if (gp && overflows(addr, P2SZ(count)))
-			gp--;
-		if (agp && overflows(area->base, P2SZ(area->pages)))
-			agp--;
-
-		if (overlaps(addr, P2SZ(count + gp), area->base,
-		    P2SZ(area->pages + agp))) {
+		
+		if (overlaps(addr, P2SZ(count), area->base,
+		    P2SZ(area->pages))) {
 			mutex_unlock(&area->lock);
 			return false;
@@ -427,10 +377,9 @@
 	/*
 	 * So far, the area does not conflict with other areas.
-	 * Check if it is contained in the user address space.
+	 * Check if it doesn't conflict with kernel address space.
 	 */
 	if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
-		return iswithin(USER_ADDRESS_SPACE_START,
-		    (USER_ADDRESS_SPACE_END - USER_ADDRESS_SPACE_START) + 1,
-		    addr, P2SZ(count));
+		return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START,
+		    KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
 	}
 	
@@ -443,8 +392,7 @@
  * this function.
  *
- * @param as      Address space.
- * @param bound   Lowest address bound.
- * @param size    Requested size of the allocation.
- * @param guarded True if the allocation must be protected by guard pages.
+ * @param as    Address space.
+ * @param bound Lowest address bound.
+ * @param size  Requested size of the allocation.
  *
  * @return Address of the beginning of unmapped address space area.
@@ -453,5 +401,5 @@
  */
 NO_TRACE static uintptr_t as_get_unmapped_area(as_t *as, uintptr_t bound,
-    size_t size, bool guarded)
+    size_t size)
 {
 	ASSERT(mutex_locked(&as->lock));
@@ -475,15 +423,7 @@
 	/* First check the bound address itself */
 	uintptr_t addr = ALIGN_UP(bound, PAGE_SIZE);
-	if (addr >= bound) {
-		if (guarded) {
-			/* Leave an unmapped page between the lower
-			 * bound and the area's start address.
-			 */
-			addr += P2SZ(1);
-		}
-
-		if (check_area_conflicts(as, addr, pages, guarded, NULL))
-			return addr;
-	}
+	if ((addr >= bound) &&
+	    (check_area_conflicts(as, addr, pages, NULL)))
+		return addr;
 	
 	/* Eventually check the addresses behind each area */
@@ -499,15 +439,7 @@
 			addr =
 			    ALIGN_UP(area->base + P2SZ(area->pages), PAGE_SIZE);
-
-			if (guarded || area->flags & AS_AREA_GUARD) {
-				/* We must leave an unmapped page
-				 * between the two areas.
-				 */
-				addr += P2SZ(1);
-			}
-
 			bool avail =
 			    ((addr >= bound) && (addr >= area->base) &&
-			    (check_area_conflicts(as, addr, pages, guarded, area)));
+			    (check_area_conflicts(as, addr, pages, area)));
 			
 			mutex_unlock(&area->lock);
@@ -549,5 +481,5 @@
 	if (size == 0)
 		return NULL;
-
+	
 	size_t pages = SIZE2FRAMES(size);
 	
@@ -555,11 +487,9 @@
 	if ((flags & AS_AREA_EXEC) && (flags & AS_AREA_WRITE))
 		return NULL;
-
-	bool const guarded = flags & AS_AREA_GUARD;
 	
 	mutex_lock(&as->lock);
 	
 	if (*base == (uintptr_t) -1) {
-		*base = as_get_unmapped_area(as, bound, size, guarded);
+		*base = as_get_unmapped_area(as, bound, size);
 		if (*base == (uintptr_t) -1) {
 			mutex_unlock(&as->lock);
@@ -567,9 +497,6 @@
 		}
 	}
-
-	if (overflows_into_positive(*base, size))
-		return NULL;
-
-	if (!check_area_conflicts(as, *base, pages, guarded, NULL)) {
+	
+	if (!check_area_conflicts(as, *base, pages, NULL)) {
 		mutex_unlock(&as->lock);
 		return NULL;
@@ -698,8 +625,9 @@
 		return ENOENT;
 	}
-
-	if (!area->backend->is_resizable(area)) {
+	
+	if (area->backend == &phys_backend) {
 		/*
-		 * The backend does not support resizing for this area.
+		 * Remapping of address space areas associated
+		 * with memory mapped devices is not supported.
 		 */
 		mutex_unlock(&area->lock);
@@ -848,14 +776,7 @@
 		/*
 		 * Growing the area.
-		 */
-
-		if (overflows_into_positive(address, P2SZ(pages)))
-			return EINVAL;
-
-		/*
 		 * Check for overlaps with other address space areas.
 		 */
-		bool const guarded = area->flags & AS_AREA_GUARD;
-		if (!check_area_conflicts(as, address, pages, guarded, area)) {
+		if (!check_area_conflicts(as, address, pages, area)) {
 			mutex_unlock(&area->lock);
 			mutex_unlock(&as->lock);
@@ -1058,7 +979,8 @@
 	}
 	
-	if (!src_area->backend->is_shareable(src_area)) {
+	if ((!src_area->backend) || (!src_area->backend->share)) {
 		/*
-		 * The backend does not permit sharing of this area.
+		 * There is no backend or the backend does not
+		 * know how to share the area.
 		 */
 		mutex_unlock(&src_area->lock);
@@ -1363,11 +1285,9 @@
 int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate)
 {
-	int rc = AS_PF_FAULT;
-
 	if (!THREAD)
-		goto page_fault;
+		return AS_PF_FAULT;
 	
 	if (!AS)
-		goto page_fault;
+		return AS_PF_FAULT;
 	
 	mutex_lock(&AS->lock);
@@ -1425,6 +1345,5 @@
 	 * Resort to the backend page fault handler.
 	 */
-	rc = area->backend->page_fault(area, page, access);
-	if (rc != AS_PF_OK) {
+	if (area->backend->page_fault(area, page, access) != AS_PF_OK) {
 		page_table_unlock(AS, false);
 		mutex_unlock(&area->lock);
@@ -1447,11 +1366,6 @@
 		istate_set_retaddr(istate,
 		    (uintptr_t) &memcpy_to_uspace_failover_address);
-	} else if (rc == AS_PF_SILENT) {
-		printf("Killing task %" PRIu64 " due to a "
-		    "failed late reservation request.\n", TASK->taskid);
-		task_kill_self(true);
 	} else {
-		fault_if_from_uspace(istate, "Page fault: %p.", (void *) page);
-		panic_memtrap(istate, access, page, NULL);
+		return AS_PF_FAULT;
 	}
 	
@@ -2140,5 +2054,5 @@
 {
 	uintptr_t virt = base;
-	as_area_t *area = as_area_create(AS, flags, size,
+	as_area_t *area = as_area_create(AS, flags | AS_AREA_CACHEABLE, size,
 	    AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, bound);
 	if (area == NULL)
Index: kernel/generic/src/mm/backend_anon.c
===================================================================
--- kernel/generic/src/mm/backend_anon.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/mm/backend_anon.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -59,7 +59,4 @@
 static void anon_destroy(as_area_t *);
 
-static bool anon_is_resizable(as_area_t *);
-static bool anon_is_shareable(as_area_t *);
-
 static int anon_page_fault(as_area_t *, uintptr_t, pf_access_t);
 static void anon_frame_free(as_area_t *, uintptr_t, uintptr_t);
@@ -71,7 +68,4 @@
 	.destroy = anon_destroy,
 
-	.is_resizable = anon_is_resizable,
-	.is_shareable = anon_is_shareable,
-
 	.page_fault = anon_page_fault,
 	.frame_free = anon_frame_free,
@@ -80,7 +74,4 @@
 bool anon_create(as_area_t *area)
 {
-	if (area->flags & AS_AREA_LATE_RESERVE)
-		return true;
-
 	return reserve_try_alloc(area->pages);
 }
@@ -88,7 +79,4 @@
 bool anon_resize(as_area_t *area, size_t new_pages)
 {
-	if (area->flags & AS_AREA_LATE_RESERVE)
-		return true;
-
 	if (new_pages > area->pages)
 		return reserve_try_alloc(new_pages - area->pages);
@@ -112,5 +100,4 @@
 	ASSERT(mutex_locked(&area->as->lock));
 	ASSERT(mutex_locked(&area->lock));
-	ASSERT(!(area->flags & AS_AREA_LATE_RESERVE));
 
 	/*
@@ -152,19 +139,7 @@
 void anon_destroy(as_area_t *area)
 {
-	if (area->flags & AS_AREA_LATE_RESERVE)
-		return;
-
 	reserve_free(area->pages);
 }
 
-bool anon_is_resizable(as_area_t *area)
-{
-	return true;
-}
-
-bool anon_is_shareable(as_area_t *area)
-{
-	return !(area->flags & AS_AREA_LATE_RESERVE);
-}
 
 /** Service a page fault in the anonymous memory address space area.
@@ -250,13 +225,4 @@
 		 *   the different causes
 		 */
-
-		if (area->flags & AS_AREA_LATE_RESERVE) {
-			/*
-			 * Reserve the memory for this page now.
-			 */
-			if (!reserve_try_alloc(1))
-				return AS_PF_SILENT;
-		}
-
 		kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE);
 		memsetb((void *) kpage, PAGE_SIZE, 0);
@@ -289,19 +255,5 @@
 	ASSERT(mutex_locked(&area->lock));
 
-	if (area->flags & AS_AREA_LATE_RESERVE) {
-		/*
-		 * In case of the late reserve areas, physical memory will not
-		 * be unreserved when the area is destroyed so we need to use
-		 * the normal unreserving frame_free().
-		 */
-		frame_free(frame);
-	} else {
-		/*
-		 * The reserve will be given back when the area is destroyed or
-		 * resized, so use the frame_free_noreserve() which does not
-		 * manipulate the reserve or it would be given back twice.
-		 */
-		frame_free_noreserve(frame);
-	}
+	frame_free_noreserve(frame);
 }
 
Index: kernel/generic/src/mm/backend_elf.c
===================================================================
--- kernel/generic/src/mm/backend_elf.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/mm/backend_elf.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -58,7 +58,4 @@
 static void elf_destroy(as_area_t *);
 
-static bool elf_is_resizable(as_area_t *);
-static bool elf_is_shareable(as_area_t *);
-
 static int elf_page_fault(as_area_t *, uintptr_t, pf_access_t);
 static void elf_frame_free(as_area_t *, uintptr_t, uintptr_t);
@@ -69,7 +66,4 @@
 	.share = elf_share,
 	.destroy = elf_destroy,
-
-	.is_resizable = elf_is_resizable,
-	.is_shareable = elf_is_shareable,
 
 	.page_fault = elf_page_fault,
@@ -219,15 +213,4 @@
 }
 
-bool elf_is_resizable(as_area_t *area)
-{
-	return true;
-}
-
-bool elf_is_shareable(as_area_t *area)
-{
-	return true;
-}
-
-
 /** Service a page fault in the ELF backend address space area.
  *
Index: kernel/generic/src/mm/backend_phys.c
===================================================================
--- kernel/generic/src/mm/backend_phys.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/mm/backend_phys.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -52,8 +52,4 @@
 static void phys_destroy(as_area_t *);
 
-static bool phys_is_resizable(as_area_t *);
-static bool phys_is_shareable(as_area_t *);
-
-
 static int phys_page_fault(as_area_t *, uintptr_t, pf_access_t);
 
@@ -63,7 +59,4 @@
 	.share = phys_share,
 	.destroy = phys_destroy,
-
-	.is_resizable = phys_is_resizable,
-	.is_shareable = phys_is_shareable,
 
 	.page_fault = phys_page_fault,
@@ -94,15 +87,4 @@
 	/* Nothing to do. */
 }
-
-bool phys_is_resizable(as_area_t *area)
-{
-	return false;
-}
-
-bool phys_is_shareable(as_area_t *area)
-{
-	return true;
-}
-
 
 /** Service a page fault in the address space area backed by physical memory.
Index: kernel/generic/src/mm/km.c
===================================================================
--- kernel/generic/src/mm/km.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/mm/km.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -233,6 +233,5 @@
  * @param[inout] framep	Pointer to a variable which will receive the physical
  *			address of the allocated frame.
- * @param[in] flags	Frame allocation flags. FRAME_NONE, FRAME_NO_RESERVE
- *			and FRAME_ATOMIC bits are allowed.
+ * @param[in] flags	Frame allocation flags. FRAME_NONE or FRAME_NO_RESERVE.
  * @return		Virtual address of the allocated frame.
  */
@@ -244,5 +243,5 @@
 	ASSERT(THREAD);
 	ASSERT(framep);
-	ASSERT(!(flags & ~(FRAME_NO_RESERVE | FRAME_ATOMIC)));
+	ASSERT(!(flags & ~FRAME_NO_RESERVE));
 
 	/*
@@ -256,8 +255,6 @@
 		ASSERT(page);	// FIXME
 	} else {
-		frame = (uintptr_t) frame_alloc(ONE_FRAME,
-		    FRAME_LOWMEM | flags);
-		if (!frame)
-			return (uintptr_t) NULL;
+		frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME,
+		    FRAME_LOWMEM);
 		page = PA2KA(frame);
 	}
Index: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/proc/program.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -79,14 +79,8 @@
 	 * Create the stack address space area.
 	 */
-	uintptr_t virt = (uintptr_t) -1;
-	uintptr_t bound = USER_ADDRESS_SPACE_END - (STACK_SIZE_USER - 1);
-
-	/* Adjust bound to create space for the desired guard page. */
-	bound -= PAGE_SIZE;
-
+	uintptr_t virt = USTACK_ADDRESS;
 	as_area_t *area = as_area_create(as,
-	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
-	    AS_AREA_LATE_RESERVE, STACK_SIZE_USER, AS_AREA_ATTR_NONE,
-	    &anon_backend, NULL, &virt, bound);
+	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
+	    STACK_SIZE, AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, 0);
 	if (!area) {
 		task_destroy(prg->task);
@@ -99,5 +93,5 @@
 	kernel_uarg->uspace_entry = (void *) entry_addr;
 	kernel_uarg->uspace_stack = (void *) virt;
-	kernel_uarg->uspace_stack_size = STACK_SIZE_USER;
+	kernel_uarg->uspace_stack_size = STACK_SIZE;
 	kernel_uarg->uspace_thread_function = NULL;
 	kernel_uarg->uspace_thread_arg = NULL;
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/proc/scheduler.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -92,5 +92,5 @@
 	else
 		fpu_disable();
-#elif defined CONFIG_FPU
+#else
 	fpu_enable();
 	if (THREAD->fpu_context_exists)
@@ -327,5 +327,5 @@
 		THREAD->kcycles += get_cycle() - THREAD->last_cycle;
 		
-#if (defined CONFIG_FPU) && (!defined CONFIG_FPU_LAZY)
+#ifndef CONFIG_FPU_LAZY
 		fpu_context_save(THREAD->saved_fpu_context);
 #endif
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ kernel/generic/src/proc/task.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -125,14 +125,4 @@
 {
 	size_t tasks_left;
-
-	if (ipc_phone_0) {
-		task_t *task_0 = ipc_phone_0->task;
-		ipc_phone_0 = NULL;
-		/*
-		 * The first task is held by kinit(), we need to release it or
-		 * it will never finish cleanup.
-		 */
-		task_release(task_0);
-	}
 	
 	/* Repeat until there are any tasks except TASK */
@@ -206,5 +196,5 @@
 	task->ucycles = 0;
 	task->kcycles = 0;
-
+	
 	task->ipc_info.call_sent = 0;
 	task->ipc_info.call_received = 0;
Index: release/Makefile
===================================================================
--- release/Makefile	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ release/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -32,5 +32,5 @@
 SRC_ARCHIVE = HelenOS-$(RELEASE).tar.bz2
 
-PROFILES = amd64 arm32/integratorcp arm32/gta02 arm32/beagleboardxm ia32 \
+PROFILES = amd64 arm32/GXemul arm32/integratorcp arm32/gta02 ia32 \
     ia64/i460GX ia64/ski mips32/GXemul mips32/msim ppc32 \
     sparc64/ultra
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ tools/autotool.py	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -563,5 +563,4 @@
 	outmk.write('#########################################\n')
 	outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
-	outmk.write('## Generated by: tools/autotool.py     ##\n')
 	outmk.write('#########################################\n\n')
 	
@@ -581,5 +580,4 @@
 	outhd.write('/***************************************\n')
 	outhd.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
-	outhd.write(' * Generated by: tools/autotool.py     *\n')
 	outhd.write(' ***************************************/\n\n')
 	
Index: tools/config.py
===================================================================
--- tools/config.py	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ tools/config.py	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -388,10 +388,8 @@
 	outmk.write('#########################################\n')
 	outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
-	outmk.write('## Generated by: tools/config.py       ##\n')
 	outmk.write('#########################################\n\n')
 	
 	outmc.write('/***************************************\n')
 	outmc.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
-	outmc.write(' * Generated by: tools/config.py       *\n')
 	outmc.write(' ***************************************/\n\n')
 	
Index: ols/ew.py
===================================================================
--- tools/ew.py	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,166 +1,0 @@
-#!/usr/bin/env python
-#
-# 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.
-#
-
-
-"""
-Emulator wrapper for running HelenOS
-"""
-
-import os 
-import subprocess 
-import autotool
-
-def run_in_console(cmd, title):
-	cmdline = 'xterm -T ' + '"' + title + '"' + ' -e ' + cmd
-	print cmdline
-	subprocess.call(cmdline, shell = True);
-
-def pc_options():
-	return '-enable-kvm'
-
-def malta_options():
-	return '-cpu 4Kc'
-
-def platform_to_qemu_options(platform, machine):
-	if platform == 'amd64':
-		return 'system-x86_64', pc_options()
-	elif platform == 'arm32':
-		return 'system-arm', ''
-	elif platform == 'ia32':
-		return 'system-i386', pc_options()
-	elif platform == 'mips32':
-		if machine == 'lmalta':
-			return 'system-mipsel', malta_options()
-		elif machine == 'bmalta':
-			return 'system-mips', malta_options()
-	elif platform == 'ppc32':
-		return 'system-ppc', ''
-	elif platform == 'sparc64':
-		return 'system-sparc64', ''
-
-def qemu_bd_options():
-	if not os.path.exists('hdisk.img'):
-		subprocess.call('tools/mkfat.py 1048576 uspace/dist/data hdisk.img', shell = True)
-	return ' -hda hdisk.img'
-
-def qemu_nic_ne2k_options():
-	return ' -device ne2k_isa,irq=5,vlan=0'
-
-def qemu_nic_e1k_options():
-	return ' -device e1000,vlan=0'
-
-def qemu_nic_rtl8139_options():
-	return ' -device rtl8139,vlan=0'
-
-def qemu_net_options():
-	nic_options = qemu_nic_e1k_options()
-	return nic_options + ' -net user -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081'
-
-def qemu_usb_options():
-	return ''
-
-def qemu_run(platform, machine, console, image, networking, storage, usb):
-	suffix, options = platform_to_qemu_options(platform, machine)
-	cmd = 'qemu-' + suffix
-
-	cmdline = cmd
-	if options != '':
-		cmdline += ' ' + options
-
-	if storage:
-		cmdline += qemu_bd_options()
-	if networking:
-		cmdline += qemu_net_options()
-	if usb:
-		cmdline += qemu_usb_options()
-	
-	if image == 'image.iso':
-		cmdline += ' -boot d -cdrom image.iso'
-	elif image == 'image.boot':
-		cmdline += ' -kernel image.boot'
-
-	if not console:
-		cmdline += ' -nographic'
-
-		title = 'HelenOS/' + platform
-		if machine != '':
-			title += ' on ' + machine
-		run_in_console(cmdline, title)
-	else:
-		print cmdline
-		subprocess.call(cmdline, shell = True)
-		
-def ski_run(platform, machine, console, image, networking, storage, usb):
-	run_in_console('ski -i contrib/conf/ski.conf', 'HelenOS/ia64 on ski')
-
-def msim_run(platform, machine, console, image, networking, storage, usb):
-	run_in_console('msim -c contrib/conf/msim.conf', 'HelenOS/mips32 on msim')
-
-emulators = {}
-emulators['amd64'] = {}
-emulators['arm32'] = {}
-emulators['ia32'] = {}
-emulators['ia64'] = {}
-emulators['mips32'] = {}
-emulators['ppc32'] = {}
-emulators['sparc64'] = {}
-
-emulators['amd64'][''] = qemu_run, True, 'image.iso', True, True, True
-emulators['arm32']['integratorcp'] = qemu_run, True, 'image.boot', False, False, False
-emulators['ia32'][''] = qemu_run, True, 'image.iso', True, True, True
-emulators['ia64']['ski'] = ski_run, False, 'image.boot', False, False, False
-emulators['mips32']['msim'] = msim_run, False, 'image.boot', False, False, False
-emulators['mips32']['lmalta'] = qemu_run, False, 'image.boot', False, False, False
-emulators['mips32']['bmalta'] = qemu_run, False, 'image.boot', False, False, False
-emulators['ppc32'][''] = qemu_run, True, 'image.iso', True, True, True
-emulators['sparc64']['generic'] = qemu_run, True, 'image.iso', True, True, True
-
-def run():
-	config = {}
-	autotool.read_config(autotool.CONFIG, config)
-
-	try:
-		platform = config['PLATFORM']
-	except:
-		platform = ''
-
-	try:
-		mach = config['MACHINE']
-	except:
-		mach = ''
-
-	try:
-		emu_run, console, image, networking, storage, usb = emulators[platform][mach]
-	except:
-		print "Cannot start emulation for the chosen configuration."
-		return
-
-	emu_run(platform, mach, console, image, networking, storage, usb)
-
-run()
Index: tools/mkarray.py
===================================================================
--- tools/mkarray.py	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ tools/mkarray.py	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -95,5 +95,4 @@
 	header.write('/***************************************\n')
 	header.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
-	header.write(' * Generated by: tools/mkarray.py      *\n')
 	header.write(' ***************************************/\n\n')
 	header.write("#ifndef %s_H_\n" % label)
@@ -110,5 +109,4 @@
 	data.write('/***************************************\n')
 	data.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
-	data.write(' * Generated by: tools/mkarray.py      *\n')
 	data.write(' ***************************************/\n\n')
 	data.write("#include \"%s.h\"\n\n" % dest)
Index: tools/mkuimage.py
===================================================================
--- tools/mkuimage.py	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ tools/mkuimage.py	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -60,5 +60,4 @@
 	load_addr = 0
 	start_addr = 0
-	os_type = 5 #Linux is the default
 
 	while len(args) >= 2 and args[0][0] == '-':
@@ -72,6 +71,4 @@
 		elif opt == 'saddr':
 			start_addr = (int)(optarg, 0)
-		elif opt == 'ostype':
-			os_type = (int)(optarg, 0)
 		else:
 			print(base_name + ": Unrecognized option.")
@@ -88,10 +85,10 @@
 
 	try:
-		mkuimage(inf_name, outf_name, image_name, load_addr, start_addr, os_type)
+		mkuimage(inf_name, outf_name, image_name, load_addr, start_addr)
 	except:
 		os.remove(outf_name)
 		raise
 
-def mkuimage(inf_name, outf_name, image_name, load_addr, start_addr, os_type):
+def mkuimage(inf_name, outf_name, image_name, load_addr, start_addr):
 	inf = open(inf_name, 'rb')
 	outf = open(outf_name, 'wb')
@@ -123,5 +120,5 @@
 	header.start_addr = start_addr	# Address of entry point
 	header.data_crc = data_crc
-	header.os = os_type
+	header.os = 5			# Linux
 	header.arch = 2			# ARM
 	header.img_type = 2		# Kernel
Index: tools/pack.py
===================================================================
--- tools/pack.py	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ tools/pack.py	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -155,5 +155,4 @@
 	header.write('/***************************************\n')
 	header.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
-	header.write(' * Generated by: tools/pack.py         *\n')
 	header.write(' ***************************************/\n\n')
 	header.write("#ifndef BOOT_COMPONENTS_H_\n")
@@ -178,5 +177,4 @@
 	data.write('/***************************************\n')
 	data.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
-	data.write(' * Generated by: tools/pack.py         *\n')
 	data.write(' ***************************************/\n\n')
 	data.write("#include <typedefs.h>\n")
Index: tools/toolchain.sh
===================================================================
--- tools/toolchain.sh	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ tools/toolchain.sh	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -53,5 +53,5 @@
 EOF
 
-BINUTILS_VERSION="2.23.1"
+BINUTILS_VERSION="2.22"
 BINUTILS_RELEASE=""
 GCC_VERSION="4.7.2"
@@ -274,5 +274,5 @@
 	GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/"
 	
-	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "33adb18c3048d057ac58d07a3f1adb38"
+	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "ee0f10756c84979622b992a4a61ea3f5"
 	download_fetch "${GCC_SOURCE}" "${GCC}" "cc308a0891e778cfda7a151ab8a6e762"
 	download_fetch "${GDB_SOURCE}" "${GDB}" "24a6779a9fe0260667710de1b082ef61"
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,4 +40,5 @@
 	app/devctl \
 	app/edit \
+	app/ext2info \
 	app/getterm \
 	app/init \
@@ -104,4 +105,5 @@
 	srv/fs/mfs \
 	srv/fs/locfs \
+	srv/fs/ext2fs \
 	srv/fs/ext4fs \
 	srv/hid/compositor \
@@ -192,10 +194,4 @@
 endif
 
-ifeq ($(UARCH),arm32)
-	DIRS += \
-		drv/infrastructure/rootamdm37x \
-		drv/fb/amdm37x_dispc
-endif
-
 ## System libraries
 #
@@ -217,4 +213,5 @@
 	lib/net \
 	lib/nic \
+	lib/ext2 \
 	lib/ext4 \
 	lib/usb \
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/Makefile.common	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -122,4 +122,5 @@
 LIBGUI_PREFIX = $(LIB_PREFIX)/gui
 
+LIBEXT2_PREFIX = $(LIB_PREFIX)/ext2
 LIBEXT4_PREFIX = $(LIB_PREFIX)/ext4
 
Index: uspace/app/bdsh/compl.c
===================================================================
--- uspace/app/bdsh/compl.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/bdsh/compl.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -28,5 +28,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <dirent.h>
 #include <errno.h>
Index: uspace/app/bdsh/input.c
===================================================================
--- uspace/app/bdsh/input.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/bdsh/input.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 #include <errno.h>
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <tinput.h>
 
Index: uspace/app/edit/edit.c
===================================================================
--- uspace/app/edit/edit.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/edit/edit.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -47,5 +47,5 @@
 #include <macros.h>
 #include <clipboard.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include "sheet.h"
Index: uspace/app/edit/sheet.h
===================================================================
--- uspace/app/edit/sheet.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/edit/sheet.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <adt/list.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 /** Direction (in linear space) */
Index: uspace/app/ext2info/Makefile
===================================================================
--- uspace/app/ext2info/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/app/ext2info/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 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.
+#
+
+USPACE_PREFIX = ../..
+LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBEXT2_PREFIX)/libext2.a
+EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBEXT2_PREFIX)
+BINARY = ext2info
+
+SOURCES = \
+	ext2info.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/ext2info/ext2info.c
===================================================================
--- uspace/app/ext2info/ext2info.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/app/ext2info/ext2info.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,624 @@
+/*
+ * Copyright (c) 2011 Martin Sucha
+ * 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 fs
+ * @{
+ */
+
+/**
+ * @file	ext2info.c
+ * @brief	Tool for displaying information about ext2 filesystem
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <block.h>
+#include <mem.h>
+#include <loc.h>
+#include <byteorder.h>
+#include <sys/types.h>
+#include <sys/typefmt.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <libext2.h>
+#include <assert.h>
+
+#define NAME	"ext2info"
+
+static void syntax_print(void);
+static void print_superblock(ext2_superblock_t *);
+static void print_block_groups(ext2_filesystem_t *);
+static void print_block_group(ext2_block_group_t *);
+static void print_inode_by_number(ext2_filesystem_t *, uint32_t, bool, uint32_t,
+    bool, bool);
+static void print_data(unsigned char *, size_t);
+static void print_inode(ext2_filesystem_t *, ext2_inode_t *, bool);
+static void print_inode_data(ext2_filesystem_t *, ext2_inode_t *, uint32_t);
+static void print_directory_contents(ext2_filesystem_t *, ext2_inode_ref_t *);
+
+#define ARG_SUPERBLOCK 1
+#define ARG_BLOCK_GROUPS 2
+#define ARG_INODE 4
+#define ARG_NO_CHECK 8
+#define ARG_INODE_DATA 16
+#define ARG_INODE_LIST 32
+#define ARG_INODE_BLOCKS 64
+#define ARG_COMMON (ARG_SUPERBLOCK)
+#define ARG_ALL 127
+
+
+int main(int argc, char **argv)
+{
+
+	int rc;
+	char *endptr;
+	char *dev_path;
+	service_id_t service_id;
+	ext2_filesystem_t filesystem;
+	int arg_flags;
+	uint32_t inode = 0;
+	uint32_t inode_data = 0;
+	
+	arg_flags = 0;
+	
+	if (argc < 2) {
+		printf(NAME ": Error, argument missing.\n");
+		syntax_print();
+		return 1;
+	}
+	
+	/* Skip program name */
+	--argc; ++argv;
+	
+	if (argc > 0 && str_cmp(*argv, "--no-check") == 0) {
+		--argc; ++argv;
+		arg_flags |= ARG_NO_CHECK;
+	}
+	
+	if (argc > 0 && str_cmp(*argv, "--superblock") == 0) {
+		--argc; ++argv;
+		arg_flags |= ARG_SUPERBLOCK;
+	}
+	
+	if (argc > 0 && str_cmp(*argv, "--block-groups") == 0) {
+		--argc; ++argv;
+		arg_flags |= ARG_BLOCK_GROUPS;
+	}
+	
+	if (argc > 0 && str_cmp(*argv, "--inode") == 0) {
+		--argc; ++argv;
+		if (argc == 0) {
+			printf(NAME ": Argument expected for --inode\n");
+			return 2;
+		}
+		
+		inode = strtol(*argv, &endptr, 10);
+		if (*endptr != '\0') {
+			printf(NAME ": Error, invalid argument for --inode.\n");
+			syntax_print();
+			return 1;
+		}
+		
+		arg_flags |= ARG_INODE;
+		--argc; ++argv;
+		
+		if (argc > 0 && str_cmp(*argv, "--blocks") == 0) {
+			--argc; ++argv;
+			arg_flags |= ARG_INODE_BLOCKS;
+		}
+		
+		if (argc > 0 && str_cmp(*argv, "--data") == 0) {
+			--argc; ++argv;
+			if (argc == 0) {
+				printf(NAME ": Argument expected for --data\n");
+				return 2;
+			}
+			
+			inode_data = strtol(*argv, &endptr, 10);
+			if (*endptr != '\0') {
+				printf(NAME ": Error, invalid argument for --data.\n");
+				syntax_print();
+				return 1;
+			}
+			
+			arg_flags |= ARG_INODE_DATA;
+			--argc; ++argv;
+		}
+		
+		if (argc > 0 && str_cmp(*argv, "--list") == 0) {
+			--argc; ++argv;
+			arg_flags |= ARG_INODE_LIST;
+		}
+	}
+
+	if (argc < 1) {
+		printf(NAME ": Error, argument missing.\n");
+		syntax_print();
+		return 1;
+	}
+	else if (argc > 1) {
+		printf(NAME ": Error, unexpected argument.\n");
+		syntax_print();
+		return 1;
+	}
+	assert(argc == 1);
+	
+	/* Display common things by default */
+	if ((arg_flags & ARG_ALL) == 0) {
+		arg_flags = ARG_COMMON;
+	}
+
+	dev_path = *argv;
+
+	rc = loc_service_get_id(dev_path, &service_id, 0);
+	if (rc != EOK) {
+		printf(NAME ": Error resolving device `%s'.\n", dev_path);
+		return 2;
+	}
+
+	rc = ext2_filesystem_init(&filesystem, service_id);
+	if (rc != EOK)  {
+		printf(NAME ": Error initializing libext2.\n");
+		return 3;
+	}
+	
+	rc = ext2_filesystem_check_sanity(&filesystem);
+	if (rc != EOK) {
+		printf(NAME ": Filesystem did not pass sanity check.\n");
+		if (!(arg_flags & ARG_NO_CHECK)) {
+			return 3;
+		}
+	}
+	
+	if (arg_flags & ARG_SUPERBLOCK) {
+		print_superblock(filesystem.superblock);
+	}
+	
+	if (arg_flags & ARG_BLOCK_GROUPS) {
+		print_block_groups(&filesystem);
+	}
+	
+	if (arg_flags & ARG_INODE) {
+		print_inode_by_number(&filesystem, inode, arg_flags & ARG_INODE_DATA,
+		    inode_data, arg_flags & ARG_INODE_LIST,
+		    arg_flags & ARG_INODE_BLOCKS);
+	}
+
+	ext2_filesystem_fini(&filesystem);
+
+	return 0;
+}
+
+
+static void syntax_print(void)
+{
+	printf("syntax: ext2info [--no-check] [--superblock] [--block-groups] "
+	    "[--inode <i-number> [--blocks] [--data <block-number>] [--list]] "
+	    "<device_name>\n");
+}
+
+static void print_superblock(ext2_superblock_t *superblock)
+{
+	uint16_t magic;
+	uint32_t first_block;
+	uint32_t block_size;
+	uint32_t fragment_size;
+	uint32_t blocks_per_group;
+	uint32_t fragments_per_group;
+	uint32_t rev_major;
+	uint16_t rev_minor;
+	uint16_t state;
+	uint32_t first_inode;
+	uint16_t inode_size;
+	uint32_t total_blocks;
+	uint32_t reserved_blocks;
+	uint32_t free_blocks;
+	uint32_t total_inodes;
+	uint32_t free_inodes;	
+	uint32_t os;
+	
+	int pos;
+	unsigned char c;
+	
+	magic = ext2_superblock_get_magic(superblock);
+	first_block = ext2_superblock_get_first_block(superblock);
+	block_size = ext2_superblock_get_block_size(superblock);
+	fragment_size = ext2_superblock_get_fragment_size(superblock);
+	blocks_per_group = ext2_superblock_get_blocks_per_group(superblock);
+	fragments_per_group = ext2_superblock_get_fragments_per_group(superblock);
+	rev_major = ext2_superblock_get_rev_major(superblock);
+	rev_minor = ext2_superblock_get_rev_minor(superblock);
+	state = ext2_superblock_get_state(superblock);
+	first_inode = ext2_superblock_get_first_inode(superblock);
+	inode_size = ext2_superblock_get_inode_size(superblock);
+	total_blocks = ext2_superblock_get_total_block_count(superblock);
+	reserved_blocks = ext2_superblock_get_reserved_block_count(superblock);
+	free_blocks = ext2_superblock_get_free_block_count(superblock);
+	total_inodes = ext2_superblock_get_total_inode_count(superblock);
+	free_inodes = ext2_superblock_get_free_inode_count(superblock);
+	os = ext2_superblock_get_os(superblock);
+	
+	printf("Superblock:\n");
+	
+	if (magic == EXT2_SUPERBLOCK_MAGIC) {
+		printf("  Magic value: %X (correct)\n", magic);
+	}
+	else {
+		printf("  Magic value: %X (incorrect)\n", magic);
+	}
+	
+	printf("  Revision: %u.%hu\n", rev_major, rev_minor);
+	printf("  State: %hu\n", state);
+	printf("  Creator OS: %u\n", os);
+	printf("  First block: %u\n", first_block);
+	printf("  Block size: %u bytes (%u KiB)\n", block_size, block_size/1024);
+	printf("  Blocks per group: %u\n", blocks_per_group);
+	printf("  Total blocks: %u\n", total_blocks);
+	printf("  Reserved blocks: %u\n", reserved_blocks);
+	printf("  Free blocks: %u\n", free_blocks);
+	printf("  Fragment size: %u bytes (%u KiB)\n", fragment_size,
+	    fragment_size/1024);
+	printf("  Fragments per group: %u\n", fragments_per_group);
+	printf("  First inode: %u\n", first_inode);
+	printf("  Inode size: %hu bytes\n", inode_size);
+	printf("  Total inodes: %u\n", total_inodes);
+	printf("  Free inodes: %u\n", free_inodes);
+	
+	
+	if (rev_major == 1) {
+		printf("  UUID: ");
+		for (pos = 0; pos < 16; pos++) {
+			printf("%02x", superblock->uuid[pos]);
+		}
+		printf("\n");
+		
+		printf("  Volume label: ");
+		for (pos = 0; pos < 16; pos++) {
+			c = superblock->volume_name[pos];
+			if (c >= 32 && c < 128) {
+				putchar(c);
+			}
+			else {
+				putchar(' ');
+			}
+		}
+		printf("\n");
+	}
+	
+}
+
+void print_block_groups(ext2_filesystem_t *filesystem)
+{
+	uint32_t block_group_count;
+	uint32_t i;
+	ext2_block_group_ref_t *block_group_ref;
+	int rc;
+	
+	printf("Block groups:\n");
+	
+	block_group_count = ext2_superblock_get_block_group_count(
+	    filesystem->superblock);
+	
+	for (i = 0; i < block_group_count; i++) {
+		printf("  Block group %u\n", i);
+		rc = ext2_filesystem_get_block_group_ref(filesystem, i, &block_group_ref);
+		if (rc != EOK) {
+			printf("    Failed reading block group\n");
+			continue;
+		}
+		
+		print_block_group(block_group_ref->block_group);
+		
+		rc = ext2_filesystem_put_block_group_ref(block_group_ref);
+		if (rc != EOK) {
+			printf("    Failed freeing block group\n");
+		}
+	}
+	
+}
+
+void print_block_group(ext2_block_group_t *bg)
+{
+	uint32_t block_bitmap_block;
+	uint32_t inode_bitmap_block;
+	uint32_t inode_table_first_block;
+	uint16_t free_block_count;
+	uint16_t free_inode_count;
+	uint16_t directory_inode_count;
+	
+	block_bitmap_block = ext2_block_group_get_block_bitmap_block(bg);
+	inode_bitmap_block = ext2_block_group_get_inode_bitmap_block(bg);
+	inode_table_first_block = ext2_block_group_get_inode_table_first_block(bg);
+	free_block_count = ext2_block_group_get_free_block_count(bg);
+	free_inode_count = ext2_block_group_get_free_inode_count(bg);
+	directory_inode_count = ext2_block_group_get_directory_inode_count(bg);
+	
+	printf("    Block bitmap block: %u\n", block_bitmap_block);
+	printf("    Inode bitmap block: %u\n", inode_bitmap_block);
+	printf("    Inode table's first block: %u\n", inode_table_first_block);
+	printf("    Free blocks: %u\n", free_block_count);
+	printf("    Free inodes: %u\n", free_inode_count);
+	printf("    Directory inodes: %u\n", directory_inode_count);
+}
+
+void print_inode_by_number(ext2_filesystem_t *fs, uint32_t inode, 
+    bool print_data, uint32_t data, bool list, bool blocks)
+{
+	int rc;
+	ext2_inode_ref_t *inode_ref;
+	
+	printf("Inode %u\n", inode);
+	
+	rc = ext2_filesystem_get_inode_ref(fs, inode, &inode_ref);
+	if (rc != EOK) {
+		printf("  Failed getting inode ref\n");
+		return;
+	}
+	
+	print_inode(fs, inode_ref->inode, blocks);
+	if (print_data) {
+		print_inode_data(fs, inode_ref->inode, data);
+	}
+	
+	if (list && ext2_inode_is_type(fs->superblock, inode_ref->inode,
+	    EXT2_INODE_MODE_DIRECTORY)) {
+		print_directory_contents(fs, inode_ref);
+	}
+	
+	rc = ext2_filesystem_put_inode_ref(inode_ref);
+	if (rc != EOK) {
+		printf("  Failed putting inode ref\n");
+	}
+}
+
+void print_inode(ext2_filesystem_t *fs, ext2_inode_t *inode, bool blocks)
+{
+	uint32_t mode;
+	uint32_t mode_type;
+	uint32_t user_id;
+	uint32_t group_id;
+	uint64_t size;
+	uint16_t usage_count;
+	uint32_t flags;
+	uint16_t access;
+	const char *type;
+	uint32_t total_blocks;
+	uint32_t i;
+	uint32_t range_start;
+	uint32_t range_last;
+	uint32_t range_start_file;
+	uint32_t range_last_file;
+	uint32_t range_current;
+	uint32_t range_expected;
+	uint32_t block_size;
+	uint64_t file_blocks;
+	bool printed_range;
+	int rc;
+	
+	block_size = ext2_superblock_get_block_size(fs->superblock);
+	mode = ext2_inode_get_mode(fs->superblock, inode);
+	mode_type = mode & EXT2_INODE_MODE_TYPE_MASK;
+	user_id = ext2_inode_get_user_id(fs->superblock, inode);
+	group_id = ext2_inode_get_group_id(fs->superblock, inode);
+	size = ext2_inode_get_size(fs->superblock, inode);
+	usage_count = ext2_inode_get_usage_count(inode);
+	flags = ext2_inode_get_flags(inode);
+	total_blocks = ext2_inode_get_reserved_blocks(fs->superblock, inode);
+	file_blocks = 0;
+	if (size > 0) {
+		file_blocks = ((size-1)/block_size)+1;
+	}
+	
+	type = "Unknown";
+	if (mode_type == EXT2_INODE_MODE_BLOCKDEV) {
+		type = "Block device";
+	}
+	else if (mode_type == EXT2_INODE_MODE_FIFO) {
+		type = "Fifo (pipe)";
+	}
+	else if (mode_type == EXT2_INODE_MODE_CHARDEV) {
+		type = "Character device";
+	}
+	else if (mode_type == EXT2_INODE_MODE_DIRECTORY) {
+		type = "Directory";
+	}
+	else if (mode_type == EXT2_INODE_MODE_FILE) {
+		type = "File";
+	}
+	else if (mode_type == EXT2_INODE_MODE_SOFTLINK) {
+		type = "Soft link";
+	}
+	else if (mode_type == EXT2_INODE_MODE_SOCKET) {
+		type = "Socket";
+	}
+	
+	access = mode & EXT2_INODE_MODE_ACCESS_MASK;
+	
+	
+	printf("  Mode: %08x (Type: %s, Access bits: %04ho)\n", mode, type, access);
+	printf("  User ID: %u\n", user_id);
+	printf("  Group ID: %u\n", group_id);
+	printf("  Size: %" PRIu64 "\n", size);
+	printf("  Usage (link) count: %u\n", usage_count);
+	printf("  Flags: %u\n", flags);
+	printf("  Total allocated blocks: %u\n", total_blocks);
+	
+	if (blocks) {
+		printf("  Block list: ");
+		
+		range_start = 0;
+		range_current = 0;
+		range_last = 0;
+		
+		printed_range = false;
+		
+		for (i = 0; i <= file_blocks; i++) {
+			if (i < file_blocks) {
+				rc = ext2_filesystem_get_inode_data_block_index(fs, inode, i, &range_current);
+				if (rc != EOK) {
+					printf("Error reading data block indexes\n");
+					return;
+				}
+			}
+			if (range_last == 0) {
+				range_expected = 0;
+			}
+			else {
+				range_expected = range_last + 1;
+			}
+			if (range_current != range_expected) {
+				if (i > 0) {
+					if (printed_range) {
+						printf(", ");
+					}
+					if (range_start == 0 && range_last == 0) {
+						if (range_start_file == range_last_file) {
+							printf("%u N/A", range_start_file);
+						}
+						else {
+							printf("[%u, %u] N/A", range_start_file,
+								range_last_file);
+						}
+					}
+					else {
+						if (range_start_file == range_last_file) {
+							printf("%u -> %u", range_start_file, range_start);
+						}
+						else {
+							printf("[%u, %u] -> [%u, %u]", range_start_file,
+								range_last_file, range_start, range_last);
+						}
+					}
+					printed_range = true;
+				}
+				range_start = range_current;
+				range_start_file = i;
+			}
+			range_last = range_current;
+			range_last_file = i;
+		}
+		printf("\n");
+	}
+}
+
+void print_data(unsigned char *data, size_t size)
+{
+	unsigned char c;
+	size_t i;
+	
+	for (i = 0; i < size; i++) {
+		c = data[i];
+		if (c >= 32 && c < 127) {
+			putchar(c);
+		}
+		else {
+			putchar('.');
+		}
+	}
+}
+
+void print_inode_data(ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t data)
+{
+	int rc;
+	uint32_t data_block_index;
+	block_t *block;
+	
+	rc = ext2_filesystem_get_inode_data_block_index(fs, inode, data,
+	    &data_block_index);
+	
+	if (rc != EOK) {
+		printf("Failed getting data block #%u\n", data);
+		return;
+	}
+	
+	printf("Data for inode contents block #%u is located in filesystem "
+	    "block %u\n", data, data_block_index);
+	
+	printf("Data preview (only printable characters):\n");
+	
+	rc = block_get(&block, fs->device, data_block_index, 0);
+	if (rc != EOK) {
+		printf("Failed reading filesystem block %u\n", data_block_index);
+		return;
+	}
+	
+	print_data(block->data, block->size);
+	printf("\n");	
+	
+	rc = block_put(block);
+	if (rc != EOK) {
+		printf("Failed putting filesystem block\n");
+	}
+	
+}
+
+void print_directory_contents(ext2_filesystem_t *fs,
+    ext2_inode_ref_t *inode_ref)
+{
+	int rc;
+	ext2_directory_iterator_t it;
+	size_t name_size;
+	uint32_t inode;
+	
+	printf("  Directory contents:\n");
+	
+	rc = ext2_directory_iterator_init(&it, fs, inode_ref, 0);
+	if (rc != EOK) {
+		printf("Failed initializing directory iterator\n");
+		return;
+	}
+	
+	while (it.current != NULL) {
+		name_size = ext2_directory_entry_ll_get_name_length(fs->superblock,
+		    it.current);
+		printf("    ");
+		print_data(&it.current->name, name_size);
+		
+		inode = ext2_directory_entry_ll_get_inode(it.current);
+		printf(" --> %u\n", inode);
+		
+		rc = ext2_directory_iterator_next(&it);
+		if (rc != EOK) {
+			printf("Failed reading directory contents\n");
+			goto cleanup;
+		}
+	}
+
+cleanup:
+	rc = ext2_directory_iterator_fini(&it);
+	if (rc != EOK) {
+		printf("Failed cleaning-up directory iterator\n");
+	}
+	
+}
+
+/**
+ * @}
+ */
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/init/init.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <stdarg.h>
 #include <vfs/vfs.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <fcntl.h>
Index: uspace/app/klog/Makefile
===================================================================
--- uspace/app/klog/Makefile	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/klog/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -29,6 +29,4 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBCLUI_PREFIX)/libclui.a
-EXTRA_CFLAGS = -I$(LIBCLUI_PREFIX)
 BINARY = klog
 
Index: uspace/app/klog/klog.c
===================================================================
--- uspace/app/klog/klog.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/klog/klog.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -48,5 +48,4 @@
 #include <adt/list.h>
 #include <adt/prodcons.h>
-#include <tinput.h>
 
 #define NAME       "klog"
@@ -229,31 +228,12 @@
 	}
 	
-	tinput_t *input = tinput_new();
-	if (!input) {
-		fprintf(stderr, "%s: Could not create input\n", NAME);
-		return ENOMEM;
-	}	
-
 	fibril_add_ready(fid);
 	event_unmask(EVENT_KLOG);
 	klog_update();
 	
-	tinput_set_prompt(input, "klog> ");
-
-	char *str;
-	while ((rc = tinput_read(input, &str)) == EOK) {
-		if (str_cmp(str, "") == 0) {
-			free(str);
-			continue;
-		}
-
-		klog_command(str, str_size(str));
-		free(str);
-	}
- 
-	if (rc == ENOENT)
-		rc = EOK;	
-
-	return EOK;
+	task_retval(0);
+	async_manager();
+	
+	return 0;
 }
 
Index: uspace/app/mkbd/main.c
===================================================================
--- uspace/app/mkbd/main.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/mkbd/main.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <errno.h>
 #include <str_error.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <getopt.h>
 #include <devman.h>
Index: uspace/app/mkexfat/exfat.h
===================================================================
--- uspace/app/mkexfat/exfat.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/mkexfat/exfat.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
 #include <sys/types.h>
 #include <stdint.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #define EXFAT_FILENAME_LEN	255
Index: uspace/app/mkexfat/mkexfat.c
===================================================================
--- uspace/app/mkexfat/mkexfat.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/mkexfat/mkexfat.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -46,5 +46,5 @@
 #include <sys/types.h>
 #include <sys/typefmt.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <str.h>
 #include <getopt.h>
Index: uspace/app/nettest2/nettest2.c
===================================================================
--- uspace/app/nettest2/nettest2.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/nettest2/nettest2.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -45,5 +45,5 @@
 #include <time.h>
 #include <arg_parse.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <net/in.h>
Index: uspace/app/nterm/conn.c
===================================================================
--- uspace/app/nterm/conn.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/nterm/conn.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,5 +33,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <fibril.h>
Index: uspace/app/nterm/nterm.c
===================================================================
--- uspace/app/nterm/nterm.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/nterm/nterm.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,5 +33,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <io/console.h>
Index: uspace/app/ping/ping.c
===================================================================
--- uspace/app/ping/ping.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/ping/ping.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
 
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <fibril_synch.h>
Index: uspace/app/stats/stats.c
===================================================================
--- uspace/app/stats/stats.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/stats/stats.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #include <malloc.h>
 #include <inttypes.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <str.h>
 #include <arg_parse.h>
Index: uspace/app/taskdump/taskdump.c
===================================================================
--- uspace/app/taskdump/taskdump.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/taskdump/taskdump.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -47,5 +47,5 @@
 #include <macros.h>
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <symtab.h>
Index: uspace/app/tester/Makefile
===================================================================
--- uspace/app/tester/Makefile	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tester/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -29,6 +29,6 @@
 
 USPACE_PREFIX = ../..
-LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
-EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBSOFTFLOAT_PREFIX)
+LIBS = $(LIBEXT2_PREFIX)/libext2.a $(LIBBLOCK_PREFIX)/libblock.a $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
+EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBEXT2_PREFIX) -I$(LIBSOFTFLOAT_PREFIX)
 BINARY = tester
 
@@ -42,5 +42,4 @@
 	print/print4.c \
 	print/print5.c \
-	print/print6.c \
 	console/console1.c \
 	stdio/stdio1.c \
@@ -63,5 +62,6 @@
 	mm/mapping1.c \
 	hw/misc/virtchar1.c \
-	hw/serial/serial1.c
+	hw/serial/serial1.c \
+	ext2/ext2_1.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/tester/ext2/ext2_1.c
===================================================================
--- uspace/app/tester/ext2/ext2_1.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/app/tester/ext2/ext2_1.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include "../tester.h"
+#include "../util.h"
+#include <libext2.h>
+#include <malloc.h>
+
+static ext2_superblock_t *fake_superblock1()
+{
+	uint8_t *buf;
+	int i;
+	
+	buf = malloc(EXT2_SUPERBLOCK_SIZE);
+	if (buf == NULL) {
+		return NULL;
+	}
+	
+	for (i = 0; i < EXT2_SUPERBLOCK_SIZE; i++) {
+		buf[i] = i % 256;
+	}
+	
+	return (ext2_superblock_t *) buf;
+}
+
+const char *test_ext2_1(void)
+{
+	ext2_superblock_t *fake1;
+	
+	TPRINTF("Testing ext2 superblock getters...\n");
+	TPRINTF("Simple test for correct position and byte order\n");
+	
+	fake1 = fake_superblock1();
+	if (fake1 == NULL) {
+		return "Failed allocating memory for test superblock 1";
+	}
+	
+	ASSERT_EQ_32(0x03020100, ext2_superblock_get_total_inode_count(fake1),
+	    "Failed getting total inode count");
+	ASSERT_EQ_32(0x07060504, ext2_superblock_get_total_block_count(fake1),
+	    "Failed getting total block count");
+	ASSERT_EQ_32(0x0B0A0908, ext2_superblock_get_reserved_block_count(fake1),
+	    "Failed getting reserved block count");
+	ASSERT_EQ_32(0x0F0E0D0C, ext2_superblock_get_free_block_count(fake1),
+	    "Failed getting free block count");
+	ASSERT_EQ_32(0x13121110, ext2_superblock_get_free_inode_count(fake1),
+	    "Failed getting free inode count");
+	ASSERT_EQ_32(0x17161514, ext2_superblock_get_first_block(fake1),
+	    "Failed getting first block number");
+	ASSERT_EQ_32(0x1B1A1918, ext2_superblock_get_block_size_log2(fake1),
+	    "Failed getting log block size");
+	ASSERT_EQ_32(0x1F1E1D1C, ext2_superblock_get_fragment_size_log2(fake1),
+	    "Failed getting log fragment size");
+	ASSERT_EQ_32(0x23222120, ext2_superblock_get_blocks_per_group(fake1),
+	    "Failed getting blocks per group");
+	ASSERT_EQ_32(0x27262524, ext2_superblock_get_fragments_per_group(fake1),
+	    "Failed getting fragments per group");
+	ASSERT_EQ_32(0x2B2A2928, ext2_superblock_get_inodes_per_group(fake1),
+	    "Failed getting inodes per group");
+	ASSERT_EQ_16(0x3938, ext2_superblock_get_magic(fake1),
+	    "Failed getting magic number");
+	ASSERT_EQ_16(0x3B3A, ext2_superblock_get_state(fake1),
+	    "Failed getting state");
+	ASSERT_EQ_16(0x3F3E, ext2_superblock_get_rev_minor(fake1),
+	    "Failed getting minor revision number");
+	ASSERT_EQ_32(0x4B4A4948, ext2_superblock_get_os(fake1),
+	    "Failed getting OS");
+	ASSERT_EQ_32(0x4F4E4D4C, ext2_superblock_get_rev_major(fake1),
+	    "Failed getting major revision number");
+	ASSERT_EQ_32(0x57565554, ext2_superblock_get_first_inode(fake1),
+	    "Failed getting first inode number");
+	ASSERT_EQ_16(0x5958, ext2_superblock_get_inode_size(fake1),
+	    "Failed getting size");
+	ASSERT_EQ_8(0x68, fake1->uuid[0], "UUID position is incorrect");
+	ASSERT_EQ_8(0x78, fake1->volume_name[0],
+	    "Volume name position is incorrect");
+	
+	return NULL;
+}
Index: uspace/app/tester/ext2/ext2_1.def
===================================================================
--- uspace/app/tester/ext2/ext2_1.def	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/app/tester/ext2/ext2_1.def	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,6 @@
+{
+	"ext2_1",
+	"Superblock getters test",
+	&test_ext2_1,
+	true
+},
Index: uspace/app/tester/float/softfloat1.c
===================================================================
--- uspace/app/tester/float/softfloat1.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tester/float/softfloat1.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,10 +34,8 @@
 #include <mul.h>
 #include <div.h>
-#include <comparison.h>
-#include <conversion.h>
-#include <stdbool.h>
+#include <bool.h>
 #include "../tester.h"
 
-#define OPERANDS  10
+#define OPERANDS  6 
 #define PRECISION  10000
 
@@ -45,29 +43,20 @@
 
 typedef int32_t cmptype_t;
-
-typedef void (* uint_to_double_op_t)(unsigned int, double *, double_t *);
-typedef void (* double_to_uint_op_t)(double, unsigned int *, unsigned int *);
-typedef void (* float_binary_op_t)(float, float, float *, float_t *);
-typedef void (* double_binary_op_t)(double, double, double *, double_t *);
-typedef void (* double_cmp_op_t)(double, double, cmptype_t *, cmptype_t *);
-
-typedef void (* template_unary_t)(void *, unsigned, cmptype_t *, cmptype_t *);
-typedef void (* template_binary_t)(void *, unsigned, unsigned, cmptype_t *,
+typedef void (* float_op_t)(float, float, float *, float_t *);
+typedef void (* double_op_t)(double, double, double *, double_t *);
+typedef void (* template_t)(void *, unsigned, unsigned, cmptype_t *,
     cmptype_t *);
 
-#define NUMBERS	\
-	3.5, -2.1, 100.0, 50.0, -1024.0, 0.0, 768.3156, 1080.499999, -600.0, 1.0
-
-static float fop_a[OPERANDS] = {
-	NUMBERS
-};
-
-static double dop_a[OPERANDS] =	{
-	NUMBERS
-};
-
-static unsigned int uop_a[OPERANDS] = {
-	4, -100, 100, 50, 1024, 0, 1000000, -1U, 0x80000000U, 500
-};
+static float fop_a[OPERANDS] =
+	{3.5, -2.1, 100.0, 50.0, -1024.0, 0.0};
+
+static float fop_b[OPERANDS] =
+	{-2.1, 100.0, 50.0, -1024.0, 3.5, 0.0};
+
+static double dop_a[OPERANDS] =
+	{3.5, -2.1, 100.0, 50.0, -1024.0, 0.0};
+
+static double dop_b[OPERANDS] =
+	{-2.1, 100.0, 50.0, -1024.0, 3.5, 0.0};
 
 static cmptype_t cmpabs(cmptype_t a)
@@ -79,23 +68,29 @@
 }
 
-static int dcmp(double a, double b)
-{
-	if (a < b)
-		return -1;
-	else if (a > b)
-		return 1;
-
-	return 0;
-}
-
 static void
-uint_to_double_template(void *f, unsigned i, cmptype_t *pic, cmptype_t *pisc)
+float_template(void *f, unsigned i, unsigned j, cmptype_t *pic,
+    cmptype_t *pisc)
+{
+	float c;
+	float_t sc;
+
+	float_op_t op = (float_op_t) f;
+	
+	op(fop_a[i], fop_b[j], &c, &sc);
+
+	*pic = (cmptype_t) (c * PRECISION);
+	*pisc = (cmptype_t) (sc.val * PRECISION);
+}
+
+static void
+double_template(void *f, unsigned i, unsigned j, cmptype_t *pic,
+    cmptype_t *pisc)
 {
 	double c;
 	double_t sc;
 
-	uint_to_double_op_t op = (uint_to_double_op_t) f;
-	
-	op(uop_a[i], &c, &sc);
+	double_op_t op = (double_op_t) f;
+	
+	op(dop_a[i], dop_b[j], &c, &sc);
 
 	*pic = (cmptype_t) (c * PRECISION);
@@ -103,79 +98,5 @@
 }
 
-static void
-double_to_uint_template(void *f, unsigned i, cmptype_t *pic, cmptype_t *pisc)
-{
-	unsigned int c;
-	unsigned int sc;
-
-	double_to_uint_op_t op = (double_to_uint_op_t) f;
-	
-	op(dop_a[i], &c, &sc);
-
-	*pic = (cmptype_t) c;
-	*pisc = (cmptype_t) sc;
-}
-
-
-static void
-float_template_binary(void *f, unsigned i, unsigned j, cmptype_t *pic,
-    cmptype_t *pisc)
-{
-	float c;
-	float_t sc;
-
-	float_binary_op_t op = (float_binary_op_t) f;
-	
-	op(fop_a[i], fop_a[j], &c, &sc);
-
-	*pic = (cmptype_t) (c * PRECISION);
-	*pisc = (cmptype_t) (sc.val * PRECISION);
-}
-
-static void
-double_template_binary(void *f, unsigned i, unsigned j, cmptype_t *pic,
-    cmptype_t *pisc)
-{
-	double c;
-	double_t sc;
-
-	double_binary_op_t op = (double_binary_op_t) f;
-	
-	op(dop_a[i], dop_a[j], &c, &sc);
-
-	*pic = (cmptype_t) (c * PRECISION);
-	*pisc = (cmptype_t) (sc.val * PRECISION);
-}
-
-static void
-double_compare_template(void *f, unsigned i, unsigned j, cmptype_t *pis,
-    cmptype_t *piss)
-{
-	double_cmp_op_t op = (double_cmp_op_t) f;
-	
-	op(dop_a[i], dop_a[j], pis, piss);
-}
-
-static bool test_template_unary(template_unary_t template, void *f)
-{
-	bool correct = true;
-	
-	for (unsigned int i = 0; i < OPERANDS; i++) {
-		cmptype_t ic;
-		cmptype_t isc;
-
-		template(f, i, &ic, &isc);	
-		cmptype_t diff = cmpabs(ic - isc);
-			
-		if (diff != 0) {
-			TPRINTF("i=%u diff=%" PRIdCMPTYPE "\n", i, diff);
-			correct = false;
-		}
-	}
-	
-	return correct;
-}
-
-static bool test_template_binary(template_binary_t template, void *f)
+static bool test_template(template_t template, void *f)
 {
 	bool correct = true;
@@ -200,32 +121,4 @@
 }
 
-static void uint_to_double_operator(unsigned int a, double *pc, double_t *psc)
-{
-	*pc = (double) a;
-	psc->data = uint_to_double(a);
-}
-
-static void
-double_to_uint_operator(double a, unsigned int *pc, unsigned int *psc)
-{
-	double_t sa;
-
-	sa.val = a;
-
-	*pc = (unsigned int) a;
-	*psc = double_to_uint(sa.data);
-}
-
-static void
-double_to_int_operator(double a, unsigned int *pc, unsigned int *psc)
-{
-	double_t sa;
-
-	sa.val = a;
-
-	*pc = (int) a;
-	*psc = double_to_int(sa.data);
-}
-
 static void float_add_operator(float a, float b, float *pc, float_t *psc)
 {
@@ -328,72 +221,32 @@
 }
 
-static void
-double_cmp_operator(double a, double b, cmptype_t *pis, cmptype_t *piss)
-{
-	*pis = dcmp(a, b);
-
-	double_t sa;
-	double_t sb;
-
-	sa.val = a;
-	sb.val = b;
-
-	if (is_double_lt(sa.data, sb.data))
-		*piss = -1;
-	else if (is_double_gt(sa.data, sb.data))
-		*piss = 1;
-	else if (is_double_eq(sa.data, sb.data))
-		*piss = 0;
-	else
-		*piss = 42;
-}
-
 const char *test_softfloat1(void)
 {
 	const char *err = NULL;
 
-	if (!test_template_binary(float_template_binary, float_add_operator)) {
+	if (!test_template(float_template, float_add_operator)) {
 		err = "Float addition failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template_binary(float_template_binary, float_mul_operator)) {
+	if (!test_template(float_template, float_mul_operator)) {
 		err = "Float multiplication failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template_binary(float_template_binary, float_div_operator)) {
+	if (!test_template(float_template, float_div_operator)) {
 		err = "Float division failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template_binary(double_template_binary, double_add_operator)) {
+	if (!test_template(double_template, double_add_operator)) {
 		err = "Double addition failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template_binary(double_template_binary, double_mul_operator)) {
+	if (!test_template(double_template, double_mul_operator)) {
 		err = "Double multiplication failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template_binary(double_template_binary, double_div_operator)) {
+	if (!test_template(double_template, double_div_operator)) {
 		err = "Double division failed";
 		TPRINTF("%s\n", err);
 	}
-	if (!test_template_binary(double_compare_template, double_cmp_operator)) {
-		err = "Double comparison failed";
-		TPRINTF("%s\n", err);
-	}
-	if (!test_template_unary(uint_to_double_template,
-	    uint_to_double_operator)) {
-		err = "Conversion from unsigned int to double failed";
-		TPRINTF("%s\n", err);
-	}
-	if (!test_template_unary(double_to_uint_template,
-	    double_to_uint_operator)) {
-		err = "Conversion from double to unsigned int failed";
-		TPRINTF("%s\n", err);
-	}
-	if (!test_template_unary(double_to_uint_template,
-	    double_to_int_operator)) {
-		err = "Conversion from double to signed int failed";
-		TPRINTF("%s\n", err);
-	}
 	
 	return err;
Index: uspace/app/tester/mm/common.c
===================================================================
--- uspace/app/tester/mm/common.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tester/mm/common.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -343,5 +343,5 @@
 	
 	area->addr = as_area_create(AS_AREA_ANY, size,
-	    AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE);
+	    AS_AREA_WRITE | AS_AREA_READ);
 	if (area->addr == AS_MAP_FAILED) {
 		free(area);
Index: uspace/app/tester/mm/common.h
===================================================================
--- uspace/app/tester/mm/common.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tester/mm/common.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <adt/list.h>
 
Index: uspace/app/tester/mm/mapping1.c
===================================================================
--- uspace/app/tester/mm/mapping1.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tester/mm/mapping1.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -43,5 +43,5 @@
 	
 	void *result = as_area_create(AS_AREA_ANY, size,
-	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
+	    AS_AREA_READ | AS_AREA_WRITE);
 	if (result == AS_MAP_FAILED)
 		return NULL;
Index: uspace/app/tester/print/print5.def
===================================================================
--- uspace/app/tester/print/print5.def	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tester/print/print5.def	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,6 +1,6 @@
 {
-	"print5",
-	"Char printf test",
-	&test_print5,
+	"print1",
+	"String printf test",
+	&test_print1,
 	true
 },
Index: pace/app/tester/print/print6.c
===================================================================
--- uspace/app/tester/print/print6.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,213 +1,0 @@
-/*
- * Copyright (c) 2012 Adam Hraska
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include "../tester.h"
-
-#include <str.h>
-
-const char *test_print6(void)
-{
-	struct {
-		double val;
-		const char *fmt;
-		const char *exp_str;
-		const char *warn_str;
-	} pat[] = {
-		/* 
-		 * Generic 
-		 */
-		{ 2.0,         "%g",       "2", 0 },
-		{ 0,           "%g",       "0", 0 },
-		{ 0.1,         "%g",     "0.1", 0 },
-		{ 9e59,        "%g",   "9e+59", 0 },
-		{ -9e-59,      "%g",  "-9e-59", 0 },
-		{ 1e307,       "%g",  "1e+307", 0 },   
-		{ 0.09999999999999999, "%g",  "9.999999999999999e-02", 0 },   
-		{ 0.099999999999999999, "%g",  "0.1", 0 },   
-
-		/*
-		 * gcc and msvc convert "3.4567e-317" to different binary
-		 * doubles.
-		 */
-		{ 3.4567e-317, "%g",  "3.4567e-317", "3.456998e-317" },   
-		{ 3.4567e-318, "%g",  "3.4567e-318", 0 },   
-		{ 123456789012345.0, "%g",  "123456789012345", 0 },   
-		{ -123456789012345.0, "%g",  "-123456789012345", 0 },   
-
-		/* Special */
-		{ 1e300 * 1e300, "%g",  "inf", 0 },   
-		{ -1.0 /(1e300 * 1e300), "%g",  "-0", 0 },   
-
-		{ 1234567.8901, "%g",  "1234567.8901", 0 },   
-		{ 1234567.80012, "%g",  "1234567.80012", 0 },   
-		{ 112e-32, "%g",  "1.12e-30", 0 },   
-		{ 10.0e45, "%g",  "1e+46", 0 },   
-
-		/* rounding w/ trailing zero removal */
-		{ 0.01, "%10.6g",      "      0.01", 0 },   
-		{ 9.495, "%10.2g",     "       9.5", 0 },   
-		{ 9.495e30, "%10.2g",  "   9.5e+30", 0 },   
-		{ 9.495e30, "%10g",  " 9.495e+30", 0 },   
-		{ 9.495e30, "%10.6g",  " 9.495e+30", 0 },   
-
-		/*
-		 * Scientific 
-		 */
-		{ 1e05, "%e",  "1.000000e+05", 0 },   
-
-		/* full padding */
-
-		/* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
-		{ 1e-1, "%+010.3e",  "+1.000e-01", 0 },
-		{ 1e-1, "%+10.3e",  "+1.000e-01", 0 },   
-		/* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_LEFTALIGNED */
-		{ 1e-1, "%+-10.3e",  "+1.000e-01", 0 },
-
-		/* padding */
-
-		/* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
-		{ 1e-1, "%+010.2e",  "+01.00e-01", 0 },
-		{ 1e-1, "%+10.2e",  " +1.00e-01", 0 },   
-		/* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_LEFTALIGNED */
-		{ 1e-1, "%+-10.2e",  "+1.00e-01 ", 0 },
-		/* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
-		{ 1e-1, "% 010.2e",  " 01.00e-01", 0 },
-		/* __PRINTF_FLAG_ZEROPADDED */
-		{ 1e-1, "%010.2e",  "001.00e-01", 0 },
-		/* __PRINTF_FLAG_SPACESIGN */
-		{ 1e-1, "% 10.2e",  "  1.00e-01", 0 },
-		{ 1e-1, "%10.2e",  "  1.00e-01", 0 },   
-
-		/* padding fractionals */
-
-		/* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
-		{ 1.08e29, "%+010.3e",  "+1.080e+29", 0 },
-		{ 1.08e29, "%+10.3e",  "+1.080e+29", 0 },  
-		/* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
-		{ 1.08e29, "%+011.2e",  "+001.08e+29", 0 },
-		{ 1.085e29, "%11.2e", "   1.09e+29", 0 },   
-
-		/* rounding */
-
-		{ 1.345e2, "%+10.2e",  " +1.35e+02", 0 }, 
-		{ 9.995e2, "%+10.2e",  " +1.00e+03", 0 }, 
-		{ -9.99499999e2, "%10.2e",  " -9.99e+02", 0 },   
-		{ -9.99499999e2, "%10.0e",  "    -1e+03", 0 },   
-		/* __PRINTF_FLAG_DECIMALPT */
-		{ -9.99499999e2, "%#10.0e",  "   -1.e+03", 0 },
-		/* __PRINTF_FLAG_DECIMALPT */
-		{ -1.2345006789e+231, "%#10.10e",   "-1.2345006789e+231", 0 },
-		/* __PRINTF_FLAG_DECIMALPT */
-		{ -1.23450067995e+231, "%#10.10e",  "-1.2345006800e+231", 0 },
-			
-		/* special */
-
-		{ 1e300 * 1e300, "%10.5e",  "       inf", 0 },   
-		{ -1.0 /(1e300 * 1e300), "%10.2e",  " -0.00e+00", 0 },   
-		/* __PRINTF_FLAG_BIGCHARS */
-		{ 1e300 * 1e300, "%10.5E",  "       INF", 0 },
-		/* __PRINTF_FLAG_BIGCHARS */
-		{ -1.0 /(1e300 * 1e300), "%10.2E",  " -0.00E+00", 0 },
-
-		/*
-		 * Fixed
-		 */
-		 
-		/* padding */
-
-		/* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
-		{ 1e-1, "% 010.3f",  " 00000.100", 0 },
-		/*
-		 * __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED |
-		 * __PRINTF_FLAG_LEFTALIGNED
-		 */
-		{ 1e-1, "% 0-10.3f",  " 0.100    ", 0 },
-		/* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
-		{ 1e-1, "% 010.3f",  " 00000.100", 0 },
-		{ 1e-1, "%10.3f",  "     0.100", 0 },   
-
-		/* rounding */
-
-		{ -0.0, "%10.0f",     "        -0", 0 },   
-		{ -0.099, "%+10.3f",   "    -0.099", 0 }, 
-		{ -0.0995, "%+10.3f",  "    -0.100", 0 }, 
-		{ -0.0994, "%+10.3f",  "    -0.099", 0 }, 
-		{ -99.995, "%+10.0f",  "      -100", 0 }, 
-		{ 3.5, "%+10.30f",  "+3.500000000000000000000000000000", 0 }, 
-		{ 3.5, "%+10.0f",      "        +4", 0 }, 
-		{ 0.1, "%+10.6f",      " +0.100000", 0 }, 
-
-		/*
-		 * The compiler will go for closer 0.10..055 instead of
-		 * 0.09..917
-		 */
-		{ 0.1, "%+10.20f",  "+0.10000000000000000550", 0 },  
-		/* Next closest to 0.1 */
-		{ 0.0999999999999999917, "%+10.20f", "+0.09999999999999999170",
-		    0 }, 
-		{ 0.0999999999999999917, "%+10f",    " +0.100000", 0 },
-		{ 0.0999999999999998945, "%10.20f",  "0.09999999999999989450",
-		    0 },   
-	};
-
-	int patterns_len = (int)(sizeof(pat) / sizeof(pat[0]));
-	int failed = 0;
-	const int buf_size = 256;
-	char buf[256 + 1] = { 0 };
-	
-	TPRINTF("Test printing of floating point numbers via "
-	    "printf(\"%%f\"):\n");
-	
-	for (int i = 0; i < patterns_len; ++i) {
-		
-		snprintf(buf, buf_size, pat[i].fmt, pat[i].val);
-		
-		if (!str_cmp(buf, pat[i].exp_str)) {
-			TPRINTF("ok:  %s |%s| == |%s|\n",
-			    pat[i].fmt, buf, pat[i].exp_str);
-		} else {
-			if (pat[i].warn_str && !str_cmp(buf, pat[i].warn_str)) {
-				TPRINTF("warn: %s |%s| != |%s|\n",
-				    pat[i].fmt, buf, pat[i].exp_str);
-			} else {
-				++failed;
-				TPRINTF("ERR: %s |%s| != |%s|\n",
-				    pat[i].fmt, buf, pat[i].exp_str);
-			}
-		}
-	}
-	
-	if (failed) {
-		return "Unexpectedly misprinted floating point numbers.";
-	} else {
-		return 0;
-	}
-}
-
Index: pace/app/tester/print/print6.def
===================================================================
--- uspace/app/tester/print/print6.def	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,6 +1,0 @@
-{
-	"print6",
-	"Floating point printf test",
-	&test_print6,
-	true
-},
Index: uspace/app/tester/tester.c
===================================================================
--- uspace/app/tester/tester.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tester/tester.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -53,5 +53,4 @@
 #include "print/print4.def"
 #include "print/print5.def"
-#include "print/print6.def"
 #include "console/console1.def"
 #include "stdio/stdio1.def"
@@ -74,4 +73,5 @@
 #include "hw/serial/serial1.def"
 #include "hw/misc/virtchar1.def"
+#include "ext2/ext2_1.def"
 	{NULL, NULL, NULL, false}
 };
Index: uspace/app/tester/tester.h
===================================================================
--- uspace/app/tester/tester.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tester/tester.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <stacktrace.h>
 
@@ -85,5 +85,4 @@
 extern const char *test_print4(void);
 extern const char *test_print5(void);
-extern const char *test_print6(void);
 extern const char *test_console1(void);
 extern const char *test_stdio1(void);
@@ -106,4 +105,5 @@
 extern const char *test_serial1(void);
 extern const char *test_virtchar1(void);
+extern const char *test_ext2_1(void);
 extern const char *test_devman1(void);
 extern const char *test_devman2(void);
Index: uspace/app/tetris/screen.c
===================================================================
--- uspace/app/tetris/screen.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tetris/screen.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -61,5 +61,5 @@
 #include <vfs/vfs.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <io/console.h>
 #include <io/style.h>
Index: uspace/app/tetris/screen.h
===================================================================
--- uspace/app/tetris/screen.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/tetris/screen.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -58,5 +58,5 @@
 #include <io/console.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 
 typedef struct {
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/trace/trace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -43,5 +43,5 @@
 #include <mem.h>
 #include <str.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <loader/loader.h>
 #include <io/console.h>
Index: uspace/app/usbinfo/desctree.c
===================================================================
--- uspace/app/usbinfo/desctree.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/usbinfo/desctree.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <errno.h>
 #include <str_error.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <usb/usb.h>
Index: uspace/app/usbinfo/dump.c
===================================================================
--- uspace/app/usbinfo/dump.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/usbinfo/dump.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <errno.h>
 #include <str_error.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <usb/usb.h>
Index: uspace/app/usbinfo/list.c
===================================================================
--- uspace/app/usbinfo/list.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/usbinfo/list.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <errno.h>
 #include <str_error.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <getopt.h>
 #include <devman.h>
Index: uspace/app/usbinfo/main.c
===================================================================
--- uspace/app/usbinfo/main.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/usbinfo/main.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <errno.h>
 #include <str_error.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <getopt.h>
 #include <devman.h>
Index: uspace/app/vdemo/vdemo.c
===================================================================
--- uspace/app/vdemo/vdemo.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/vdemo/vdemo.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,5 +33,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <stdio.h>
 #include <malloc.h>
@@ -110,5 +110,5 @@
 {
 	if (argc >= 2) {
-		window_t *main_window = window_open(argv[1], true, true, "vdemo", 0, 0);
+		window_t *main_window = window_open(argv[1], true, true, "vdemo");
 		if (!main_window) {
 			printf("Cannot open main window.\n");
Index: uspace/app/vlaunch/vlaunch.c
===================================================================
--- uspace/app/vlaunch/vlaunch.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/vlaunch/vlaunch.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,5 +33,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <stdio.h>
@@ -98,5 +98,5 @@
 	
 	winreg = argv[1];
-	window_t *main_window = window_open(argv[1], true, true, "vlaunch", 0, 0);
+	window_t *main_window = window_open(argv[1], true, true, "vlaunch");
 	if (!main_window) {
 		printf("Cannot open main window.\n");
Index: uspace/app/vterm/vterm.c
===================================================================
--- uspace/app/vterm/vterm.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/vterm/vterm.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,5 +33,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <stdio.h>
 #include <io/pixel.h>
@@ -49,5 +49,5 @@
 	}
 	
-	window_t *main_window = window_open(argv[1], true, true, "vterm", 0, 0);
+	window_t *main_window = window_open(argv[1], true, true, "vterm");
 	if (!main_window) {
 		printf("%s: Cannot open main window.\n", NAME);
Index: uspace/app/websrv/websrv.c
===================================================================
--- uspace/app/websrv/websrv.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/app/websrv/websrv.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <assert.h>
Index: uspace/dist/src/c/demos/edit/edit.c
===================================================================
--- uspace/dist/src/c/demos/edit/edit.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/dist/src/c/demos/edit/edit.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -46,5 +46,5 @@
 #include <macros.h>
 #include <clipboard.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include "sheet.h"
Index: uspace/dist/src/c/demos/edit/sheet.h
===================================================================
--- uspace/dist/src/c/demos/edit/sheet.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/dist/src/c/demos/edit/sheet.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <adt/list.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 /** Direction (in linear space) */
Index: uspace/dist/src/c/demos/tetris/screen.c
===================================================================
--- uspace/dist/src/c/demos/tetris/screen.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/dist/src/c/demos/tetris/screen.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -61,5 +61,5 @@
 #include <vfs/vfs.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <io/console.h>
 #include <io/style.h>
Index: uspace/dist/src/c/demos/tetris/screen.h
===================================================================
--- uspace/dist/src/c/demos/tetris/screen.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/dist/src/c/demos/tetris/screen.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -58,5 +58,5 @@
 #include <io/console.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 
 typedef struct {
Index: uspace/drv/bus/isa/i8237.c
===================================================================
--- uspace/drv/bus/isa/i8237.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/isa/i8237.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,8 +36,9 @@
 
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <fibril_synch.h>
 #include <ddi.h>
+#include <libarch/ddi.h>
 #include <ddf/log.h>
 #include "i8237.h"
Index: uspace/drv/bus/isa/isa.c
===================================================================
--- uspace/drv/bus/isa/isa.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/isa/isa.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,5 +42,5 @@
 #include <stdio.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <stdlib.h>
Index: uspace/drv/bus/pci/pciintel/pci.c
===================================================================
--- uspace/drv/bus/pci/pciintel/pci.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/pci/pciintel/pci.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 #include <stdio.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <str.h>
@@ -58,4 +58,5 @@
 #include <device/hw_res.h>
 #include <ddi.h>
+#include <libarch/ddi.h>
 #include <pci_dev_iface.h>
 
Index: uspace/drv/bus/usb/ehci/ehci.ma
===================================================================
--- uspace/drv/bus/usb/ehci/ehci.ma	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/ehci/ehci.ma	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,2 +1,1 @@
-20 usb/host=ehci
 10 pci/class=0c&subclass=03&progif=20
Index: uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 #define DRV_OHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
 
-#include <stdbool.h>
+#include <bool.h>
 #include <stdint.h>
 
Index: uspace/drv/bus/usb/ohci/ohci.ma
===================================================================
--- uspace/drv/bus/usb/ohci/ohci.ma	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/ohci/ohci.ma	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,2 +1,1 @@
-20 usb/host=ohci
 10 pci/class=0c&subclass=03&progif=10
Index: uspace/drv/bus/usb/ohci/ohci_regs.h
===================================================================
--- uspace/drv/bus/usb/ohci/ohci_regs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/ohci/ohci_regs.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -245,5 +245,5 @@
 #define RHPS_PRSC_FLAG (1 << 20) /* port reset status change WC */
 #define RHPS_CHANGE_WC_MASK (0x1f0000)
-} ohci_regs_t;
+} __attribute__((packed)) ohci_regs_t;
 #endif
 /**
Index: uspace/drv/bus/usb/uhci/hc.c
===================================================================
--- uspace/drv/bus/usb/uhci/hc.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/uhci/hc.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 #include <str_error.h>
 #include <adt/list.h>
-#include <ddi.h>
+#include <libarch/ddi.h>
 
 #include <usb/debug.h>
Index: uspace/drv/bus/usb/uhci/hc.h
===================================================================
--- uspace/drv/bus/usb/uhci/hc.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/uhci/hc.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,4 +37,6 @@
 
 #include <fibril.h>
+#include <ddi.h>
+
 #include <usb/host/hcd.h>
 
Index: uspace/drv/bus/usb/uhcirh/port.c
===================================================================
--- uspace/drv/bus/usb/uhcirh/port.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/uhcirh/port.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -32,5 +32,5 @@
  * @brief UHCI root hub port routines
  */
-#include <ddi.h>
+#include <libarch/ddi.h>  /* pio_read and pio_write */
 #include <fibril_synch.h> /* async_usleep */
 #include <errno.h>
Index: uspace/drv/bus/usb/usbhid/generic/hiddev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/generic/hiddev.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/usbhid/generic/hiddev.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,5 +42,5 @@
 #include <errno.h>
 #include <str_error.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <usbhid_iface.h>
Index: uspace/drv/bus/usb/usbhid/usbhid.h
===================================================================
--- uspace/drv/bus/usb/usbhid/usbhid.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/usbhid/usbhid.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #include <usb/dev/driver.h>
 #include <usb/hid/hid.h>
-#include <stdbool.h>
+#include <bool.h>
 
 typedef struct usb_hid_dev usb_hid_dev_t;
Index: uspace/drv/bus/usb/usbhub/port.c
===================================================================
--- uspace/drv/bus/usb/usbhub/port.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/usbhub/port.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/drv/bus/usb/usbhub/status.h
===================================================================
--- uspace/drv/bus/usb/usbhub/status.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/usbhub/status.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
 #define	HUB_STATUS_H
 
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 #include <usb/dev/request.h>
Index: uspace/drv/bus/usb/usbhub/usbhub.c
===================================================================
--- uspace/drv/bus/usb/usbhub/usbhub.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/usbhub/usbhub.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 
 #include <ddf/driver.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/drv/bus/usb/usbmast/bo_trans.c
===================================================================
--- uspace/drv/bus/usb/usbmast/bo_trans.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/bus/usb/usbmast/bo_trans.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
  * USB mass storage bulk-only transport.
  */
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/drv/char/i8042/i8042.c
===================================================================
--- uspace/drv/char/i8042/i8042.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/char/i8042/i8042.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,4 +41,5 @@
 #include <device/hw_res.h>
 #include <ddi.h>
+#include <libarch/ddi.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/drv/char/ns8250/ns8250.c
===================================================================
--- uspace/drv/char/ns8250/ns8250.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/char/ns8250/ns8250.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <stdio.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <stdlib.h>
@@ -51,4 +51,5 @@
 #include <sys/stat.h>
 #include <ddi.h>
+#include <libarch/ddi.h>
 
 #include <ddf/driver.h>
Index: uspace/drv/char/ps2mouse/ps2mouse.c
===================================================================
--- uspace/drv/char/ps2mouse/ps2mouse.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/char/ps2mouse/ps2mouse.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,5 +33,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <ddf/log.h>
Index: pace/drv/fb/amdm37x_dispc/Makefile
===================================================================
--- uspace/drv/fb/amdm37x_dispc/Makefile	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# Copyright (c) 2007 Jakub Jermar
-# Copyright (c) 2011 Petr Koupy
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../../..
-
-LIBS = \
-	$(LIBDRV_PREFIX)/libdrv.a \
-	$(LIBGRAPH_PREFIX)/libgraph.a \
-	$(LIBSOFTREND_PREFIX)/libsoftrend.a
-
-EXTRA_CFLAGS += \
-	-I$(LIBDRV_PREFIX)/include \
-	-I$(LIBGRAPH_PREFIX) \
-	-I$(LIBSOFTREND_PREFIX)
-
-BINARY = amdm37x_dispc
-
-SOURCES = \
-	amdm37x_dispc.c \
-	main.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/drv/fb/amdm37x_dispc/amdm37x_dispc.c
===================================================================
--- uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,332 +1,0 @@
-/*
- * Copyright (c) 2013 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 amdm37x
- * @{
- */
-/**
- * @file
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <ddf/log.h>
-#include <ddi.h>
-#include <abi/mm/as.h>
-
-#include "amdm37x_dispc.h"
-
-#ifndef CONFIG_BFB_BPP
-#define CONFIG_BFB_BPP 24
-#endif
-
-#ifndef CONFIG_BFB_WIDTH
-#define CONFIG_BFB_WIDTH 1024
-#endif
-
-#ifndef CONFIG_BFB_HEIGHT
-#define CONFIG_BFB_HEIGHT 768
-#endif
-
-
-static int change_mode(visualizer_t *vis, vslmode_t mode);
-static int handle_damage(visualizer_t *vs,
-    sysarg_t x0, sysarg_t y0, sysarg_t width, sysarg_t height,
-    sysarg_t x_offset, sysarg_t y_offset);
-static int dummy(visualizer_t *vs)
-{
-	return EOK;
-}
-
-static const visualizer_ops_t amdm37x_dispc_vis_ops = {
-	.change_mode = change_mode,
-	.handle_damage = handle_damage,
-	.claim = dummy,
-	.yield = dummy,
-	.suspend = dummy,
-	.wakeup = dummy,
-};
-
-static const struct {
-	unsigned bpp;
-	pixel2visual_t func;
-} pixel2visual_table[] = {
-	[VISUAL_INDIRECT_8] = { .bpp = 1, .func = pixel2bgr_323 },
-	[VISUAL_RGB_5_5_5_LE] = { .bpp = 2, .func = pixel2rgb_555_le },
-	[VISUAL_RGB_5_5_5_BE] = { .bpp = 2, .func = pixel2rgb_555_be },
-	[VISUAL_RGB_5_6_5_LE] = { .bpp = 2, .func = pixel2rgb_565_le },
-	[VISUAL_RGB_5_6_5_BE] = { .bpp = 2, .func = pixel2rgb_565_be },
-	[VISUAL_BGR_8_8_8] = { .bpp = 3, .func = pixel2bgr_888 },
-	[VISUAL_RGB_8_8_8] = { .bpp = 3, .func = pixel2rgb_888 },
-	[VISUAL_BGR_0_8_8_8] = { .bpp = 4, .func = pixel2rgb_0888 },
-	[VISUAL_BGR_8_8_8_0] = { .bpp = 4, .func = pixel2bgr_8880 },
-	[VISUAL_ABGR_8_8_8_8] = { .bpp = 4, .func = pixel2abgr_8888 },
-	[VISUAL_BGRA_8_8_8_8] = { .bpp = 4, .func = pixel2bgra_8888 },
-	[VISUAL_RGB_0_8_8_8] = { .bpp = 4, .func = pixel2rgb_0888 },
-	[VISUAL_RGB_8_8_8_0] = { .bpp = 4, .func = pixel2rgb_8880 },
-	[VISUAL_ARGB_8_8_8_8] = { .bpp = 4, .func = pixel2argb_8888 },
-	[VISUAL_RGBA_8_8_8_8] = { .bpp = 4, .func = pixel2rgba_8888 },
-};
-
-
-
-static void mode_init(vslmode_list_element_t *mode,
-    unsigned width, unsigned height, visual_t visual)
-{
-	mode->mode.index = 0;
-	mode->mode.version = 0;
-	mode->mode.refresh_rate = 0;
-	mode->mode.screen_aspect.width = width;
-	mode->mode.screen_aspect.height = height;
-	mode->mode.screen_width = width;
-	mode->mode.screen_height = height;
-	mode->mode.cell_aspect.width = 1;
-	mode->mode.cell_aspect.height = 1;
-	mode->mode.cell_visual.pixel_visual = visual;
-
-	link_initialize(&mode->link);
-
-}
-
-int amdm37x_dispc_init(amdm37x_dispc_t *instance, visualizer_t *vis)
-{
-	assert(instance);
-	assert(vis);
-
-	instance->fb_data = NULL;
-	instance->size = 0;
-
-	/* Default is 24bpp, use config option if available */
-	visual_t visual = VISUAL_BGR_8_8_8;
-	switch (CONFIG_BFB_BPP)	{
-	case 8: visual = VISUAL_INDIRECT_8; break;
-	case 16: visual = VISUAL_RGB_5_6_5_LE; break;
-	case 24: visual = VISUAL_BGR_8_8_8; break;
-	case 32: visual = VISUAL_RGB_8_8_8_0; break;
-	default:
-		return EINVAL;
-	}
-
-	int ret = pio_enable((void*)AMDM37x_DISPC_BASE_ADDRESS,
-	    AMDM37x_DISPC_SIZE, (void**)&instance->regs);
-	if (ret != EOK) {
-		return EIO;
-	}
-
-	mode_init(&instance->modes[0],
-	    CONFIG_BFB_WIDTH, CONFIG_BFB_HEIGHT, visual);
-
-	/* Handle vis stuff */
-	vis->dev_ctx = instance;
-	vis->def_mode_idx = 0;
-	vis->ops = amdm37x_dispc_vis_ops;
-	list_append(&instance->modes[0].link, &vis->modes);
-
-	return EOK;
-};
-
-int amdm37x_dispc_fini(amdm37x_dispc_t *instance)
-{
-	return EOK;
-};
-
-static int amdm37x_dispc_setup_fb(amdm37x_dispc_regs_t *regs,
-    unsigned x, unsigned y, unsigned bpp, uint32_t pa)
-{
-	assert(regs);
-	/* Init sequence for dispc is in chapter 7.6.5.1.4 p. 1810,
-	 * no idea what parts of that work. */
-
-	/* Disable all interrupts */
-	regs->irqenable = 0;
-
-	/* Pixel format specifics*/
-	uint32_t attrib_pixel_format = 0;
-	uint32_t control_data_lanes = 0;
-	switch (bpp)
-	{
-	case 32:
-		attrib_pixel_format = AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_RGBX;
-		control_data_lanes = AMDM37X_DISPC_CONTROL_TFTDATALINES_24B;
-		break;
-	case 24:
-		attrib_pixel_format = AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_RGB24;
-		control_data_lanes = AMDM37X_DISPC_CONTROL_TFTDATALINES_24B;
-		break;
-	case 16:
-		attrib_pixel_format = AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_RGB16;
-		control_data_lanes = AMDM37X_DISPC_CONTROL_TFTDATALINES_16B;
-		break;
-	default:
-		return EINVAL;
-	}
-
-	/* Prepare sizes */
-	const uint32_t size_reg =
-	    (((x - 1) & AMDM37X_DISPC_SIZE_WIDTH_MASK)
-	        << AMDM37X_DISPC_SIZE_WIDTH_SHIFT) |
-	    (((y - 1) & AMDM37X_DISPC_SIZE_HEIGHT_MASK)
-	        << AMDM37X_DISPC_SIZE_HEIGHT_SHIFT);
-
-	/* modes taken from u-boot, for 1024x768 */
-	// TODO replace magic values with actual correct values
-//	regs->timing_h = 0x1a4024c9;
-//	regs->timing_v = 0x02c00509;
-//	regs->pol_freq = 0x00007028;
-//	regs->divisor  = 0x00010001;
-
-	/* setup output */
-	regs->size_lcd = size_reg;
-	regs->size_dig = size_reg;
-
-	/* Nice blue default color */
-	regs->default_color[0] = 0x0000ff;
-	regs->default_color[1] = 0x0000ff;
-
-	/* Setup control register */
-	uint32_t control = 0 |
-		AMDM37X_DISPC_CONTROL_PCKFREEENABLE_FLAG |
-		(control_data_lanes << AMDM37X_DISPC_CONTROL_TFTDATALINES_SHIFT) |
-		AMDM37X_DISPC_CONTROL_GPOUT0_FLAG |
-		AMDM37X_DISPC_CONTROL_GPOUT1_FLAG;
-	regs->control = control;
-
-	/* No gamma stuff only data */
-	uint32_t config = (AMDM37X_DISPC_CONFIG_LOADMODE_DATAEVERYFRAME
-	            << AMDM37X_DISPC_CONFIG_LOADMODE_SHIFT);
-	regs->config = config;
-
-
-	/* Set framebuffer base address */
-	regs->gfx.ba[0] = pa;
-	regs->gfx.ba[1] = pa;
-	regs->gfx.position = 0;
-
-	/* Setup fb size */
-	regs->gfx.size = size_reg;
-
-	/* Set pixel format */
-	uint32_t attribs = 0 |
-	    (attrib_pixel_format << AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_SHIFT);
-	regs->gfx.attributes = attribs;
-
-	/* 0x03ff03c0 is the default */
-	regs->gfx.fifo_threshold = 0x03ff03c0;
-	/* This value should be stride - width, 1 means next pixel i.e.
-	 * stride == width */
-	regs->gfx.row_inc = 1;
-	/* number of bytes to next pixel in BPP multiples */
-	regs->gfx.pixel_inc = 1;
-	/* only used if video is played over fb */
-	regs->gfx.window_skip = 0;
-	/* Gamma and palette table */
-	regs->gfx.table_ba = 0;
-
-	/* enable frame buffer graphics */
-	regs->gfx.attributes |= AMDM37X_DISPC_GFX_ATTRIBUTES_ENABLE_FLAG;
-	/* Update register values */
-	regs->control |= AMDM37X_DISPC_CONTROL_GOLCD_FLAG;
-	regs->control |= AMDM37X_DISPC_CONTROL_GODIGITAL_FLAG;
-	/* Enable output */
-	regs->control |= AMDM37X_DISPC_CONTROL_LCD_ENABLE_FLAG;
-	regs->control |= AMDM37X_DISPC_CONTROL_DIGITAL_ENABLE_FLAG;
-	return EOK;
-}
-
-static int change_mode(visualizer_t *vis, vslmode_t mode)
-{
-	assert(vis);
-	assert(vis->dev_ctx);
-
-	amdm37x_dispc_t *dispc = vis->dev_ctx;
-	const visual_t visual = mode.cell_visual.pixel_visual;
-	assert(visual < sizeof(pixel2visual_table) / sizeof(pixel2visual_table[0]));
-	const unsigned bpp = pixel2visual_table[visual].bpp;
-	pixel2visual_t p2v = pixel2visual_table[visual].func;
-	const unsigned x = mode.screen_width;
-	const unsigned y = mode.screen_height;
-	ddf_log_note("Setting mode: %ux%ux%u\n", x, y, bpp*8);
-	const size_t size = ALIGN_UP(x * y * bpp, PAGE_SIZE);
-	void *buffer, *pa;
-	int ret = dmamem_map_anonymous(size, AS_AREA_READ | AS_AREA_WRITE,
-	    0, &pa, &buffer);
-	if (ret != EOK) {
-		ddf_log_error("Failed to get new FB\n");
-		return ret;
-	}
-	amdm37x_dispc_setup_fb(dispc->regs, x, y, bpp *8, (uint32_t)pa);
-	dispc->active_fb.idx = mode.index;
-	dispc->active_fb.width = x;
-	dispc->active_fb.height = y;
-	dispc->active_fb.pitch = 0;
-	dispc->active_fb.bpp = bpp;
-	dispc->active_fb.pixel2visual = p2v;
-	dispc->fb_data = buffer;
-	dispc->size = size;
-	assert(mode.index < 1);
-
-	if (dispc->fb_data)
-		dmamem_unmap_anonymous(dispc->fb_data);
-	return EOK;
-}
-
-static int handle_damage(visualizer_t *vs,
-    sysarg_t x0, sysarg_t y0, sysarg_t width, sysarg_t height,
-    sysarg_t x_offset, sysarg_t y_offset)
-{
-	assert(vs);
-	assert(vs->dev_ctx);
-	amdm37x_dispc_t *dispc = vs->dev_ctx;
-	pixelmap_t *map = &vs->cells;
-
-#define FB_POS(x, y) \
-	(((y) * (dispc->active_fb.width + dispc->active_fb.pitch) + (x)) \
-	    * dispc->active_fb.bpp)
-	if (x_offset == 0 && y_offset == 0) {
-		/* Faster damage routine ignoring offsets. */
-		for (sysarg_t y = y0; y < height + y0; ++y) {
-			pixel_t *pixel = pixelmap_pixel_at(map, x0, y);
-			for (sysarg_t x = x0; x < width + x0; ++x) {
-				dispc->active_fb.pixel2visual(
-				    dispc->fb_data + FB_POS(x, y), *pixel++);
-			}
-		}
-	} else {
-		for (sysarg_t y = y0; y < height + y0; ++y) {
-			for (sysarg_t x = x0; x < width + x0; ++x) {
-				dispc->active_fb.pixel2visual(
-				    dispc->fb_data + FB_POS(x, y),
-				    *pixelmap_pixel_at(map,
-				        (x + x_offset) % map->width,
-				        (y + y_offset) % map->height));
-			}
-		}
-	}
-
-	return EOK;
-}
Index: pace/drv/fb/amdm37x_dispc/amdm37x_dispc.h
===================================================================
--- uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * Copyright (c) 2013 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 kgraph
- * @{
- */
-/**
- * @file
- */
-
-#ifndef AMDM37X_DISPC_H_
-#define AMDM37X_DISPC_H_
-
-#include <graph.h>
-#include <abi/fb/visuals.h>
-#include <pixconv.h>
-
-#include "amdm37x_dispc_regs.h"
-
-typedef struct {
-	amdm37x_dispc_regs_t *regs;
-
-	struct {
-		pixel2visual_t pixel2visual;
-		unsigned width;
-		unsigned height;
-		unsigned pitch;
-		unsigned bpp;
-		unsigned idx;
-	} active_fb;
-
-	size_t size;
-	void *fb_data;
-
-	vslmode_list_element_t modes[1];
-} amdm37x_dispc_t;
-
-int amdm37x_dispc_init(amdm37x_dispc_t *instance, visualizer_t *vis);
-int amdm37x_dispc_fini(amdm37x_dispc_t *instance);
-
-#endif
-/** @}
- */
Index: pace/drv/fb/amdm37x_dispc/amdm37x_dispc.ma
===================================================================
--- uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.ma	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,1 +1,0 @@
-100 amdm37x&dispc
Index: pace/drv/fb/amdm37x_dispc/amdm37x_dispc_regs.h
===================================================================
--- uspace/drv/fb/amdm37x_dispc/amdm37x_dispc_regs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,287 +1,0 @@
-/*
- * Copyright (c) 2013 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 genarch
- * @{
- */
-/**
- * @file
- * @brief Texas Instruments AM/DM37x SDRAM Memory Scheduler.
- */
-
-#ifndef AMDM37x_DISPC_REGS_H_
-#define AMDM37x_DISPC_REGS_H_
-
-/* AMDM37x TRM p. 1813 */
-#define AMDM37x_DISPC_BASE_ADDRESS 0x48050400
-#define AMDM37x_DISPC_SIZE 1024
-
-#include <macros.h>
-
-typedef struct {
-	const ioport32_t revision;
-#define AMDM37X_DISPC_REVISION_MASK  0xff
-
-	PADD32[3];
-	ioport32_t sysconfig;
-#define AMDM37X_DISPC_SYSCONFIG_AUTOIDLE_FLAG  (1 << 0)
-#define AMDM37X_DISPC_SYSCONFIG_SOFTRESET_FLAG  (1 << 1)
-#define AMDM37X_DISPC_SYSCONFIG_ENWAKEUP_FLAG  (1 << 2)
-#define AMDM37X_DISPC_SYSCONFIG_SIDLEMODE_MASK  0x3
-#define AMDM37X_DISPC_SYSCONFIG_SIDLEMODE_SHIFT  3
-#define AMDM37X_DISPC_SYSCONFIG_CLOCKACTIVITY_MASK  0x3
-#define AMDM37X_DISPC_SYSCONFIG_CLOCKACTIVITY_SHIFT  8
-#define AMDM37X_DISPC_SYSCONFIG_MIDLEMODE_MASK  0x3
-#define AMDM37X_DISPC_SYSCONFIG_MIDLEMODE_SHIFT  12
-
-	const ioport32_t sysstatus;
-#define AMDM37X_DISPC_SYSSTATUS_RESETDONE_FLAG  (1 << 0)
-
-	ioport32_t irqstatus;
-	ioport32_t irqenable;
-#define AMDM37X_DISPC_IRQ_FRAMEDONE_FLAG  (1 << 0)
-#define AMDM37X_DISPC_IRQ_VSYNC_FLAG  (1 << 1)
-#define AMDM37X_DISPC_IRQ_EVSYNCEVEN_FLAG  (1 << 2)
-#define AMDM37X_DISPC_IRQ_EVSYNCODD_FLAG  (1 << 3)
-#define AMDM37X_DISPC_IRQ_ACBIASCOUNTSTATUS_FLAG  (1 << 4)
-#define AMDM37X_DISPC_IRQ_PROGRAMMEDLINENUMBER_FLAG  (1 << 5)
-#define AMDM37X_DISPC_IRQ_GFXFIFOUNDERFLOW_FLAG  (1 << 6)
-#define AMDM37X_DISPC_IRQ_GFXENDWINDOW_FLAG  (1 << 7)
-#define AMDM37X_DISPC_IRQ_PALETTEGAMMALOADING_FLAG  (1 << 8)
-#define AMDM37X_DISPC_IRQ_OPCERROR_FLAG  (1 << 9)
-#define AMDM37X_DISPC_IRQ_VID1FIFOUNDERFLOW_FLAG  (1 << 10)
-#define AMDM37X_DISPC_IRQ_VID1ENDWINDOW_FLAG  (1 << 11)
-#define AMDM37X_DISPC_IRQ_VID2FIFOUNDERFLOW_FLAG  (1 << 12)
-#define AMDM37X_DISPC_IRQ_VID2ENDWINDOW_FLAG  (1 << 13)
-#define AMDM37X_DISPC_IRQ_SYNCLOST_FLAG  (1 << 14)
-#define AMDM37X_DISPC_IRQ_SYNCLOSTDIGITAL_FLAG  (1 << 15)
-#define AMDM37X_DISPC_IRQ_WAKEUP_FLAG  (1 << 16)
-
-	PADD32[8];
-	ioport32_t control;
-#define AMDM37X_DISPC_CONTROL_LCD_ENABLE_FLAG  (1 << 0)
-#define AMDM37X_DISPC_CONTROL_DIGITAL_ENABLE_FLAG  (1 << 1)
-#define AMDM37X_DISPC_CONTROL_MONOCOLOR_FLAG  (1 << 2)
-#define AMDM37X_DISPC_CONTROL_STNTFT_FLAG  (1 << 3)
-#define AMDM37X_DISPC_CONTROL_M8B_FLAG  (1 << 4)
-#define AMDM37X_DISPC_CONTROL_GOLCD_FLAG  (1 << 5)
-#define AMDM37X_DISPC_CONTROL_GODIGITAL_FLAG  (1 << 6)
-#define AMDM37X_DISPC_CONTROL_STDITHERENABLE_FLAG  (1 << 7)
-#define AMDM37X_DISPC_CONTROL_TFTDATALINES_MASK  0x3
-#define AMDM37X_DISPC_CONTROL_TFTDATALINES_SHIFT  8
-#define AMDM37X_DISPC_CONTROL_TFTDATALINES_12B  0
-#define AMDM37X_DISPC_CONTROL_TFTDATALINES_16B  1
-#define AMDM37X_DISPC_CONTROL_TFTDATALINES_18B  2
-#define AMDM37X_DISPC_CONTROL_TFTDATALINES_24B  3
-#define AMDM37X_DISPC_CONTROL_STALLMODE_FLAG  (1 << 11)
-#define AMDM37X_DISPC_CONTROL_OVERLAYOPTIMIZATION_FLAG  (1 << 12)
-#define AMDM37X_DISPC_CONTROL_GPIN0_FLAG  (1 << 13)
-#define AMDM37X_DISPC_CONTROL_GPIN1_FLAG  (1 << 14)
-#define AMDM37X_DISPC_CONTROL_GPOUT0_FLAG  (1 << 15)
-#define AMDM37X_DISPC_CONTROL_GPOUT1_FLAG  (1 << 16)
-#define AMDM37X_DISPC_CONTROL_HT_MASK  0x7
-#define AMDM37X_DISPC_CONTROL_HT_SHIFT  17
-#define AMDM37X_DISPC_CONTROL_TDMENABLE_FLAG  (1 << 20)
-#define AMDM37X_DISPC_CONTROL_TDMPARALLELMODE_MASK  0x3
-#define AMDM37X_DISPC_CONTROL_TDMPARELLELMODE_SHIFT  21
-#define AMDM37X_DISPC_CONTROL_TDMCYCLEFORMAT_MASK  0x3
-#define AMDM37X_DISPC_CONTROL_TDMCYCLEFORMAT_SHIFT  23
-#define AMDM37X_DISPC_CONTROL_TDMUNUSEDBITS_MASK  0x3
-#define AMDM37X_DISPC_CONTROL_TDMUNUSEDBITS_SHIFT  25
-#define AMDM37X_DISPC_CONTROL_PCKFREEENABLE_FLAG  (1 << 27)
-#define AMDM37X_DISPC_CONTROL_LCDENABLESIGNAL_FLAG  (1 << 28)
-#define AMDM37X_DISPC_CONTROL_KCDENABLEPOL_FLAG  (1 << 29)
-#define AMDM37X_DISPC_CONTROL_SPATIALTEMPORALDITHERINGFRAMES_MASK  0x3
-#define AMDM37X_DISPC_CONTROL_SPATIALTEMPORALDITHERINGFRAMES_SHIFT  30
-
-	ioport32_t config;
-#define AMDM37X_DISPC_CONFIG_PIXELGATED_FLAG  (1 << 0)
-#define AMDM37X_DISPC_CONFIG_LOADMODE_MASK  0x3
-#define AMDM37X_DISPC_CONFIG_LOADMODE_SHIFT  1
-#define AMDM37X_DISPC_CONFIG_LOADMODE_PGDATAEVERYFRAME  0x0
-#define AMDM37X_DISPC_CONFIG_LOADMODE_PGUSER  0x1
-#define AMDM37X_DISPC_CONFIG_LOADMODE_DATAEVERYFRAME  0x2
-#define AMDM37X_DISPC_CONFIG_LOADMODE_PGDFIRSTFRAME  0x3
-#define AMDM37X_DISPC_CONFIG_PALETTEGAMMATABLE_FLAG  (1 << 3)
-#define AMDM37X_DISPC_CONFIG_PIXELDATAGATED_FLAG  (1 << 4)
-#define AMDM37X_DISPC_CONFIG_PIXELCLOCKGATED_FLAG  (1 << 5)
-#define AMDM37X_DISPC_CONFIG_HSYNCGATED_FLAG  (1 << 6)
-#define AMDM37X_DISPC_CONFIG_VSYNCGATED_FLAG  (1 << 7)
-#define AMDM37X_DISPC_CONFIG_ACBIASGATED_FLAG  (1 << 8)
-#define AMDM37X_DISPC_CONFIG_FUNCGATED_FLAG  (1 << 9)
-#define AMDM37X_DISPC_CONFIG_TCKLCDENABLE_FLAG  (1 << 10)
-#define AMDM37X_DISPC_CONFIG_TCKLCDSELECTION_FLAG  (1 << 11)
-#define AMDM37X_DISPC_CONFIG_TCKDIGENABLE_FLAG  (1 << 12)
-#define AMDM37X_DISPC_CONFIG_TCKDIGSELECTION_FLAG  (1 << 13)
-#define AMDM37X_DISPC_CONFIG_FIFOMERGE_FLAG  (1 << 14)
-#define AMDM37X_DISPC_CONFIG_CPR_FLAG  (1 << 15)
-#define AMDM37X_DISPC_CONFIG_FIFOHANDCHECK_FLAG  (1 << 16)
-#define AMDM37X_DISPC_CONFIG_FIFOFILLING_FLAG  (1 << 17)
-#define AMDM37X_DISPC_CONFIG_LCDPALPHABLENDERENABLDE_FLAG  (1 << 18)
-#define AMDM37X_DISPC_CONFIG_TVALPHABLENDERENABLE_FLAG  (1 << 19)
-
-	PADD32[1];
-	ioport32_t default_color[2];
-	ioport32_t trans_color[2];
-#define AMDM37X_DISPC_COLOR_MASK 0xffffff
-
-	const ioport32_t line_status;
-	ioport32_t line_number;
-#define AMDM37X_DISPC_LINE_NUMBER_MASK 0x3ff
-
-	ioport32_t timing_h;
-#define AMDM37X_DISPC_TIMING_H_HSW_MASK 0xff
-#define AMDM37X_DISPC_TIMING_H_HSW_SHIFT 0
-#define AMDM37X_DISPC_TIMING_H_HFP_MASK 0xfff
-#define AMDM37X_DISPC_TIMING_H_HFP_SHIFT 8
-#define AMDM37X_DISPC_TIMING_H_HBP_MASK 0xfff
-#define AMDM37X_DISPC_TIMING_H_HBP_SHIFT 20
-
-	ioport32_t timing_v;
-#define AMDM37X_DISPC_TIMING_V_VSW_MASK 0xff
-#define AMDM37X_DISPC_TIMING_V_VSW_SHIFT 0
-#define AMDM37X_DISPC_TIMING_V_VFP_MASK 0xfff
-#define AMDM37X_DISPC_TIMING_V_VFP_SHIFT 8
-#define AMDM37X_DISPC_TIMING_V_VBP_MASK 0xfff
-#define AMDM37X_DISPC_TIMING_V_VBP_SHIFT 20
-
-	ioport32_t pol_freq;
-#define AMDM37X_DISPC_POL_FREQ_ACB_MASK  0xff
-#define AMDM37X_DISPC_POL_FREQ_ACB_SHIFT 0
-#define AMDM37X_DISPC_POL_FREQ_ACBI_MASK  0xf
-#define AMDM37X_DISPC_POL_FREQ_ACBI_SHIFT 8
-#define AMDM37X_DISPC_POL_FREQ_IVS_FLAG  (1 << 12)
-#define AMDM37X_DISPC_POL_FREQ_IHS_FLAG  (1 << 13)
-#define AMDM37X_DISPC_POL_FREQ_IPC_FLAG  (1 << 14)
-#define AMDM37X_DISPC_POL_FREQ_IEO_FLAG  (1 << 15)
-#define AMDM37X_DISPC_POL_FREQ_RF_FLAG  (1 << 16)
-#define AMDM37X_DISPC_POL_FREQ_ONOFF_FLAG  (1 << 17)
-
-	ioport32_t divisor;
-#define AMDM37X_DISPC_DIVISOR_PCD_MASK  0xff
-#define AMDM37X_DISPC_DIVISOR_PCD_SHIFT  0
-#define AMDM37X_DISPC_DIVISOR_LCD_MASK  0xff
-#define AMDM37X_DISPC_DIVISOR_LCD_SHIFT  16
-
-	ioport32_t global_alpha;
-#define AMDM37X_DISPC_GLOBAL_ALPHA_GFXGLOBALALPHA_MASK  0xff
-#define AMDM37X_DISPC_GLOBAL_ALPHA_GFXGLOBALALPHA_SHIFT  0
-#define AMDM37X_DISPC_GLOBAL_ALPHA_VID2GLOBALALPHA_MASK  0xff
-#define AMDM37X_DISPC_GLOBAL_ALPHA_VID2GLOBALALPHA_SHIFT  16
-
-	ioport32_t size_dig;
-	ioport32_t size_lcd;
-
-	struct {
-		ioport32_t ba[2];
-		ioport32_t position;
-#define AMDM37X_DISPC_GFX_POSITION_GFXPOSX_MASK  0x7ff
-#define AMDM37X_DISPC_GFX_POSITION_GFXPOSX_SHIFT  0
-#define AMDM37X_DISPC_GFX_POSITION_GFXPOSY_MASK  0x7ff
-#define AMDM37X_DISPC_GFX_POSITION_GFXPOSY_SHIFT  16
-
-		ioport32_t size;
-#define AMDM37X_DISPC_SIZE_WIDTH_MASK  0x7ff
-#define AMDM37X_DISPC_SIZE_WIDTH_SHIFT  0
-#define AMDM37X_DISPC_SIZE_HEIGHT_MASK  0x7ff
-#define AMDM37X_DISPC_SIZE_HEIGHT_SHIFT  16
-
-		PADD32[4];
-		ioport32_t attributes;
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_ENABLE_FLAG  (1 << 0)
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_MASK  0xf
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_SHIFT  1
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_ARGB16  0x5
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_RGB16  0x6
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_RGB24_32  0x8
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_RGB24  0x9
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_ARGB  0xc
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_RGBA  0xd
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_FORMAT_RGBX  0xe
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_REPLICATIONENABLE_FLAG  (1 << 5)
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXBURSTSIZE_MASK  0x3
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXBURSTSIZE_SHIFT  6
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXCHANNELOUT_FLAG  (1 << 8)
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXNIBBLEMODE_FLAG  (1 << 9)
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXENDIANNES_FLAG  (1 << 10)
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXFIFOPRELOAD_FLAG  (1 << 11)
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXROTATION_MASK  0x3
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXROTATION_SHIFT  12
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXARBITRATION_FLAG  (1 << 14)
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_GFXSELFREFRESH_FLAG  (1 << 15)
-#define AMDM37X_DISPC_GFX_ATTRIBUTES_PREMULTIALPHA_FLAG  (1 << 28)
-
-
-		ioport32_t fifo_threshold;
-		const ioport32_t fifo_size_status;
-		ioport32_t row_inc;
-		ioport32_t pixel_inc;
-		ioport32_t window_skip;
-		ioport32_t table_ba;
-	} gfx;
-
-	struct {
-		ioport32_t ba[2];
-		ioport32_t position;
-		ioport32_t size;
-		ioport32_t attributes;
-		ioport32_t fifo_threshold;
-		const ioport32_t fifo_size_status;
-		ioport32_t row_inc;
-		ioport32_t pixel_inc;
-		ioport32_t fir;
-		ioport32_t picture_size;
-		ioport32_t accui[2];
-		struct {
-			ioport32_t hi;
-			ioport32_t hvi;
-		} fir_coef[8];
-		ioport32_t conv_coef[5];
-		PADD32[2];
-	} vid[2];
-	/* 0x1d4 */
-	ioport32_t data_cycle[3];
-	/* 0x1e0 */
-	ioport32_t vid_fir_coef_v[8];
-	/* 0x200 */
-	PADD32[8];
-	/* 0x220 */
-	ioport32_t cpr_coef_r;
-	ioport32_t cpr_coef_g;
-	ioport32_t cpr_coef_b;
-	ioport32_t gfx_preload;
-
-	/* 0x230 */
-	ioport32_t vid_preload[2];
-
-} amdm37x_dispc_regs_t;
-
-
-#endif
-/**
- * @}
- */
Index: pace/drv/fb/amdm37x_dispc/main.c
===================================================================
--- uspace/drv/fb/amdm37x_dispc/main.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,124 +1,0 @@
-/*
- * Copyright (c) 2013 Jan Vesely
- * Copyright (c) 2011 Petr Koupy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup amdm37x
- * @{
- */
-/**
- * @file
- */
-
-#include <ddf/log.h>
-#include <errno.h>
-#include <str_error.h>
-#include <stdio.h>
-#include <ops/graph_dev.h>
-#include <graph.h>
-
-#include "amdm37x_dispc.h"
-
-#define NAME  "amdm37x_dispc"
-
-static graph_dev_ops_t graph_vsl_dev_ops = {
-	.connect = (connect_func) &graph_visualizer_connection
-};
-
-static ddf_dev_ops_t graph_fun_ops = {
-	.interfaces[GRAPH_DEV_IFACE] = &graph_vsl_dev_ops
-};
-
-static int amdm37x_dispc_dev_add(ddf_dev_t *dev)
-{
-	assert(dev);
-	/* Visualizer part */
-	ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "viz");
-	if (!fun) {
-		ddf_log_error("Failed to create visualizer function\n");
-		return ENOMEM;
-	}
-
-	visualizer_t *vis = ddf_fun_data_alloc(fun, sizeof(visualizer_t));
-	if (!vis) {
-		ddf_log_error("Failed to allocate visualizer structure\n");
-		ddf_fun_destroy(fun);
-		return ENOMEM;
-	}
-
-	graph_init_visualizer(vis);
-	vis->reg_svc_handle = ddf_fun_get_handle(fun);
-
-	ddf_fun_set_ops(fun, &graph_fun_ops);
-	/* Hw part */
-	amdm37x_dispc_t *dispc =
-	    ddf_dev_data_alloc(dev, sizeof(amdm37x_dispc_t));
-	if (!dispc) {
-		ddf_log_error("Failed to allocate dispc structure\n");
-		ddf_fun_destroy(fun);
-		return ENOMEM;
-	}
-
-	int ret = amdm37x_dispc_init(dispc, vis);
-	if (ret != EOK) {
-		ddf_log_error("Failed to init dispc: %s\n", str_error(ret));
-		ddf_fun_destroy(fun);
-		return ret;
-	}
-
-	/* Report to devman */
-	ret = ddf_fun_bind(fun);
-	if (ret != EOK) {
-		ddf_log_error("Failed to bind function: %s\n", str_error(ret));
-		amdm37x_dispc_fini(dispc);
-		ddf_fun_destroy(fun);
-		return ret;
-	}
-	ddf_fun_add_to_category(fun, "visualizer");
-
-	ddf_log_note("Added device `%s'\n", ddf_dev_get_name(dev));
-	return EOK;
-}
-
-static driver_ops_t amdm37x_dispc_driver_ops = {
-	.dev_add = amdm37x_dispc_dev_add,
-};
-
-static driver_t amdm37x_dispc_driver = {
-	.name = NAME,
-	.driver_ops = &amdm37x_dispc_driver_ops
-};
-
-int main(int argc, char *argv[])
-{
-	printf("%s: HelenOS AM/DM37x framebuffer driver\n", NAME);
-	ddf_log_init(NAME);
-	return ddf_driver_main(&amdm37x_dispc_driver);
-}
-
-/** @}
- */
Index: uspace/drv/fb/kfb/port.c
===================================================================
--- uspace/drv/fb/kfb/port.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/fb/kfb/port.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -163,7 +163,7 @@
 		/* Faster damage routine ignoring offsets. */
 		for (sysarg_t y = y0; y < height + y0; ++y) {
-			pixel_t *pixel = pixelmap_pixel_at(map, x0, y);
 			for (sysarg_t x = x0; x < width + x0; ++x) {
-				kfb.pixel2visual(kfb.addr + FB_POS(x, y), *pixel++);
+				kfb.pixel2visual(kfb.addr + FB_POS(x, y),
+				    *pixelmap_pixel_at(map, x, y));
 			}
 		}
Index: uspace/drv/infrastructure/root/root.c
===================================================================
--- uspace/drv/infrastructure/root/root.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/infrastructure/root/root.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 #include <stdio.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <stdlib.h>
Index: pace/drv/infrastructure/rootamdm37x/Makefile
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/Makefile	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,237 +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 {
-	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
-
-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 const rootamdm37x_fun_t ohci = {
-	.hw_resources = {
-	    .resources = ohci_res,
-	    .count = sizeof(ohci_res)/sizeof(ohci_res[0]),
-	}
-};
-
-static const rootamdm37x_fun_t ehci = {
-	.hw_resources = {
-	    .resources = ehci_res,
-	    .count = sizeof(ehci_res) / sizeof(ehci_res[0]),
-	}
-};
-
-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 char *name,
-    const char *str_match_id, const rootamdm37x_fun_t *fun)
-{
-	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
-	
-	/* Create new device function. */
-	ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, name);
-	if (fnode == NULL)
-		return ENOMEM;
-	
-	/* Add match id */
-	int ret = ddf_fun_add_match_id(fnode, str_match_id, 100);
-	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.", 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 */
-	if (rootamdm37x_add_fun(dev, "ohci", "usb/host=ohci", &ohci) != EOK)
-		ddf_msg(LVL_ERROR, "Failed to add OHCI function for "
-		    "BeagleBoard-xM platform.");
-	if (rootamdm37x_add_fun(dev, "ehci", "usb/host=ehci", &ehci) != EOK)
-		ddf_msg(LVL_ERROR, "Failed to add EHCI function for "
-		    "BeagleBoard-xM platform.");
-	if (rootamdm37x_add_fun(dev, "dispc", "amdm37x&dispc", &ehci) != EOK)
-		ddf_msg(LVL_ERROR, "Failed to add dispc function for "
-		    "BeagleBoard-xM platform.");
-
-	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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 platform/beagleboardxm
Index: pace/drv/infrastructure/rootamdm37x/uhh.h
===================================================================
--- uspace/drv/infrastructure/rootamdm37x/uhh.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(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: uspace/drv/infrastructure/rootpc/rootpc.c
===================================================================
--- uspace/drv/infrastructure/rootpc/rootpc.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/infrastructure/rootpc/rootpc.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <stdio.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <stdlib.h>
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/nic/e1k/e1k.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -45,5 +45,5 @@
 #include <ipc/irc.h>
 #include <ipc/ns.h>
-#include <ddi.h>
+#include <libarch/ddi.h>
 #include <as.h>
 #include <ddf/log.h>
Index: uspace/drv/nic/ne2k/dp8390.c
===================================================================
--- uspace/drv/nic/ne2k/dp8390.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/nic/ne2k/dp8390.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -58,5 +58,5 @@
 #include <errno.h>
 #include <stdio.h>
-#include <ddi.h>
+#include <libarch/ddi.h>
 #include "dp8390.h"
 
Index: uspace/drv/nic/rtl8139/defs.h
===================================================================
--- uspace/drv/nic/rtl8139/defs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/nic/rtl8139/defs.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 
 #include <sys/types.h>
-#include <ddi.h>
+#include <libarch/ddi.h>
 
 /** Size of RTL8139 registers address space */
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/nic/rtl8139/driver.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,4 +34,5 @@
 #include <align.h>
 #include <byteorder.h>
+#include <libarch/ddi.h>
 #include <libarch/barrier.h>
 
Index: uspace/drv/time/cmos-rtc/cmos-rtc.c
===================================================================
--- uspace/drv/time/cmos-rtc/cmos-rtc.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/drv/time/cmos-rtc/cmos-rtc.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,4 +40,5 @@
 #include <as.h>
 #include <sysinfo.h>
+#include <libarch/ddi.h>
 #include <libarch/barrier.h>
 #include <stdio.h>
@@ -99,6 +100,4 @@
 static time_t uptime_get(void);
 static bool is_battery_ok(rtc_t *rtc);
-static int  rtc_fun_online(ddf_fun_t *fun);
-static int  rtc_fun_offline(ddf_fun_t *fun);
 
 static ddf_dev_ops_t rtc_dev_ops;
@@ -108,6 +107,4 @@
 	.dev_add = rtc_dev_add,
 	.dev_remove = rtc_dev_remove,
-	.fun_online = rtc_fun_online,
-	.fun_offline = rtc_fun_offline,
 };
 
@@ -409,16 +406,10 @@
 	/* Try to normalize the content of the tm structure */
 	time_t r = mktime(t);
-	int result;
-
-	if (r < 0)
-		result = EINVAL;
-	else {
-		rtc->boottime = r - uptime_get();
-		result = EOK;
-	}
+
+	rtc->boottime = r - uptime_get();
 
 	fibril_mutex_unlock(&rtc->mutex);
 
-	return result;
+	return r < 0 ? EINVAL : EOK;
 }
 
@@ -647,10 +638,4 @@
 	fibril_mutex_unlock(&rtc->mutex);
 
-	rc = rtc_fun_offline(rtc->fun);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed to offline function");
-		return rc;
-	}
-
 	rc = ddf_fun_unbind(rtc->fun);
 	if (rc != EOK) {
@@ -741,25 +726,4 @@
 }
 
-static int
-rtc_fun_online(ddf_fun_t *fun)
-{
-	int rc;
-
-	ddf_msg(LVL_DEBUG, "rtc_fun_online()");
-
-	rc = ddf_fun_online(fun);
-	if (rc == EOK)
-		ddf_fun_add_to_category(fun, "clock");
-
-	return rc;
-}
-
-static int
-rtc_fun_offline(ddf_fun_t *fun)
-{
-	ddf_msg(LVL_DEBUG, "rtc_fun_offline()");
-	return ddf_fun_offline(fun);
-}
-
 int
 main(int argc, char **argv)
Index: uspace/lib/bithenge/src/helenos/common.h
===================================================================
--- uspace/lib/bithenge/src/helenos/common.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/bithenge/src/helenos/common.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -31,5 +31,5 @@
 
 #include <bithenge/os.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <byteorder.h>
 #include <errno.h>
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -113,7 +113,4 @@
 	generic/iplink.c \
 	generic/iplink_srv.c \
-	generic/ieee_double.c \
-	generic/power_of_ten.c \
-	generic/double_to_str.c \
 	generic/malloc.c \
 	generic/sysinfo.c \
@@ -137,11 +134,9 @@
 	generic/net/socket_client.c \
 	generic/net/socket_parse.c \
-	generic/stack.c \
 	generic/stacktrace.c \
 	generic/arg_parse.c \
 	generic/sort.c \
 	generic/stats.c \
-	generic/assert.c \
-	generic/pio_trace.c
+	generic/assert.c
 
 ifeq ($(CONFIG_RTLD),y)
Index: uspace/lib/c/arch/abs32le/include/libarch/atomic.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/libarch/atomic.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/abs32le/include/libarch/atomic.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 #define LIBC_abs32le_ATOMIC_H_
 
-#include <stdbool.h>
+#include <bool.h>
 
 #define LIBC_ARCH_ATOMIC_H_
Index: uspace/lib/c/arch/abs32le/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/libarch/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/abs32le/include/libarch/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,30 +36,30 @@
 #include <libarch/types.h>
 
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+static inline void pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+static inline void pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+static inline void pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+static inline uint8_t pio_read_8(ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+static inline uint16_t pio_read_16(ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+static inline uint32_t pio_read_32(ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/abs32le/src/entryjmp.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/entryjmp.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/abs32le/src/entryjmp.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -30,5 +30,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <entry_point.h>
 
Index: uspace/lib/c/arch/abs32le/src/fibril.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/fibril.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/abs32le/src/fibril.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -31,5 +31,5 @@
 
 #include <fibril.h>
-#include <stdbool.h>
+#include <bool.h>
 
 int context_save(context_t *ctx)
Index: uspace/lib/c/arch/abs32le/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/abs32le/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -32,5 +32,5 @@
 #include <sys/types.h>
 #include <unistd.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <stacktrace.h>
 
Index: uspace/lib/c/arch/abs32le/src/tls.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/abs32le/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,10 +34,10 @@
 #include <unistd.h>
 
-tcb_t * tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_2(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_2(tcb, size);
Index: uspace/lib/c/arch/amd64/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/amd64/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/amd64/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <stacktrace.h>
Index: uspace/lib/c/arch/amd64/src/tls.c
===================================================================
--- uspace/lib/c/arch/amd64/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/amd64/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,10 +38,10 @@
 #include <sys/types.h>
 
-tcb_t *tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_2(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_2(tcb, size);
Index: uspace/lib/c/arch/arm32/Makefile.common
===================================================================
--- uspace/lib/c/arch/arm32/Makefile.common	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/arm32/Makefile.common	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -28,11 +28,6 @@
 #
 
-GCC_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR_ARCH))
-
-ifeq ($(CONFIG_FPU),y)
-GCC_CFLAGS += -mfloat-abi=hard
-else
 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
-endif
+GCC_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -march=armv4 -mapcs-frame
 
 ENDIANESS = LE
Index: uspace/lib/c/arch/arm32/include/libarch/atomic.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/atomic.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/arm32/include/libarch/atomic.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 
 #include <atomicdflt.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 
Index: pace/lib/c/arch/arm32/include/libarch/cp15.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/cp15.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/arm32/include/arch/cp15.h
Index: uspace/lib/c/arch/arm32/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/arm32/include/libarch/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,30 +37,30 @@
 #include <libarch/types.h>
 
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+static inline void pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+static inline void pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+static inline void pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+static inline uint8_t pio_read_8(ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+static inline uint16_t pio_read_16(ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+static inline uint32_t pio_read_32(ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/arm32/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/arm32/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/arm32/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <stacktrace.h>
Index: uspace/lib/c/arch/arm32/src/tls.c
===================================================================
--- uspace/lib/c/arch/arm32/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/arm32/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,10 +38,10 @@
 #include <sys/types.h>
 
-tcb_t *tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_1(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_1(tcb, size);
Index: uspace/lib/c/arch/ia32/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ia32/include/libarch/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #define IO_SPACE_BOUNDARY  ((void *) (64 * 1024))
 
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+static inline uint8_t pio_read_8(ioport8_t *port)
 {
 	if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
@@ -55,5 +55,5 @@
 }
 
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+static inline uint16_t pio_read_16(ioport16_t *port)
 {
 	if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
@@ -71,5 +71,5 @@
 }
 
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+static inline uint32_t pio_read_32(ioport32_t *port)
 {
 	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
@@ -87,5 +87,5 @@
 }
 
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t val)
+static inline void pio_write_8(ioport8_t *port, uint8_t val)
 {
 	if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
@@ -98,5 +98,5 @@
 }
 
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t val)
+static inline void pio_write_16(ioport16_t *port, uint16_t val)
 {
 	if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
@@ -109,5 +109,5 @@
 }
 
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t val)
+static inline void pio_write_32(ioport32_t *port, uint32_t val)
 {
 	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
Index: uspace/lib/c/arch/ia32/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/ia32/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ia32/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 #include <libarch/config.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <stacktrace.h>
 
Index: uspace/lib/c/arch/ia32/src/tls.c
===================================================================
--- uspace/lib/c/arch/ia32/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ia32/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,10 +39,10 @@
 #include <align.h>
 
-tcb_t *tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_2(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_2(tcb, size);
Index: uspace/lib/c/arch/ia64/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ia64/include/libarch/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -50,5 +50,5 @@
 	    (ia64_iospace_address = get_ia64_iospace_address()))
 
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+static inline void pio_write_8(ioport8_t *port, uint8_t v)
 {
 	if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
@@ -65,5 +65,5 @@
 }
 
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+static inline void pio_write_16(ioport16_t *port, uint16_t v)
 {
 	if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
@@ -80,5 +80,5 @@
 }
 
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+static inline void pio_write_32(ioport32_t *port, uint32_t v)
 {
 	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
@@ -95,5 +95,5 @@
 }
 
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+static inline uint8_t pio_read_8(ioport8_t *port)
 {
 	uint8_t v;
@@ -115,5 +115,5 @@
 }
 
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+static inline uint16_t pio_read_16(ioport16_t *port)
 {
 	uint16_t v;
@@ -135,5 +135,5 @@
 }
 
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+static inline uint32_t pio_read_32(ioport32_t *port)
 {
 	uint32_t v;
Index: uspace/lib/c/arch/ia64/src/ddi.c
===================================================================
--- uspace/lib/c/arch/ia64/src/ddi.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ia64/src/ddi.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,29 +1,2 @@
-/*
- * 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 <libarch/ddi.h>
 #include <sysinfo.h>
@@ -39,2 +12,3 @@
 	return addr;
 }
+
Index: uspace/lib/c/arch/ia64/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/ia64/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ia64/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 
Index: uspace/lib/c/arch/ia64/src/tls.c
===================================================================
--- uspace/lib/c/arch/ia64/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ia64/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,10 +38,10 @@
 #include <malloc.h>
 
-tcb_t *tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_1(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_1(tcb, size);
Index: uspace/lib/c/arch/mips32/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/mips32/include/libarch/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,30 +37,30 @@
 #include <libarch/types.h>
 
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+static inline void pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+static inline void pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+static inline void pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+static inline uint8_t pio_read_8(ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+static inline uint16_t pio_read_16(ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+static inline uint32_t pio_read_32(ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/mips32/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/mips32/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/mips32/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 
Index: uspace/lib/c/arch/mips32/src/tls.c
===================================================================
--- uspace/lib/c/arch/mips32/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/mips32/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,10 +37,10 @@
 #include <sys/types.h>
 
-tcb_t * tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_1(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_1(tcb, size);
Index: uspace/lib/c/arch/mips64/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/mips64/include/libarch/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,30 +37,30 @@
 #include <libarch/types.h>
 
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+static inline void pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+static inline void pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+static inline void pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+static inline uint8_t pio_read_8(ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+static inline uint16_t pio_read_16(ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+static inline uint32_t pio_read_32(ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/mips64/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/mips64/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/mips64/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 
Index: uspace/lib/c/arch/mips64/src/tls.c
===================================================================
--- uspace/lib/c/arch/mips64/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/mips64/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,10 +37,10 @@
 #include <sys/types.h>
 
-tcb_t *tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_1(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_1(tcb, size);
Index: uspace/lib/c/arch/ppc32/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ppc32/include/libarch/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,30 +37,30 @@
 #include <libarch/types.h>
 
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+static inline void pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+static inline void pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
 }
 
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+static inline void pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
 }
 
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+static inline uint8_t pio_read_8(ioport8_t *port)
 {
 	return *port;
 }
 
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+static inline uint16_t pio_read_16(ioport16_t *port)
 {
 	return *port;
 }
 
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+static inline uint32_t pio_read_32(ioport32_t *port)
 {
 	return *port;
Index: uspace/lib/c/arch/ppc32/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/ppc32/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ppc32/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <stacktrace.h>
Index: uspace/lib/c/arch/ppc32/src/tls.c
===================================================================
--- uspace/lib/c/arch/ppc32/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/ppc32/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,10 +36,10 @@
 #include <sys/types.h>
 
-tcb_t *tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_1(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_1(tcb, size);
Index: uspace/lib/c/arch/sparc64/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/sparc64/include/libarch/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -45,5 +45,5 @@
 }
 
-static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+static inline void pio_write_8(ioport8_t *port, uint8_t v)
 {
 	*port = v;
@@ -51,5 +51,5 @@
 }
 
-static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+static inline void pio_write_16(ioport16_t *port, uint16_t v)
 {
 	*port = v;
@@ -57,5 +57,5 @@
 }
 
-static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+static inline void pio_write_32(ioport32_t *port, uint32_t v)
 {
 	*port = v;
@@ -63,5 +63,5 @@
 }
 
-static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+static inline uint8_t pio_read_8(ioport8_t *port)
 {
 	uint8_t rv;
@@ -73,5 +73,5 @@
 }
 
-static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+static inline uint16_t pio_read_16(ioport16_t *port)
 {
 	uint16_t rv;
@@ -83,5 +83,5 @@
 }
 
-static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+static inline uint32_t pio_read_32(ioport32_t *port)
 {
 	uint32_t rv;
Index: uspace/lib/c/arch/sparc64/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/sparc64/src/stacktrace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/sparc64/src/stacktrace.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <libarch/stack.h>
 #include <errno.h>
Index: uspace/lib/c/arch/sparc64/src/tls.c
===================================================================
--- uspace/lib/c/arch/sparc64/src/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/arch/sparc64/src/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,10 +38,10 @@
 #include <sys/types.h>
 
-tcb_t *tls_alloc_arch(void **data, size_t size)
+tcb_t * __alloc_tls(void **data, size_t size)
 {
 	return tls_alloc_variant_2(data, size);
 }
 
-void tls_free_arch(tcb_t *tcb, size_t size)
+void __free_tls_arch(tcb_t *tcb, size_t size)
 {
 	tls_free_variant_2(tcb, size);
Index: uspace/lib/c/generic/adt/list.c
===================================================================
--- uspace/lib/c/generic/adt/list.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/adt/list.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 
 #include <adt/list.h>
-#include <stdbool.h>
+#include <bool.h>
 
 /** Check for membership
Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/async.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -109,5 +109,5 @@
 #include <sys/time.h>
 #include <libarch/barrier.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <malloc.h>
 #include <mem.h>
Index: uspace/lib/c/generic/ddi.c
===================================================================
--- uspace/lib/c/generic/ddi.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/ddi.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,7 +34,5 @@
 
 #include <assert.h>
-#include <atomic.h>
 #include <unistd.h>
-#include <stdio.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -48,5 +46,4 @@
 #include <libarch/config.h>
 #include "private/libc.h"
-
 
 /** Return unique device number.
@@ -123,11 +120,11 @@
  *
  */
-static int iospace_enable(task_id_t id, void *ioaddr, size_t size)
+int iospace_enable(task_id_t id, void *ioaddr, unsigned long size)
 {
-	const ddi_ioarg_t arg = {
-		.task_id = id,
-		.ioaddr = ioaddr,
-		.size = size
-	};
+	ddi_ioarg_t arg;
+	
+	arg.task_id = id;
+	arg.ioaddr = ioaddr;
+	arg.size = size;
 	
 	return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
@@ -139,5 +136,5 @@
  * @param size     Size of the I/O region.
  * @param virt     Virtual address for application's
- *                 PIO operations. Can be NULL for PMIO.
+ *                 PIO operations.
  *
  * @return EOK on success.
@@ -149,14 +146,9 @@
 #ifdef IO_SPACE_BOUNDARY
 	if (pio_addr < IO_SPACE_BOUNDARY) {
-		if (virt)
-			*virt = pio_addr;
+		*virt = pio_addr;
 		return iospace_enable(task_get_id(), pio_addr, size);
 	}
-#else
-	(void) iospace_enable;
 #endif
-	if (!virt)
-		return EINVAL;
-
+	
 	void *phys_frame =
 	    (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
@@ -172,43 +164,4 @@
 	*virt = virt_page + offset;
 	return EOK;
-}
-
-void pio_write_8(ioport8_t *reg, uint8_t val)
-{
-	pio_trace_log(reg, val, true);
-	arch_pio_write_8(reg, val);
-}
-
-void pio_write_16(ioport16_t *reg, uint16_t val)
-{
-	pio_trace_log(reg, val, true);
-	arch_pio_write_16(reg, val);
-}
-
-void pio_write_32(ioport32_t *reg, uint32_t val)
-{
-	pio_trace_log(reg, val, true);
-	arch_pio_write_32(reg, val);
-}
-
-uint8_t pio_read_8(const ioport8_t *reg)
-{
-	const uint8_t val = arch_pio_read_8(reg);
-	pio_trace_log(reg, val, false);
-	return val;
-}
-
-uint16_t pio_read_16(const ioport16_t *reg)
-{
-	const uint16_t val = arch_pio_read_16(reg);
-	pio_trace_log(reg, val, false);
-	return val;
-}
-
-uint32_t pio_read_32(const ioport32_t *reg)
-{
-	const uint32_t val = arch_pio_read_32(reg);
-	pio_trace_log(reg, val, false);
-	return val;
 }
 
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/devman.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -45,5 +45,5 @@
 #include <errno.h>
 #include <malloc.h>
-#include <stdbool.h>
+#include <bool.h>
 
 static FIBRIL_MUTEX_INITIALIZE(devman_driver_block_mutex);
Index: pace/lib/c/generic/double_to_str.c
===================================================================
--- uspace/lib/c/generic/double_to_str.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,785 +1,0 @@
-/*
- * Copyright (c) 2012 Adam Hraska
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 <double_to_str.h>
-
-#include "private/power_of_ten.h"
-#include <ieee_double.h>
-
-#include <stdint.h>
-#include <assert.h>
-#include <stdbool.h>
-
-/*
- * Floating point numbers are converted from their binary representation
- * into a decimal string using the algorithm described in:
- *   Printing floating-point numbers quickly and accurately with integers
- *   Loitsch, 2010
- */
-
-/** The computation assumes a significand of 64 bits. */
-static const int significand_width = 64;
-
-/* Scale exponents to interval [alpha, gamma] to simplify conversion. */
-static const int alpha = -59;
-static const int gamma = -32;
-
-
-/** Returns true if the most-significant bit of num.significand is set. */
-static bool is_normalized(fp_num_t num)
-{
-	assert(8*sizeof(num.significand) == significand_width);
-
-	/* Normalized == most significant bit of the significand is set. */
-	return (num.significand & (1ULL << (significand_width - 1))) != 0;
-}
-
-/** Returns a normalized num with the MSbit set. */
-static fp_num_t normalize(fp_num_t num)
-{
-	const uint64_t top10bits = 0xffc0000000000000ULL;
-
-	/* num usually comes from ieee_double with top 10 bits zero. */
-	while (0 == (num.significand & top10bits)) {
-		num.significand <<= 10;
-		num.exponent -= 10;
-	}
-
-	while (!is_normalized(num)) {
-		num.significand <<= 1;
-		--num.exponent;
-	}
-
-	return num;
-}
-
-
-/** Returns x * y with an error of less than 0.5 ulp. */
-static fp_num_t multiply(fp_num_t x, fp_num_t y)
-{
-	assert(/* is_normalized(x) && */ is_normalized(y));
-	
-	const uint32_t low_bits = -1;
-
-	uint64_t a, b, c, d;
-	a = x.significand >> 32;
-	b = x.significand & low_bits;
-	c = y.significand >> 32;
-	d = y.significand & low_bits;
-
-	uint64_t bd, ad, bc, ac;
-	bd = b * d;
-	ad = a * d;
-	
-	bc = b * c;
-	ac = a * c;
-
-	/* Denote 32 bit parts of x a y as: x == a b, y == c d. Then:
-	 *        a  b    
-	 *  *     c  d
-	 *  ----------
-	 *       ad bd .. multiplication of 32bit parts results in 64bit parts
-	 *  + ac bc
-	 *  ----------
-	 *       [b|d] .. Depicts 64 bit intermediate results and how
-	 *     [a|d]      the 32 bit parts of these results overlap and
-	 *     [b|c]      contribute to the final result.
-	 *  +[a|c]
-	 *  ----------
-	 *   [ret]
-	 *  [tmp]
-	 */
-	uint64_t tmp = (bd >> 32) + (ad & low_bits) + (bc & low_bits);
-
-	/* Round upwards. */
-	tmp += 1U << 31;
-
-	fp_num_t ret;
-	ret.significand = ac + (bc >> 32) + (ad >> 32) + (tmp >> 32);
-	ret.exponent = x.exponent + y.exponent + significand_width;
-	
-	return ret;			
-}
-
-
-/** Returns a - b. Both must have the same exponent. */
-static fp_num_t subtract(fp_num_t a, fp_num_t b)
-{
-	assert(a.exponent == b.exponent);
-	assert(a.significand >= b.significand);
-
-	fp_num_t result;
-	
-	result.significand = a.significand - b.significand;
-	result.exponent = a.exponent;
-
-	return result;
-}
-
-
-/** Returns the interval [low, high] of numbers that convert to binary val. */
-static void get_normalized_bounds(ieee_double_t val, fp_num_t *high, 
-	fp_num_t *low, fp_num_t *val_dist)
-{
-	/* 
-	 * Only works if val comes directly from extract_ieee_double without
-	 * being manipulated in any way (eg it must not be normalized). 
-	 */
-	assert(!is_normalized(val.pos_val));
-
-	high->significand = (val.pos_val.significand << 1) + 1;
-	high->exponent = val.pos_val.exponent - 1;
-
-	/* val_dist = high - val */
-	val_dist->significand = 1;
-	val_dist->exponent = val.pos_val.exponent - 1;
-
-	/* Distance from both lower and upper bound is the same. */
-	if (!val.is_accuracy_step) {
-		low->significand = (val.pos_val.significand << 1) - 1;
-		low->exponent = val.pos_val.exponent - 1;
-	} else {
-		low->significand = (val.pos_val.significand << 2) - 1;
-		low->exponent = val.pos_val.exponent - 2;
-	}
-
-	*high = normalize(*high);
-
-	/* 
-	 * Lower bound may not be normalized if subtracting 1 unit
-	 * reset the most-significant bit to 0. 
-	 */
-	low->significand = low->significand << (low->exponent - high->exponent);
-	low->exponent = high->exponent;
-
-	val_dist->significand = 
-		val_dist->significand << (val_dist->exponent - high->exponent);
-	val_dist->exponent = high->exponent;
-}
-
-/** Determines the interval of numbers that have the binary representation 
- *  of val.
- * 
- * Numbers in the range [scaled_upper_bound - bounds_delta, scaled_upper_bound]
- * have the same double binary representation as val. 
- *
- * Bounds are scaled by 10^scale so that alpha <= exponent <= gamma.
- * Moreover, scaled_upper_bound is normalized.
- *
- * val_dist is the scaled distance from val to the upper bound, ie
- * val_dist == (upper_bound - val) * 10^scale
- */
-static void calc_scaled_bounds(ieee_double_t val, fp_num_t *scaled_upper_bound, 
-	fp_num_t *bounds_delta, fp_num_t *val_dist, int *scale)
-{
-	fp_num_t upper_bound, lower_bound;
-
-	get_normalized_bounds(val, &upper_bound, &lower_bound, val_dist);
-
-	assert(upper_bound.exponent == lower_bound.exponent);
-	assert(is_normalized(upper_bound));
-	assert(normalize(val.pos_val).exponent == upper_bound.exponent);
-
-	/* 
-	 * Find such a cached normalized power of 10 that if multiplied
-	 * by upper_bound the binary exponent of upper_bound almost vanishes, 
-	 * ie:
-	 *   upper_scaled := upper_bound * 10^scale
-	 *   alpha <= upper_scaled.exponent <= gamma
-	 *   alpha <= upper_bound.exponent + pow_10.exponent + 64 <= gamma
-	 */
-	fp_num_t scaling_power_of_10;
-	int lower_bin_exp = alpha - upper_bound.exponent - significand_width;
-
-	get_power_of_ten(lower_bin_exp, &scaling_power_of_10, scale);
-
-	int scale_exp = scaling_power_of_10.exponent;
-	assert(alpha <= upper_bound.exponent + scale_exp + significand_width);
-	assert(upper_bound.exponent + scale_exp + significand_width <= gamma);
-
-	fp_num_t upper_scaled = multiply(upper_bound, scaling_power_of_10);
-	fp_num_t lower_scaled = multiply(lower_bound, scaling_power_of_10);
-	*val_dist = multiply(*val_dist, scaling_power_of_10);
-
-	assert(alpha <= upper_scaled.exponent && upper_scaled.exponent <= gamma);
-
-	/* 
-	 * Any value between lower and upper bound would be represented
-	 * in binary as the double val originated from. The bounds were
-	 * however scaled by an imprecise power of 10 (error less than 
-	 * 1 ulp) so the scaled bounds have an error of less than 1 ulp. 
-	 * Conservatively round the lower bound up and the upper bound 
-	 * down by 1 ulp just to be on the safe side. It avoids pronouncing
-	 * produced decimal digits as correct if such a decimal number
-	 * is close to the bounds to within 1 ulp. 
-	 */
-	upper_scaled.significand -= 1;
-	lower_scaled.significand += 1;
-
-	*bounds_delta = subtract(upper_scaled, lower_scaled);
-	*scaled_upper_bound = upper_scaled;
-}
-
-
-/** Rounds the last digit of buf so that it is closest to the converted number.*/
-static void round_last_digit(uint64_t rest, uint64_t w_dist, uint64_t delta,
-	uint64_t digit_val_diff, char *buf, int len)
-{
-	/*
-	 *  | <------- delta -------> |
-	 *  |    | <---- w_dist ----> |
-	 *  |    |       | <- rest -> |
-	 *  |    |       |            |
-	 *  |    |       ` buffer     |
-	 *  |    ` w                  ` upper
-	 *  ` lower
-	 *
-	 * delta = upper - lower .. conservative/safe interval
-	 * w_dist = upper - w    
-	 * upper = "number represented by digits in buf" + rest
-	 * 
-	 * Changing buf[len - 1] changes the value represented by buf 
-	 * by digit_val_diff * scaling, where scaling is shared by
-	 * all parameters. 
-	 *
-	 */
-
-	/* Current number in buf is greater than the double being converted */
-	bool cur_greater_w = rest < w_dist;
-	/* Rounding down by one would keep buf in between bounds (in safe rng). */
-	bool next_in_val_rng = cur_greater_w && (rest + digit_val_diff < delta);
-	/* Rounding down by one would bring buf closer to the processed number. */
-	bool next_closer = next_in_val_rng 
-		&& (rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest);
-
-	/* Of the shortest strings pick the one that is closest to the actual 
-	   floating point number. */
-	while (next_closer) {
-		assert('0' < buf[len - 1]);
-		assert(0 < digit_val_diff);
-
-		--buf[len - 1];
-		rest += digit_val_diff;
-
-		cur_greater_w = rest < w_dist;
-		next_in_val_rng = cur_greater_w && (rest + digit_val_diff < delta);
-		next_closer = next_in_val_rng 
-			&& (rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest);
-	}
-}
-
-
-/** Generates the shortest accurate decimal string representation.
- *
- * Outputs (mostly) the shortest accurate string representation 
- * for the number scaled_upper - val_dist. Numbers in the interval
- * [scaled_upper - delta, scaled_upper] have the same binary
- * floating point representation and will therefore share the
- * shortest string representation (up to the rounding of the last
- * digit to bring the shortest string also the closest to the
- * actual number). 
- *
- * @param scaled_upper Scaled upper bound of numbers that have the
- *              same binary representation as the converted number.
- *              Scaled by 10^-scale so that alpha <= exponent <= gamma.
- * @param delta scaled_upper - delta is the lower bound of numbers
- *              that share the same binary representation in double.
- * @param val_dist scaled_upper - val_dist is the number whose
- *              decimal string we're generating.
- * @param scale Decimal scaling of the value to convert (ie scaled_upper).
- * @param buf   Buffer to store the string representation. Must be large 
- *              enough to store all digits and a null terminator. At most
- *              MAX_DOUBLE_STR_LEN digits will be written (not counting
- *              the null terminator).
- * @param buf_size Size of buf in bytes. 
- * @param dec_exponent Will be set to the decimal exponent of the number 
- *              string in buf.
- *
- * @return Number of digits; negative on failure (eg buffer too small).
- */
-static int gen_dec_digits(fp_num_t scaled_upper, fp_num_t delta, 
-	fp_num_t val_dist, int scale, char *buf, size_t buf_size, int *dec_exponent)
-{
-	/* 
-	 * The integral part of scaled_upper is 5 to 32 bits long while 
-	 * the remaining fractional part is 59 to 32 bits long because:
-	 * -59 == alpha <= scaled_upper.e <= gamma == -32
-	 *
-	 *  | <------- delta -------> |
-	 *  |    | <--- val_dist ---> |
-	 *  |    |    |<- remainder ->|
-	 *  |    |    |               |
-	 *  |    |    ` buffer        |
-	 *  |    ` val                ` upper
-	 *  ` lower
-	 *
-	 */ 
-	assert(scaled_upper.significand != 0);
-	assert(alpha <= scaled_upper.exponent && scaled_upper.exponent <= gamma);
-	assert(scaled_upper.exponent == delta.exponent);
-	assert(scaled_upper.exponent == val_dist.exponent);
-	assert(val_dist.significand <= delta.significand);
-
-	/* We'll produce at least one digit and a null terminator. */
-	if (buf_size < 2) {
-		return -1;
-	}
-
-	/* one is number 1 encoded with the same exponent as scaled_upper */
-	fp_num_t one;
-	one.significand = ((uint64_t) 1) << (-scaled_upper.exponent);
-	one.exponent = scaled_upper.exponent;
-
-	/*
-	 * Extract the integral part of scaled_upper. 
-	 *  upper / one == upper >> -one.e 
-	 */
-	uint32_t int_part = (uint32_t)(scaled_upper.significand >> (-one.exponent));
-	
-	/* 
-	 * Fractional part of scaled_upper.
-	 *  upper % one == upper & (one.f - 1) 
-	 */
-	uint64_t frac_part = scaled_upper.significand & (one.significand - 1);
-
-	/*
-	 * The integral part of upper has at least 5 bits (64 + alpha) and 
-	 * at most 32 bits (64 + gamma). The integral part has at most 10 
-	 * decimal digits, so kappa <= 10. 
-	 */
-	int kappa = 10;
-	uint32_t div = 1000000000;
-	size_t len = 0;
-
-	/* Produce decimal digits for the integral part of upper. */
-	while (kappa > 0) {
-		int digit = int_part / div;
-		int_part %= div;
-
-		--kappa;
-
-		/* Skip leading zeros. */
-		if (digit != 0 || len != 0) {
-			/* Current length + new digit + null terminator <= buf_size */
-			if (len + 2 <= buf_size) {
-				buf[len] = '0' + digit;
-				++len;
-			} else {
-				return -1;
-			}
-		}
-
-		/* 
-		 * Difference between the so far produced decimal number and upper
-		 * is calculated as: remaining_int_part * one + frac_part 
-		 */
-		uint64_t remainder = (((uint64_t)int_part) << -one.exponent) + frac_part;
-
-		/* The produced decimal number would convert back to upper. */
-		if (remainder <= delta.significand) {
-			assert(0 < len && len < buf_size);
-			*dec_exponent = kappa - scale;
-			buf[len] = '\0';
-
-			/* Of the shortest representations choose the numerically closest. */
-			round_last_digit(remainder, val_dist.significand, delta.significand,
-				(uint64_t)div << (-one.exponent), buf, len);
-			return len;
-		}
-
-		div /= 10;
-	}
-
-	/* Generate decimal digits for the fractional part of upper. */
-	do {
-		/*
-		 * Does not overflow because at least 5 upper bits were
-		 * taken by the integral part and are now unused in frac_part. 
-		 */
-		frac_part *= 10;
-		delta.significand *= 10;
-		val_dist.significand *= 10;
-
-		/* frac_part / one */
-		int digit = (int)(frac_part >> (-one.exponent));
-		
-		/* frac_part %= one */
-		frac_part &= one.significand - 1;
-
-		--kappa;
-
-		/* Skip leading zeros. */
-		if (digit == 0 && len == 0) {
-			continue;
-		}
-
-		/* Current length + new digit + null terminator <= buf_size */
-		if (len + 2 <= buf_size) {
-			buf[len] = '0' + digit;
-			++len;
-		} else {
-			return -1;
-		}
-	} while (frac_part > delta.significand);
-
-	assert(0 < len && len < buf_size);
-
-	*dec_exponent = kappa - scale;
-	buf[len] = '\0';
-
-	/* Of the shortest representations choose the numerically closest one. */
-	round_last_digit(frac_part, val_dist.significand, delta.significand, 
-		one.significand, buf, len);
-
-	return len;
-}
-
-/** Produce a string for 0.0 */
-static int zero_to_str(char *buf, size_t buf_size, int *dec_exponent)
-{
-	if (2 <= buf_size) {
-		buf[0] = '0';
-		buf[1] = '\0';
-		*dec_exponent = 0;
-		return 1;
-	} else {
-		return -1;
-	}
-}
-
-
-/** Converts a non-special double into its shortest accurate string 
- *  representation.
- *
- * Produces an accurate string representation, ie the string will 
- * convert back to the same binary double (eg via strtod). In the
- * vast majority of cases (99%) the string will be the shortest such
- * string that is also the closest to the value of any shortest
- * string representations. Therefore, no trailing zeros are ever
- * produced.
- *
- * Conceptually, the value is: buf * 10^dec_exponent
- *
- * Never outputs trailing zeros.
- *
- * @param ieee_val Binary double description to convert. Must be the product
- *                 of extract_ieee_double and it must not be a special number.
- * @param buf      Buffer to store the string representation. Must be large 
- *                 enough to store all digits and a null terminator. At most
- *                 MAX_DOUBLE_STR_LEN digits will be written (not counting
- *                 the null terminator).
- * @param buf_size Size of buf in bytes.
- * @param dec_exponent Will be set to the decimal exponent of the number 
- *                 string in buf.
- *
- * @return The number of printed digits. A negative value indicates
- *         an error: buf too small (or ieee_val.is_special).
- */
-int double_to_short_str(ieee_double_t ieee_val, char *buf, size_t buf_size, 
-	int *dec_exponent)
-{
-	/* The whole computation assumes 64bit significand. */
-	assert(sizeof(ieee_val.pos_val.significand) == sizeof(uint64_t));
-
-	if (ieee_val.is_special) {
-		return -1;
-	}
-
-	/* Zero cannot be normalized. Handle it here. */
-	if (0 == ieee_val.pos_val.significand) {
-		return zero_to_str(buf, buf_size, dec_exponent);
-	}
-
-	fp_num_t scaled_upper_bound;
-	fp_num_t delta;
-	fp_num_t val_dist;
-	int scale;
-
-	calc_scaled_bounds(ieee_val, &scaled_upper_bound, 
-		&delta, &val_dist, &scale);
-
-	int len = gen_dec_digits(scaled_upper_bound, delta, val_dist, scale, 
-		buf, buf_size, dec_exponent);
-
-	assert(len <= MAX_DOUBLE_STR_LEN);
-	return len;
-}
-
-/** Generates a fixed number of decimal digits of w_scaled.
- *
- * double == w_scaled * 10^-scale, where alpha <= w_scaled.e <= gamma
- *
- * @param w_scaled Scaled number by 10^-scale so that
- *              alpha <= exponent <= gamma
- * @param scale Decimal scaling of the value to convert (ie w_scaled).
- * @param signif_d_cnt Maximum number of significant digits to output. 
- *              Negative if as many as possible are requested.
- * @param frac_d_cnt   Maximum number of fractional digits to output.
- *              Negative if as many as possible are requested.
- *              Eg. if 2 then 1.234 -> "1.23"; if 2 then 3e-9 -> "0".
- * @param buf   Buffer to store the string representation. Must be large 
- *              enough to store all digits and a null terminator. At most
- *              MAX_DOUBLE_STR_LEN digits will be written (not counting
- *              the null terminator).
- * @param buf_size Size of buf in bytes. 
- *
- * @return Number of digits; negative on failure (eg buffer too small).
- */
-static int gen_fixed_dec_digits(fp_num_t w_scaled, int scale, int signif_d_cnt, 
-	int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent)
-{
-	/* We'll produce at least one digit and a null terminator. */
-	if (0 == signif_d_cnt || buf_size < 2) {
-		return -1;
-	}
-
-	/* 
-	 * The integral part of w_scaled is 5 to 32 bits long while the 
-	 * remaining fractional part is 59 to 32 bits long because:
-	 * -59 == alpha <= w_scaled.e <= gamma == -32
-	 * 
-	 * Therefore:
-	 *  | 5..32 bits | 32..59 bits | == w_scaled == w * 10^scale
-	 *  |  int_part  |  frac_part  |
-	 *  |0 0  ..  0 1|0 0   ..  0 0| == one == 1.0
-	 *  |      0     |0 0   ..  0 1| == w_err == 1 * 2^w_scaled.e  
-	*/
-	assert(alpha <= w_scaled.exponent && w_scaled.exponent <= gamma);
-	assert(0 != w_scaled.significand);
-
-	/* 
-	 * Scaling the number being converted by 10^scale introduced
-	 * an error of less that 1 ulp. The actual value of w_scaled
-	 * could lie anywhere between w_scaled.signif +/- w_err. 
-	 * Scale the error locally as we scale the fractional part
-	 * of w_scaled.
-	 */
-	uint64_t w_err = 1;
-
-	/* one is number 1.0 encoded with the same exponent as w_scaled */
-	fp_num_t one;
-	one.significand = ((uint64_t) 1) << (-w_scaled.exponent);
-	one.exponent = w_scaled.exponent;
-
-	/* Extract the integral part of w_scaled. 
-	   w_scaled / one == w_scaled >> -one.e */
-	uint32_t int_part = (uint32_t)(w_scaled.significand >> (-one.exponent));
-
-	/* Fractional part of w_scaled.
-	   w_scaled % one == w_scaled & (one.f - 1) */
-	uint64_t frac_part = w_scaled.significand & (one.significand - 1);
-
-	size_t len = 0;
-	/* 
-	 * The integral part of w_scaled has at least 5 bits (64 + alpha = 5) 
-	 * and at most 32 bits (64 + gamma = 32). The integral part has 
-	 * at most 10 decimal digits, so kappa <= 10. 
-	 */
-	int kappa = 10;
-	uint32_t div = 1000000000;
-
-	int rem_signif_d_cnt = signif_d_cnt;
-	int rem_frac_d_cnt = 
-		(frac_d_cnt >= 0) ? (kappa - scale + frac_d_cnt) : INT_MAX;
-
-	/* Produce decimal digits for the integral part of w_scaled. */
-	while (kappa > 0 && rem_signif_d_cnt != 0 && rem_frac_d_cnt > 0) {
-		int digit = int_part / div;
-		int_part %= div;
-
-		div /= 10;
-		--kappa;
-		--rem_frac_d_cnt;
-
-		/* Skip leading zeros. */
-		if (digit == 0 && len == 0) {
-			continue;
-		}
-
-		/* Current length + new digit + null terminator <= buf_size */
-		if (len + 2 <= buf_size) {
-			buf[len] = '0' + digit;
-			++len;
-			--rem_signif_d_cnt;
-		} else {
-			return -1;
-		}
-	}
-
-	/* Generate decimal digits for the fractional part of w_scaled. */
-	while (w_err <= frac_part && rem_signif_d_cnt != 0 && rem_frac_d_cnt > 0) {
-		/*
-		 * Does not overflow because at least 5 upper bits were
-		 * taken by the integral part and are now unused in frac_part. 
-		 */
-		frac_part *= 10;
-		w_err *= 10;
-
-		/* frac_part / one */
-		int digit = (int)(frac_part >> (-one.exponent));
-		
-		/* frac_part %= one */
-		frac_part &= one.significand - 1;
-
-		--kappa;
-		--rem_frac_d_cnt;
-
-		/* Skip leading zeros. */
-		if (digit == 0 && len == 0) {
-			continue;
-		}
-
-		/* Current length + new digit + null terminator <= buf_size */
-		if (len + 2 <= buf_size) {
-			buf[len] = '0' + digit;
-			++len;
-			--rem_signif_d_cnt;
-		} else {
-			return -1;
-		}
-	};
-
-	assert(/* 0 <= len && */ len < buf_size);
-
-	if (0 < len) {
-		*dec_exponent = kappa - scale;
-		assert(frac_d_cnt < 0 || -frac_d_cnt <= *dec_exponent);
-	} else {
-		/* 
-		 * The number of fractional digits was too limiting to produce 
-		 * any digits. 
-		 */
-		assert(rem_frac_d_cnt <= 0 || w_scaled.significand == 0);
-		*dec_exponent = 0;
-		buf[0] = '0';
-		len = 1;
-	}
-
-	if (len < buf_size) {
-		buf[len] = '\0';
-		assert(signif_d_cnt < 0 || (int)len <= signif_d_cnt);
-		return len;
-	} else {
-		return -1;
-	}
-}
-
-
-/** Converts a non-special double into its string representation.
- *
- * Conceptually, the truncated double value is: buf * 10^dec_exponent
- *
- * Conversion errors are tracked, so all produced digits except the
- * last one are accurate. Garbage digits are never produced.
- * If the requested number of digits cannot be produced accurately 
- * due to conversion errors less digits are produced than requested 
- * and the last digit has an error of +/- 1 (so if '7' is the last
- * converted digit it might have been converted to any of '6'..'8'
- * had the conversion been completely precise). 
- *
- * If no error occurs at least one digit is output. 
- *
- * The conversion stops once the requested number of significant or 
- * fractional digits is reached or the conversion error is too large 
- * to generate any more digits (whichever happens first).
- *
- * Any digits following the first (most-significant) digit (this digit
- * included) are counted as significant digits; eg:
- *   1.4,    4 signif -> "1400" * 10^-3, ie 1.400
- *   1000.3, 1 signif -> "1" * 10^3      ie 1000
- *   0.003,  2 signif -> "30" * 10^-4    ie 0.003
- *   9.5     1 signif -> "9" * 10^0,     ie 9
- *
- * Any digits following the decimal point are counted as fractional digits.
- * This includes the zeros that would appear between the decimal point
- * and the first non-zero fractional digit. If fewer fractional digits
- * are requested than would allow to place the most-significant digit
- * a "0" is output. Eg:
- *   1.4,   3 frac -> "1400" * 10^-3,   ie 1.400
- *   12.34  4 frac -> "123400" * 10^-4, ie 12.3400
- *   3e-99  4 frac -> "0" * 10^0,       ie 0
- *   0.009  2 frac -> "0" * 10^-2,      ie 0
- *
- * @param ieee_val Binary double description to convert. Must be the product
- *                 of extract_ieee_double and it must not be a special number.
- * @param signif_d_cnt Maximum number of significant digits to produce.
- *                 The output is not rounded. 
- *                 Set to a negative value to generate as many digits
- *                 as accurately possible.
- * @param frac_d_cnt Maximum number of fractional digits to produce including
- *                 any zeros immediately trailing the decimal point. 
- *                 The output is not rounded. 
- *                 Set to a negative value to generate as many digits
- *                 as accurately possible.
- * @param buf      Buffer to store the string representation. Must be large 
- *                 enough to store all digits and a null terminator. At most
- *                 MAX_DOUBLE_STR_LEN digits will be written (not counting
- *                 the null terminator).
- * @param buf_size Size of buf in bytes.
- * @param dec_exponent Set to the decimal exponent of the number string 
- *                 in buf.
- *
- * @return The number of output digits. A negative value indicates
- *         an error: buf too small (or ieee_val.is_special, or 
- *         signif_d_cnt == 0).
- */
-int double_to_fixed_str(ieee_double_t ieee_val, int signif_d_cnt,
-	int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent)
-{
-	/* The whole computation assumes 64bit significand. */
-	assert(sizeof(ieee_val.pos_val.significand) == sizeof(uint64_t));
-
-	if (ieee_val.is_special) {
-		return -1;
-	}
-
-	/* Zero cannot be normalized. Handle it here. */
-	if (0 == ieee_val.pos_val.significand) {
-		return zero_to_str(buf, buf_size, dec_exponent);
-	}
-
-	/* Normalize and scale. */
-	fp_num_t w = normalize(ieee_val.pos_val);
-
-	int lower_bin_exp = alpha - w.exponent - significand_width;
-
-	int scale;
-	fp_num_t scaling_power_of_10;
-
-	get_power_of_ten(lower_bin_exp, &scaling_power_of_10, &scale);
-
-	fp_num_t w_scaled = multiply(w, scaling_power_of_10);
-
-	/* Produce decimal digits from the scaled number. */
-	int len = gen_fixed_dec_digits(w_scaled, scale, signif_d_cnt, frac_d_cnt, 
-		buf, buf_size, dec_exponent);
-
-	assert(len <= MAX_DOUBLE_STR_LEN);
-	return len;
-}
-
Index: uspace/lib/c/generic/fibril.c
===================================================================
--- uspace/lib/c/generic/fibril.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/fibril.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,9 +37,6 @@
 #include <fibril.h>
 #include <thread.h>
-#include <stack.h>
 #include <tls.h>
 #include <malloc.h>
-#include <abi/mm/as.h>
-#include <as.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -50,4 +47,8 @@
 #include <async.h>
 
+#ifndef FIBRIL_INITIAL_STACK_PAGES_NO
+	#define FIBRIL_INITIAL_STACK_PAGES_NO  1
+#endif
+
 /**
  * This futex serializes access to ready_list,
@@ -95,5 +96,5 @@
 fibril_t *fibril_setup(void)
 {
-	tcb_t *tcb = tls_make();
+	tcb_t *tcb = __make_tls();
 	if (!tcb)
 		return NULL;
@@ -101,5 +102,5 @@
 	fibril_t *fibril = malloc(sizeof(fibril_t));
 	if (!fibril) {
-		tls_free(tcb);
+		__free_tls(tcb);
 		return NULL;
 	}
@@ -122,5 +123,5 @@
 void fibril_teardown(fibril_t *fibril)
 {
-	tls_free(fibril->tcb);
+	__free_tls(fibril->tcb);
 	free(fibril);
 }
@@ -194,5 +195,5 @@
 					 * stack member filled.
 					 */
-					as_area_destroy(stack);
+					free(stack);
 				}
 				fibril_teardown(srcf->clean_after_me);
@@ -268,9 +269,7 @@
 		return 0;
 	
-	size_t stack_size = stack_size_get();
-	fibril->stack = as_area_create((void *) -1, stack_size,
-	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
-	    AS_AREA_LATE_RESERVE);
-	if (fibril->stack == (void *) -1) {
+	fibril->stack =
+	    (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize());
+	if (!fibril->stack) {
 		fibril_teardown(fibril);
 		return 0;
@@ -282,5 +281,5 @@
 	context_save(&fibril->ctx);
 	context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack,
-	    stack_size, fibril->tcb);
+	    FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize(), fibril->tcb);
 
 	return (fid_t) fibril;
@@ -299,5 +298,5 @@
 	fibril_t *fibril = (fibril_t *) fid;
 	
-	as_area_destroy(fibril->stack);
+	free(fibril->stack);
 	fibril_teardown(fibril);
 }
Index: pace/lib/c/generic/ieee_double.c
===================================================================
--- uspace/lib/c/generic/ieee_double.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,114 +1,0 @@
-/*
- * Copyright (c) 2012 Adam Hraska
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 <ieee_double.h>
-
-#include <assert.h>
-
-/** Returns an easily processible description of the double val.
- */
-ieee_double_t extract_ieee_double(double val)
-{
-	const uint64_t significand_mask = 0xfffffffffffffULL;
-	const uint64_t exponent_mask = 0x7ff0000000000000ULL;
-	const int exponent_shift = 64 - 11 - 1;
-	const uint64_t sign_mask = 0x8000000000000000ULL;
-	
-	const int special_exponent = 0x7ff;
-	const int denormal_exponent = 0;
-	const uint64_t hidden_bit = (1ULL << 52);
-	const int exponent_bias = 1075;
-
-	assert(sizeof(val) == sizeof(uint64_t));
-
-	union {
-		uint64_t num;
-		double val;
-	} bits;
-
-	bits.val = val;
-
-	/* 
-	 * Extract the binary ieee representation of the double. 
-	 * Relies on integers having the same endianness as doubles.
-	 */
-	uint64_t num = bits.num;	
-
-	ieee_double_t ret;
-
-	/* Determine the sign. */
-	ret.is_negative = ((num & sign_mask) != 0);
-
-	/* Extract the exponent. */
-	int raw_exponent = (num & exponent_mask) >> exponent_shift;
-
-	/* The extracted raw significand may not contain the hidden bit */
-	uint64_t raw_significand = num & significand_mask;
-
-	ret.is_special = (raw_exponent == special_exponent);
-
-	/* NaN or infinity */
-	if (ret.is_special) {
-		ret.is_infinity = (raw_significand == 0);
-		ret.is_nan = (raw_significand != 0);
-
-		/* These are not valid for special numbers but init them anyway. */
-		ret.is_denormal = true;
-		ret.is_accuracy_step = false;
-		ret.pos_val.significand = 0;
-		ret.pos_val.exponent = 0;
-	} else {
-		ret.is_infinity = false;
-		ret.is_nan = false;
-
-		ret.is_denormal = (raw_exponent == denormal_exponent);
-
-		/* Denormal or zero. */
-		if (ret.is_denormal) {
-			ret.pos_val.significand = raw_significand;
-			ret.pos_val.exponent = 1 - exponent_bias;
-			ret.is_accuracy_step = false;
-		} else {
-			ret.pos_val.significand = raw_significand + hidden_bit;
-			ret.pos_val.exponent = raw_exponent - exponent_bias;
-
-			/* The predecessor is closer to val than the successor 
-			 * if val is a normal value of the form 2^k (hence
-			 * raw_significand == 0) with the only exception being 
-			 * the smallest normal (raw_exponent == 1). The smallest 
-			 * normal's predecessor is the largest denormal and denormals 
-			 * do not get an extra bit of precision because their exponent 
-			 * stays the same (ie it does not decrease from k to k-1).
-			 */
-			ret.is_accuracy_step = (raw_significand == 0) && (raw_exponent != 1);
-		}
-	}
-
-	return ret;
-}
-
Index: uspace/lib/c/generic/io/chargrid.c
===================================================================
--- uspace/lib/c/generic/io/chargrid.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/io/chargrid.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 #include <unistd.h>
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <as.h>
 #include <io/chargrid.h>
Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/io/io.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <str.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <malloc.h>
 #include <async.h>
Index: uspace/lib/c/generic/io/klog.c
===================================================================
--- uspace/lib/c/generic/io/klog.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/io/klog.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,4 @@
 #include <unistd.h>
 #include <errno.h>
-#include <abi/klog.h>
 #include <io/klog.h>
 #include <io/printf_core.h>
@@ -45,5 +44,5 @@
 size_t klog_write(const void *buf, size_t size)
 {
-	ssize_t ret = (ssize_t) __SYSCALL3(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf, size);
+	ssize_t ret = (ssize_t) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, size);
 	
 	if (ret >= 0)
@@ -55,10 +54,5 @@
 void klog_update(void)
 {
-	(void) __SYSCALL3(SYS_KLOG, KLOG_UPDATE, (uintptr_t) NULL, 0);
-}
-
-void klog_command(const void *buf, size_t size)
-{
-	(void) __SYSCALL3(SYS_KLOG, KLOG_COMMAND, (sysarg_t) buf, (sysarg_t) size);
+	(void) __SYSCALL3(SYS_KLOG, 1, (uintptr_t) NULL, 0);
 }
 
Index: uspace/lib/c/generic/io/printf_core.c
===================================================================
--- uspace/lib/c/generic/io/printf_core.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/io/printf_core.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,16 +42,8 @@
 #include <ctype.h>
 #include <str.h>
-#include <double_to_str.h>
-#include <ieee_double.h>
-#include <assert.h>
-#include <macros.h>
-
 
 /** show prefixes 0x or 0 */
 #define __PRINTF_FLAG_PREFIX       0x00000001
 
-/** show the decimal point even if no fractional digits present */
-#define __PRINTF_FLAG_DECIMALPT    0x00000001
-
 /** signed / unsigned number */
 #define __PRINTF_FLAG_SIGNED       0x00000002
@@ -74,8 +66,4 @@
 /** number has - sign */
 #define __PRINTF_FLAG_NEGATIVE     0x00000100
-
-/** don't print trailing zeros in the fractional part */
-#define __PRINTF_FLAG_NOFRACZEROS  0x00000200
-
 
 /**
@@ -122,47 +110,4 @@
 static const char invalch = U_SPECIAL;
 
-
-
-/** Unformatted double number string representation. */
-typedef struct {
-	/** Buffer with len digits, no sign or leading zeros. */
-	char *str;
-	/** Number of digits in str. */
-	int len;
-	/** Decimal exponent, ie number = str * 10^dec_exp */
-	int dec_exp;
-	/** True if negative. */
-	bool neg;
-} double_str_t;
-
-
-
-/** Returns the sign character or 0 if no sign should be printed. */
-static int get_sign_char(bool negative, uint32_t flags)
-{
-	if (negative) {
-		return '-';
-	} else if (flags & __PRINTF_FLAG_SHOWPLUS) {
-		return '+';
-	} else if (flags & __PRINTF_FLAG_SPACESIGN) {
-		return ' ';
-	} else {
-		return 0;
-	}
-}
-
-/** Prints count times character ch. */
-static int print_padding(char ch, int count, printf_spec_t *ps)
-{
-	for (int i = 0; i < count; ++i) {
-		if (ps->str_write(&ch, 1, ps->data) < 0) {
-			return -1;
-		}
-	}
-
-	return count;
-}
-
-
 /** Print one or more characters without adding newline.
  *
@@ -336,7 +281,6 @@
 		return printf_putstr(nullstr, ps);
 	
+	/* Print leading spaces. */
 	size_t strw = str_length(str);
-
-	/* Precision unspecified - print everything. */
 	if ((precision == 0) || (precision > strw))
 		precision = strw;
@@ -385,7 +329,6 @@
 		return printf_putstr(nullstr, ps);
 	
+	/* Print leading spaces. */
 	size_t strw = wstr_length(str);
-
-	/* Precision not specified - print everything. */
 	if ((precision == 0) || (precision > strw))
 		precision = strw;
@@ -434,9 +377,4 @@
     uint32_t flags, printf_spec_t *ps)
 {
-	/* Precision not specified. */
-	if (precision < 0) {
-		precision = 0;
-	}
-	
 	const char *digits;
 	if (flags & __PRINTF_FLAG_BIGCHARS)
@@ -589,656 +527,4 @@
 }
 
-/** Prints a special double (ie NaN, infinity) padded to width characters. */
-static int print_special(ieee_double_t val, int width, uint32_t flags, 
-	printf_spec_t *ps)
-{
-	assert(val.is_special);
-
-	char sign = get_sign_char(val.is_negative, flags);
-
-	const int str_len = 3;
-	const char *str;
-	
-	if (flags & __PRINTF_FLAG_BIGCHARS) {
-		str = val.is_infinity ? "INF" : "NAN";
-	} else {
-		str = val.is_infinity ? "inf" : "nan";
-	}
-
-	int padding_len = max(0, width - ((sign ? 1 : 0) + str_len));
-
-	int counter = 0;
-	int ret;
-
-	/* Leading padding. */
-	if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
-		if ((ret = print_padding(' ', padding_len, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	if (sign) {
-		if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
-			return -1;
-		
-		counter += ret;
-	}
-
-	if ((ret = ps->str_write(str, str_len, ps->data)) < 0)
-		return -1;
-	
-	counter += ret;
-
-
-	/* Trailing padding. */
-	if (flags & __PRINTF_FLAG_LEFTALIGNED) {
-		if ((ret = print_padding(' ', padding_len, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	return counter;
-}
-
-/** Trims trailing zeros but leaves a single "0" intact. */
-static void fp_trim_trailing_zeros(char *buf, int *len, int *dec_exp)
-{
-	/* Cut the zero off by adjusting the exponent. */
-	while (2 <= *len && '0' == buf[*len - 1]) {
-		--*len;
-		++*dec_exp;
-	}
-}
-
-/** Textually round up the last digit thereby eliminating it. */
-static void fp_round_up(char *buf, int *len, int *dec_exp)
-{
-	assert(1 <= *len);
-
-	char *last_digit = &buf[*len - 1];
-
-	int carry = ('5' <= *last_digit);
-
-	/* Cut the digit off by adjusting the exponent. */
-	--*len;
-	++*dec_exp;
-	--last_digit;
-
-	if (carry) {
-		/* Skip all the digits to cut off/round to zero. */
-		while (buf <= last_digit && '9' == *last_digit) {
-			--last_digit;
-		}
-
-		/* last_digit points to the last digit to round but not '9' */
-		if (buf <= last_digit) {
-			*last_digit += 1;
-			int new_len = last_digit - buf + 1;
-			*dec_exp += *len - new_len;
-			*len = new_len;
-		} else {
-			/* All len digits rounded to 0. */
-			buf[0] = '1';
-			*dec_exp += *len;
-			*len = 1;
-		}
-	} else {
-		/* The only digit was rounded to 0. */
-		if (last_digit < buf) {
-			buf[0] = '0';
-			*dec_exp = 0;
-			*len = 1;
-		}
-	}
-}
-
-
-/** Format and print the double string repressentation according 
- *  to the %f specifier. 
- */
-static int print_double_str_fixed(double_str_t *val_str, int precision, int width, 
-	uint32_t flags, printf_spec_t *ps)
-{
-	int len = val_str->len;
-	char *buf = val_str->str;
-	int dec_exp = val_str->dec_exp;
-
-	assert(0 < len);
-	assert(0 <= precision);
-	assert(0 <= dec_exp || -dec_exp <= precision);
-
-	/* Number of integral digits to print (at least leading zero). */
-	int int_len = max(1, len + dec_exp);
-
-	char sign = get_sign_char(val_str->neg, flags);
-
-	/* Fractional portion lengths. */
-	int last_frac_signif_pos = max(0, -dec_exp);
-	int leading_frac_zeros = max(0, last_frac_signif_pos - len);
-	int signif_frac_figs = min(last_frac_signif_pos, len);
-	int trailing_frac_zeros = precision - last_frac_signif_pos;
-	char *buf_frac = buf + len - signif_frac_figs;
-
-	if (flags & __PRINTF_FLAG_NOFRACZEROS) {
-		trailing_frac_zeros = 0;
-	}
-
-	int frac_len = leading_frac_zeros + signif_frac_figs + trailing_frac_zeros;
-
-	bool has_decimal_pt = (0 < frac_len) || (flags & __PRINTF_FLAG_DECIMALPT);
-
-	/* Number of non-padding chars to print. */
-	int num_len = (sign ? 1 : 0) + int_len + (has_decimal_pt ? 1 : 0) + frac_len;
-
-	int padding_len = max(0, width - num_len);
-	int ret = 0;
-	int counter = 0;
-
-	/* Leading padding and sign. */
-
-	if (!(flags & (__PRINTF_FLAG_LEFTALIGNED | __PRINTF_FLAG_ZEROPADDED))) {
-		if ((ret = print_padding(' ', padding_len, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	if (sign) {
-		if ((ret = ps->str_write(&sign, 1, ps->data)) < 0) 
-			return -1;
-		
-		counter += ret;
-	}
-
-	if (flags & __PRINTF_FLAG_ZEROPADDED) {
-		if ((ret = print_padding('0', padding_len, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	/* Print the intergral part of the buffer. */
-
-	int buf_int_len = min(len, len + dec_exp);
-
-	if (0 < buf_int_len) {
-		if ((ret = ps->str_write(buf, buf_int_len, ps->data)) < 0) 
-			return -1;
-
-		counter += ret;
-
-		/* Print trailing zeros of the integral part of the number. */
-		if ((ret = print_padding('0', int_len - buf_int_len, ps)) < 0) 
-			return -1;
-	} else {
-		/* Single leading integer 0. */
-		char ch = '0';
-		if ((ret = ps->str_write(&ch, 1, ps->data)) < 0) 
-			return -1;
-	}
-
-	counter += ret;
-	
-	/* Print the decimal point and the fractional part. */
-	if (has_decimal_pt) {
-		char ch = '.';
-
-		if ((ret = ps->str_write(&ch, 1, ps->data)) < 0) 
-			return -1;
-		
-		counter += ret;
-
-		/* Print leading zeros of the fractional part of the number. */
-		if ((ret = print_padding('0', leading_frac_zeros, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-
-		/* Print significant digits of the fractional part of the number. */
-		if (0 < signif_frac_figs) {
-			if ((ret = ps->str_write(buf_frac, signif_frac_figs, ps->data)) < 0) 
-				return -1;
-
-			counter += ret;
-		}
-
-		/* Print trailing zeros of the fractional part of the number. */
-		if ((ret = print_padding('0', trailing_frac_zeros, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	/* Trailing padding. */
-	if (flags & __PRINTF_FLAG_LEFTALIGNED) {
-		if ((ret = print_padding(' ', padding_len, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	return counter;
-}
-
-
-/** Convert, format and print a double according to the %f specifier. 
- *
- * @param g     Double to print.
- * @param precision Number of fractional digits to print. If 0 no
- *              decimal point will be printed unless the flag
- *              __PRINTF_FLAG_DECIMALPT is specified.
- * @param width Minimum number of characters to display. Pads 
- *              with '0' or ' ' depending on the set flags;
- * @param flags Printf flags.
- * @param ps    Printing functions.
- *
- * @return The number of characters printed; negative on failure.
- */
-static int print_double_fixed(double g, int precision, int width, uint32_t flags, 
-	printf_spec_t *ps)
-{
-	if (flags & __PRINTF_FLAG_LEFTALIGNED) {
-		flags &= ~__PRINTF_FLAG_ZEROPADDED;
-	}
-
-	if (flags & __PRINTF_FLAG_DECIMALPT) {
-		flags &= ~__PRINTF_FLAG_NOFRACZEROS;
-	}
-
-	ieee_double_t val = extract_ieee_double(g);
-
-	if (val.is_special) {
-		return print_special(val, width, flags, ps);
-	} 
-
-	char buf[MAX_DOUBLE_STR_BUF_SIZE];
-	const size_t buf_size = MAX_DOUBLE_STR_BUF_SIZE;
-	double_str_t val_str;
-
-	val_str.str = buf;
-	val_str.neg = val.is_negative;
-
-	if (0 <= precision) {
-		/* 
-		 * Request one more digit so we can round the result. The last
-		 * digit it returns may have an error of at most +/- 1. 
-		 */
-		val_str.len = double_to_fixed_str(val, -1, precision + 1, buf, buf_size, 
-			&val_str.dec_exp);
-
-		/* 
-		 * Round using the last digit to produce precision fractional digits. 
-		 * If less than precision+1 fractional digits were output the last 
-		 * digit is definitely inaccurate so also round to get rid of it. 
-		 */
-		fp_round_up(buf, &val_str.len, &val_str.dec_exp);
-
-		/* Rounding could have introduced trailing zeros. */
-		if (flags & __PRINTF_FLAG_NOFRACZEROS) {
-			fp_trim_trailing_zeros(buf, &val_str.len, &val_str.dec_exp);
-		}
-	} else {
-		/* Let the implementation figure out the proper precision. */
-		val_str.len = double_to_short_str(val, buf, buf_size, &val_str.dec_exp);
-		
-		/* Precision needed for the last significant digit. */
-		precision = max(0, -val_str.dec_exp);
-	}
-
-	return print_double_str_fixed(&val_str, precision, width, flags, ps);
-}
-
-/** Prints the decimal exponent part of a %e specifier formatted number. */
-static int print_exponent(int exp_val, uint32_t flags, printf_spec_t *ps)
-{
-	int counter = 0;
-	int ret;
-
-	char exp_ch = (flags & __PRINTF_FLAG_BIGCHARS) ? 'E' : 'e';
-
-	if ((ret = ps->str_write(&exp_ch, 1, ps->data)) < 0) 
-		return -1;
-	
-	counter += ret;
-
-	char exp_sign = (exp_val < 0) ? '-' : '+';
-
-	if ((ret = ps->str_write(&exp_sign, 1, ps->data)) < 0)
-		return -1;
-
-	counter += ret;
-
-	/* Print the exponent. */
-	exp_val = abs(exp_val);
-	
-	char exp_str[4] = { 0 };
-
-	exp_str[0] = '0' + exp_val / 100;
-	exp_str[1] = '0' + (exp_val % 100) / 10 ;
-	exp_str[2] = '0' + (exp_val % 10);
-	
-	int exp_len = (exp_str[0] == '0') ? 2 : 3;
-	const char *exp_str_start = &exp_str[3] - exp_len;
-
-	if ((ret = ps->str_write(exp_str_start, exp_len, ps->data)) < 0) 
-		return -1;
-
-	counter += ret;
-
-	return counter;
-}
-
-
-/** Format and print the double string repressentation according 
- *  to the %e specifier. 
- */
-static int print_double_str_scient(double_str_t *val_str, int precision, 
-	int width, uint32_t flags, printf_spec_t *ps)
-{
-	int len = val_str->len;
-	int dec_exp = val_str->dec_exp;
-	char *buf  = val_str->str;
-
-	assert(0 < len);
-
-	char sign = get_sign_char(val_str->neg, flags);
-	bool has_decimal_pt = (0 < precision) || (flags & __PRINTF_FLAG_DECIMALPT);
-	int dec_pt_len = has_decimal_pt ? 1 : 0;
-
-	/* Fractional part lengths. */
-	int signif_frac_figs = len - 1;
-	int trailing_frac_zeros = precision - signif_frac_figs;
-
-	if (flags & __PRINTF_FLAG_NOFRACZEROS) {
-		trailing_frac_zeros = 0;
-	}
-
-	int frac_len = signif_frac_figs + trailing_frac_zeros;
-
-	int exp_val = dec_exp + len - 1;
-	/* Account for exponent sign and 'e'; minimum 2 digits. */
-	int exp_len = 2 + (abs(exp_val) >= 100 ? 3 : 2);
-
-	/* Number of non-padding chars to print. */
-	int num_len = (sign ? 1 : 0) + 1 + dec_pt_len + frac_len + exp_len;
-
-	int padding_len = max(0, width - num_len);
-	int ret = 0;
-	int counter = 0;
-
-	if (!(flags & (__PRINTF_FLAG_LEFTALIGNED | __PRINTF_FLAG_ZEROPADDED))) {
-		if ((ret = print_padding(' ', padding_len, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	if (sign) {
-		if ((ret = ps->str_write(&sign, 1, ps->data)) < 0) 
-			return -1;
-		
-		counter += ret;
-	}
-
-	if (flags & __PRINTF_FLAG_ZEROPADDED) {
-		if ((ret = print_padding('0', padding_len, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	/* Single leading integer. */
-	if ((ret = ps->str_write(buf, 1, ps->data)) < 0) 
-		return -1;
-
-	counter += ret;
-
-	/* Print the decimal point and the fractional part. */
-	if (has_decimal_pt) {
-		char ch = '.';
-
-		if ((ret = ps->str_write(&ch, 1, ps->data)) < 0) 
-			return -1;
-		
-		counter += ret;
-
-		/* Print significant digits of the fractional part of the number. */
-		if (0 < signif_frac_figs) {
-			if ((ret = ps->str_write(buf + 1, signif_frac_figs, ps->data)) < 0) 
-				return -1;
-
-			counter += ret;
-		}
-
-		/* Print trailing zeros of the fractional part of the number. */
-		if ((ret = print_padding('0', trailing_frac_zeros, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	/* Print the exponent. */
-	if ((ret = print_exponent(exp_val, flags, ps)) < 0) 
-		return -1;
-
-	counter += ret;
-
-	if (flags & __PRINTF_FLAG_LEFTALIGNED) {
-		if ((ret = print_padding(' ', padding_len, ps)) < 0) 
-			return -1;
-
-		counter += ret;
-	}
-
-	return counter;
-}
-
-
-/** Convert, format and print a double according to the %e specifier. 
- *
- * Note that if g is large, the output may be huge (3e100 prints 
- * with at least 100 digits).
- *
- * %e style: [-]d.dddde+dd
- *  left-justified:  [-]d.dddde+dd[space_pad]
- *  right-justified: [space_pad][-][zero_pad]d.dddde+dd
- *
- * @param g     Double to print.
- * @param precision Number of fractional digits to print, ie
- *              precision + 1 significant digits to display. If 0 no
- *              decimal point will be printed unless the flag
- *              __PRINTF_FLAG_DECIMALPT is specified. If negative
- *              the shortest accurate number will be printed.
- * @param width Minimum number of characters to display. Pads 
- *              with '0' or ' ' depending on the set flags;
- * @param flags Printf flags.
- * @param ps    Printing functions.
- *
- * @return The number of characters printed; negative on failure.
- */
-static int print_double_scientific(double g, int precision, int width, 
-	uint32_t flags, printf_spec_t *ps)
-{
-	if (flags & __PRINTF_FLAG_LEFTALIGNED) {
-		flags &= ~__PRINTF_FLAG_ZEROPADDED;
-	}
-
-	ieee_double_t val = extract_ieee_double(g);
-
-	if (val.is_special) {
-		return print_special(val, width, flags, ps);
-	} 
-
-	char buf[MAX_DOUBLE_STR_BUF_SIZE];
-	const size_t buf_size = MAX_DOUBLE_STR_BUF_SIZE;
-	double_str_t val_str;
-
-	val_str.str = buf;
-	val_str.neg = val.is_negative;
-
-	if (0 <= precision) {
-		/* 
-		 * Request one more digit (in addition to the leading integer) 
-		 * so we can round the result. The last digit it returns may 
-		 * have an error of at most +/- 1. 
-		 */
-		val_str.len = double_to_fixed_str(val, precision + 2, -1, buf, buf_size, 
-			&val_str.dec_exp);
-
-		/* 
-		 * Round the extra digit to produce precision+1 significant digits. 
-		 * If less than precision+2 significant digits were returned the last 
-		 * digit is definitely inaccurate so also round to get rid of it. 
-		 */
-		fp_round_up(buf, &val_str.len, &val_str.dec_exp);
-
-		/* Rounding could have introduced trailing zeros. */
-		if (flags & __PRINTF_FLAG_NOFRACZEROS) {
-			fp_trim_trailing_zeros(buf, &val_str.len, &val_str.dec_exp);
-		}
-	} else {
-		/* Let the implementation figure out the proper precision. */
-		val_str.len = double_to_short_str(val, buf, buf_size, &val_str.dec_exp);
-		
-		/* Use all produced digits. */
-		precision = val_str.len - 1;
-	}
-
-	return print_double_str_scient(&val_str, precision, width, flags, ps);
-}
-
-
-/** Convert, format and print a double according to the %g specifier. 
- *
- * %g style chooses between %f and %e. 
- *
- * @param g     Double to print.
- * @param precision Number of significant digits to display; excluding
- *              any leading zeros from this count. If negative
- *              the shortest accurate number will be printed.
- * @param width Minimum number of characters to display. Pads 
- *              with '0' or ' ' depending on the set flags;
- * @param flags Printf flags.
- * @param ps    Printing functions.
- *
- * @return The number of characters printed; negative on failure.
- */
-static int print_double_generic(double g, int precision, int width, 
-	uint32_t flags, printf_spec_t *ps)
-{
-	ieee_double_t val = extract_ieee_double(g);
-
-	if (val.is_special) {
-		return print_special(val, width, flags, ps);
-	} 
-
-	char buf[MAX_DOUBLE_STR_BUF_SIZE];
-	const size_t buf_size = MAX_DOUBLE_STR_BUF_SIZE;
-	int dec_exp;
-	int len;
-
-	/* Honor the user requested number of significant digits. */
-	if (0 <= precision) {
-		/* 
-		 * Do a quick and dirty conversion of a single digit to determine 
-		 * the decimal exponent.
-		 */
-		len = double_to_fixed_str(val, 1, -1, buf, buf_size, &dec_exp);
-		assert(0 < len);
-
-		precision = max(1, precision);
-
-		if (-4 <= dec_exp && dec_exp < precision) {
-			precision = precision - (dec_exp + 1);
-			return print_double_fixed(g, precision, width, 
-				flags | __PRINTF_FLAG_NOFRACZEROS, ps);
-		} else {
-			--precision;
-			return print_double_scientific(g, precision, width, 
-				flags | __PRINTF_FLAG_NOFRACZEROS, ps);
-		}
-	} else {
-		/* Convert to get the decimal exponent and digit count.*/
-		len = double_to_short_str(val, buf, buf_size, &dec_exp);
-		assert(0 < len);
-
-		if (flags & __PRINTF_FLAG_LEFTALIGNED) {
-			flags &= ~__PRINTF_FLAG_ZEROPADDED;
-		}
-
-		double_str_t val_str;
-		val_str.str = buf;
-		val_str.len = len;
-		val_str.neg = val.is_negative;
-		val_str.dec_exp = dec_exp;
-
-		int first_digit_pos = len + dec_exp;
-		int last_digit_pos = dec_exp;
-
-		/* The whole number (15 digits max) fits between dec places 15 .. -6 */
-		if (len <= 15 && -6 <= last_digit_pos && first_digit_pos <= 15) {
-			/* Precision needed for the last significant digit. */
-			precision = max(0, -val_str.dec_exp);
-			return print_double_str_fixed(&val_str, precision, width, flags, ps);
-		} else {
-			/* Use all produced digits. */
-			precision = val_str.len - 1;
-			return print_double_str_scient(&val_str, precision, width, flags, ps);
-		}
-	}
-}
-
-
-/** Convert, format and print a double according to the specifier. 
- *
- * Depending on the specifier it prints the double using the styles
- * %g, %f or %e by means of print_double_generic(), print_double_fixed(),
- * print_double_scientific().
- *
- * @param g     Double to print.
- * @param spec  Specifier of the style to print in; one of: 'g','G','f','F',
- *              'e','E'.
- * @param precision Number of fractional digits to display. If negative
- *              the shortest accurate number will be printed for style %g;
- *              negative precision defaults to 6 for styles %f, %e.
- * @param width Minimum number of characters to display. Pads 
- *              with '0' or ' ' depending on the set flags;
- * @param flags Printf flags.
- * @param ps    Printing functions.
- *
- * @return The number of characters printed; negative on failure.
- */
-static int print_double(double g, char spec, int precision, int width, 
-	uint32_t flags, printf_spec_t *ps)
-{
-	switch (spec) {
-	case 'F':
-		flags |= __PRINTF_FLAG_BIGCHARS;
-		/* Fall through.*/
-	case 'f':
-		precision = (precision < 0) ? 6 : precision;
-		return print_double_fixed(g, precision, width, flags, ps);
-
-	case 'E':
-		flags |= __PRINTF_FLAG_BIGCHARS;
-		/* Fall through.*/
-	case 'e':
-		precision = (precision < 0) ? 6 : precision;
-		return print_double_scientific(g, precision, width, flags, ps);
-
-	case 'G':
-		flags |= __PRINTF_FLAG_BIGCHARS;
-		/* Fall through.*/
-	case 'g':
-		return print_double_generic(g, precision, width, flags, ps);
-
-	default:
-		assert(false);
-		return -1;
-	}
-}
-
 /** Print formatted string.
  *
@@ -1370,5 +656,4 @@
 				case '#':
 					flags |= __PRINTF_FLAG_PREFIX;
-					flags |= __PRINTF_FLAG_DECIMALPT;
 					break;
 				case '-':
@@ -1416,10 +701,9 @@
 			
 			/* Precision and '*' operator */
-			int precision = -1;
+			int precision = 0;
 			if (uc == '.') {
 				i = nxt;
 				uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
 				if (isdigit(uc)) {
-					precision = 0;
 					while (true) {
 						precision *= 10;
@@ -1439,6 +723,6 @@
 					precision = (int) va_arg(ap, int);
 					if (precision < 0) {
-						/* Ignore negative precision - use default instead */
-						precision = -1;
+						/* Ignore negative precision */
+						precision = 0;
 					}
 				}
@@ -1490,6 +774,4 @@
 			 */
 			case 's':
-				precision = max(0,  precision);
-				
 				if (qualifier == PrintfQualifierLong)
 					retval = print_wstr(va_arg(ap, wchar_t *), width, precision, flags, ps);
@@ -1519,25 +801,4 @@
 				j = nxt;
 				goto next_char;
-				
-			/*
-			 * Floating point values
-			 */
-			case 'G':
-			case 'g':
-			case 'F':
-			case 'f':
-			case 'E':
-			case 'e':
-				retval = print_double(va_arg(ap, double), uc, precision, 
-					width, flags, ps);
-				
-				if (retval < 0) {
-					counter = -counter;
-					goto out;
-				}
-				
-				counter += retval;
-				j = nxt;
-				goto next_char;
 			
 			/*
Index: uspace/lib/c/generic/io/window.c
===================================================================
--- uspace/lib/c/generic/io/window.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/io/window.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,9 +40,8 @@
 #include <stdio.h>
 
-int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out, 
-    sysarg_t x_offset, sysarg_t y_offset)
+int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out)
 {
 	async_exch_t *exch = async_exchange_begin(sess);
-	int ret = async_req_2_2(exch, WINDOW_REGISTER, x_offset, y_offset, in, out);
+	int ret = async_req_0_2(exch, WINDOW_REGISTER, in, out);
 	async_exchange_end(exch);
 
Index: uspace/lib/c/generic/loc.c
===================================================================
--- uspace/lib/c/generic/loc.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/loc.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 #include <errno.h>
 #include <malloc.h>
-#include <stdbool.h>
+#include <bool.h>
 
 static FIBRIL_MUTEX_INITIALIZE(loc_supp_block_mutex);
Index: uspace/lib/c/generic/malloc.c
===================================================================
--- uspace/lib/c/generic/malloc.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/malloc.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 
 #include <malloc.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <as.h>
 #include <align.h>
@@ -289,5 +289,5 @@
 	size_t asize = ALIGN_UP(size, PAGE_SIZE);
 	void *astart = as_area_create(AS_AREA_ANY, asize,
-	    AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE);
+	    AS_AREA_WRITE | AS_AREA_READ);
 	if (astart == AS_MAP_FAILED)
 		return false;
Index: pace/lib/c/generic/pio_trace.c
===================================================================
--- uspace/lib/c/generic/pio_trace.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,145 +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 libc
- * @{
- */
-/** @file
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <malloc.h>
-#include <adt/list.h>
-#include <fibril_synch.h>
-#include <ddi.h>
-#include <str.h>
-
-
-typedef struct {
-	link_t link;
-	volatile void *base;
-	size_t size;
-	void *data;
-	trace_fnc log;
-} region_t;
-
-static inline region_t * region_instance(link_t *l)
-{
-	return list_get_instance(l, region_t, link);
-}
-
-static inline region_t * region_create(volatile void* base, size_t size,
-    trace_fnc log, void* data)
-{
-	region_t *new_reg = malloc(sizeof(region_t));
-	if (new_reg) {
-		link_initialize(&new_reg->link);
-		new_reg->base = base;
-		new_reg->data = data;
-		new_reg->size = size;
-		new_reg->log = log;
-	}
-	return new_reg;
-}
-
-static inline void region_destroy(region_t *r)
-{
-	free(r);
-}
-
-typedef struct {
-	list_t list;
-	fibril_rwlock_t guard;
-} pio_regions_t;
-
-static pio_regions_t * get_regions(void)
-{
-	static pio_regions_t regions = {
-		.list = {
-			.head = { &regions.list.head, &regions.list.head },
-		},
-		.guard = FIBRIL_RWLOCK_INITIALIZER(regions.guard),
-	};
-	return &regions;
-}
-
-
-void pio_trace_log(const volatile void *r, uint32_t val, bool write)
-{
-	pio_regions_t *regions = get_regions();
-	fibril_rwlock_read_lock(&regions->guard);
-	list_foreach(regions->list, it) {
-		assert(it);
-		region_t *reg = region_instance(it);
-		assert(reg);
-		if ((r >= reg->base) && (r < reg->base + reg->size)) {
-			if (reg->log)
-				reg->log(r, val, reg->base,
-				    reg->size, reg->data, write);
-			break;
-		}
-	}
-	fibril_rwlock_read_unlock(&regions->guard);
-}
-
-int pio_trace_enable(void *base, size_t size, trace_fnc log, void *data)
-{
-	pio_regions_t *regions = get_regions();
-	assert(regions);
-
-	region_t *region = region_create(base, size, log, data);
-	if (!region)
-		return ENOMEM;
-
-	fibril_rwlock_write_lock(&regions->guard);
-	list_append(&region->link, &regions->list);
-	fibril_rwlock_write_unlock(&regions->guard);
-	return EOK;
-}
-
-void pio_trace_disable(void *r)
-{
-	pio_regions_t *regions = get_regions();
-	assert(regions);
-
-	fibril_rwlock_write_lock(&regions->guard);
-	list_foreach_safe(regions->list, it, next) {
-		assert(it);
-		region_t *reg = region_instance(it);
-		assert(reg);
-		if (r >= reg->base && (r < reg->base + reg->size)) {
-				list_remove(&reg->link);
-				region_destroy(reg);
-		}
-	}
-	fibril_rwlock_write_unlock(&regions->guard);
-}
-
-/** @}
- */
Index: pace/lib/c/generic/power_of_ten.c
===================================================================
--- uspace/lib/c/generic/power_of_ten.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,187 +1,0 @@
-/*
- * Copyright (c) 2012 Adam Hraska
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 "private/power_of_ten.h"
-
-#include <ieee_double.h>
-#include <assert.h>
-
-/** Precomputed normalized rounded-up powers of 10^k.
- *
- * The powers were computed using arbitrary precision arithmetic
- * and rounded up to the top 64 significant bits. Therefore:
- *   10^dec_exp == significand * 2^bin_exp  +/- 0.5 ulp error
- *
- * The smallest interval of binary exponents computed by hand
- * is [-1083, 987]. Add 200 (exponent change > 3 * 64 bits) 
- * to both bounds just to be on the safe side; ie [-1283, 1187].
- */
-static struct {
-	uint64_t significand;
-	int16_t bin_exp;
-	int16_t dec_exp;
-} fp_powers_of_10[] = {
-	{ 0xb8e1cbc28bef0b69ULL, -1286, -368 },
-	{ 0x89bf722840327f82ULL, -1259, -360 },
-	{ 0xcd42a11346f34f7dULL, -1233, -352 },
-	{ 0x98ee4a22ecf3188cULL, -1206, -344 },
-	{ 0xe3e27a444d8d98b8ULL, -1180, -336 },
-	{ 0xa9c98d8ccb009506ULL, -1153, -328 },
-	{ 0xfd00b897478238d1ULL, -1127, -320 },
-	{ 0xbc807527ed3e12bdULL, -1100, -312 },
-	{ 0x8c71dcd9ba0b4926ULL, -1073, -304 },
-	{ 0xd1476e2c07286faaULL, -1047, -296 },
-	{ 0x9becce62836ac577ULL, -1020, -288 },
-	{ 0xe858ad248f5c22caULL, -994, -280 },
-	{ 0xad1c8eab5ee43b67ULL, -967, -272 },
-	{ 0x80fa687f881c7f8eULL, -940, -264 },
-	{ 0xc0314325637a193aULL, -914, -256 },
-	{ 0x8f31cc0937ae58d3ULL, -887, -248 },
-	{ 0xd5605fcdcf32e1d7ULL, -861, -240 },
-	{ 0x9efa548d26e5a6e2ULL, -834, -232 },
-	{ 0xece53cec4a314ebeULL, -808, -224 },
-	{ 0xb080392cc4349dedULL, -781, -216 },
-	{ 0x8380dea93da4bc60ULL, -754, -208 },
-	{ 0xc3f490aa77bd60fdULL, -728, -200 },
-	{ 0x91ff83775423cc06ULL, -701, -192 },
-	{ 0xd98ddaee19068c76ULL, -675, -184 },
-	{ 0xa21727db38cb0030ULL, -648, -176 },
-	{ 0xf18899b1bc3f8ca2ULL, -622, -168 },
-	{ 0xb3f4e093db73a093ULL, -595, -160 },
-	{ 0x8613fd0145877586ULL, -568, -152 },
-	{ 0xc7caba6e7c5382c9ULL, -542, -144 },
-	{ 0x94db483840b717f0ULL, -515, -136 },
-	{ 0xddd0467c64bce4a1ULL, -489, -128 },
-	{ 0xa54394fe1eedb8ffULL, -462, -120 },
-	{ 0xf64335bcf065d37dULL, -436, -112 },
-	{ 0xb77ada0617e3bbcbULL, -409, -104 },
-	{ 0x88b402f7fd75539bULL, -382, -96 },
-	{ 0xcbb41ef979346bcaULL, -356, -88 },
-	{ 0x97c560ba6b0919a6ULL, -329, -80 },
-	{ 0xe2280b6c20dd5232ULL, -303, -72 },
-	{ 0xa87fea27a539e9a5ULL, -276, -64 },
-	{ 0xfb158592be068d2fULL, -250, -56 },
-	{ 0xbb127c53b17ec159ULL, -223, -48 },
-	{ 0x8b61313bbabce2c6ULL, -196, -40 },
-	{ 0xcfb11ead453994baULL, -170, -32 },
-	{ 0x9abe14cd44753b53ULL, -143, -24 },
-	{ 0xe69594bec44de15bULL, -117, -16 },
-	{ 0xabcc77118461cefdULL, -90, -8 },
-	{ 0x8000000000000000ULL, -63, 0 },
-	{ 0xbebc200000000000ULL, -37, 8 },
-	{ 0x8e1bc9bf04000000ULL, -10, 16 },
-	{ 0xd3c21bcecceda100ULL, 16, 24 },
-	{ 0x9dc5ada82b70b59eULL, 43, 32 },
-	{ 0xeb194f8e1ae525fdULL, 69, 40 },
-	{ 0xaf298d050e4395d7ULL, 96, 48 },
-	{ 0x82818f1281ed44a0ULL, 123, 56 },
-	{ 0xc2781f49ffcfa6d5ULL, 149, 64 },
-	{ 0x90e40fbeea1d3a4bULL, 176, 72 },
-	{ 0xd7e77a8f87daf7fcULL, 202, 80 },
-	{ 0xa0dc75f1778e39d6ULL, 229, 88 },
-	{ 0xefb3ab16c59b14a3ULL, 255, 96 },
-	{ 0xb2977ee300c50fe7ULL, 282, 104 },
-	{ 0x850fadc09923329eULL, 309, 112 },
-	{ 0xc646d63501a1511eULL, 335, 120 },
-	{ 0x93ba47c980e98ce0ULL, 362, 128 },
-	{ 0xdc21a1171d42645dULL, 388, 136 },
-	{ 0xa402b9c5a8d3a6e7ULL, 415, 144 },
-	{ 0xf46518c2ef5b8cd1ULL, 441, 152 },
-	{ 0xb616a12b7fe617aaULL, 468, 160 },
-	{ 0x87aa9aff79042287ULL, 495, 168 },
-	{ 0xca28a291859bbf93ULL, 521, 176 },
-	{ 0x969eb7c47859e744ULL, 548, 184 },
-	{ 0xe070f78d3927556bULL, 574, 192 },
-	{ 0xa738c6bebb12d16dULL, 601, 200 },
-	{ 0xf92e0c3537826146ULL, 627, 208 },
-	{ 0xb9a74a0637ce2ee1ULL, 654, 216 },
-	{ 0x8a5296ffe33cc930ULL, 681, 224 },
-	{ 0xce1de40642e3f4b9ULL, 707, 232 },
-	{ 0x9991a6f3d6bf1766ULL, 734, 240 },
-	{ 0xe4d5e82392a40515ULL, 760, 248 },
-	{ 0xaa7eebfb9df9de8eULL, 787, 256 },
-	{ 0xfe0efb53d30dd4d8ULL, 813, 264 },
-	{ 0xbd49d14aa79dbc82ULL, 840, 272 },
-	{ 0x8d07e33455637eb3ULL, 867, 280 },
-	{ 0xd226fc195c6a2f8cULL, 893, 288 },
-	{ 0x9c935e00d4b9d8d2ULL, 920, 296 },
-	{ 0xe950df20247c83fdULL, 946, 304 },
-	{ 0xadd57a27d29339f6ULL, 973, 312 },
-	{ 0x81842f29f2cce376ULL, 1000, 320 },
-	{ 0xc0fe908895cf3b44ULL, 1026, 328 },
-	{ 0x8fcac257558ee4e6ULL, 1053, 336 },
-	{ 0xd6444e39c3db9b0aULL, 1079, 344 },
-	{ 0x9fa42700db900ad2ULL, 1106, 352 },
-	{ 0xede24ae798ec8284ULL, 1132, 360 },
-	{ 0xb13cc3832ef0c9acULL, 1159, 368 },
-	{ 0x840d57e2899d945fULL, 1186, 376 }
-};
-
-
-/** 
- * Returns the smallest precomputed power of 10 such that 
- *  binary_exp <= power_of_10.bin_exp
- * where
- *  10^decimal_exp = power_of_10.significand * 2^bin_exp 
- * with an error of 0.5 ulp in the significand.
- */
-void get_power_of_ten(int binary_exp, fp_num_t *power_of_10, int *decimal_exp)
-{
-	const int powers_count = sizeof(fp_powers_of_10) / sizeof(fp_powers_of_10[0]);
-	const int min_bin_exp = fp_powers_of_10[0].bin_exp;
-	const int max_bin_exp = fp_powers_of_10[powers_count - 1].bin_exp;
-	const int max_bin_exp_diff = 27;
-
-	assert(min_bin_exp <= binary_exp && binary_exp <= max_bin_exp);
-
-	/* 
-	 * Binary exponent difference between adjacent powers of 10 
-	 * is lg(10^8) = 26.575. The starting search index seed_idx
-	 * undershoots the actual position by less than 1.6%, ie it
-	 * skips 26.575/27 = 98.4% of all the smaller powers. This
-	 * translates to at most three extra tests. 
-	 */
-	int seed_idx = (binary_exp - min_bin_exp) / max_bin_exp_diff;
-
-	assert(fp_powers_of_10[seed_idx].bin_exp < binary_exp);
-
-	for (int i = seed_idx; i < powers_count; ++i) {
-		/* Found the smallest power of 10 with bin_exp >= binary_exp. */
-		if (binary_exp <= fp_powers_of_10[i].bin_exp) {
-			assert(fp_powers_of_10[i].bin_exp <= binary_exp + max_bin_exp_diff);
-
-			power_of_10->significand = fp_powers_of_10[i].significand;
-			power_of_10->exponent = fp_powers_of_10[i].bin_exp;
-			*decimal_exp = fp_powers_of_10[i].dec_exp;
-			return;
-		}
-	}
-
-	assert(false);
-}
-
Index: uspace/lib/c/generic/private/async.h
===================================================================
--- uspace/lib/c/generic/private/async.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/private/async.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 #include <fibril_synch.h>
 #include <sys/time.h>
-#include <stdbool.h>
+#include <bool.h>
 
 /** Structures of this type are used to track the timeout events. */
Index: pace/lib/c/generic/private/power_of_ten.h
===================================================================
--- uspace/lib/c/generic/private/power_of_ten.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,37 +1,0 @@
-/*
- * Copyright (c) 2012 Adam Hraska
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 POWER_OF_TEN_H_
-#define POWER_OF_TEN_H_
-
-/* Fwd decl. */
-struct fp_num_t_tag;
-
-extern void get_power_of_ten(int, struct fp_num_t_tag *, int *);
-
-#endif
Index: pace/lib/c/generic/stack.c
===================================================================
--- uspace/lib/c/generic/stack.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Copyright (c) 2012 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
- */
-
-#include <stack.h>
-#include <sysinfo.h>
-
-size_t stack_size_get(void)
-{
-	static sysarg_t stack_size = 0;
-
-	if (!stack_size)
-		sysinfo_get_value("default.stack_size", &stack_size);
-
-	return (size_t) stack_size;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/stdlib.c
===================================================================
--- uspace/lib/c/generic/stdlib.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/stdlib.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,10 +39,10 @@
 long int random(void)
 {
-	return glbl_seed = ((1366 * glbl_seed + 150889) % RAND_MAX);
+	return glbl_seed = ((1366*glbl_seed + 150889) % RAND_MAX);
 }
 
 void srandom(unsigned int seed)
 {
-	glbl_seed = seed % RAND_MAX;
+	glbl_seed = seed;
 }
 
Index: uspace/lib/c/generic/sysinfo.c
===================================================================
--- uspace/lib/c/generic/sysinfo.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/sysinfo.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #include <errno.h>
 #include <malloc.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <unistd.h>
 
Index: uspace/lib/c/generic/thread.c
===================================================================
--- uspace/lib/c/generic/thread.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/thread.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,4 @@
 #include <abi/proc/uarg.h>
 #include <fibril.h>
-#include <stack.h>
 #include <str.h>
 #include <async.h>
@@ -45,4 +44,8 @@
 #include <as.h>
 #include "private/thread.h"
+
+#ifndef THREAD_INITIAL_STACK_PAGES
+	#define THREAD_INITIAL_STACK_PAGES  2
+#endif
 
 /** Main thread function.
@@ -98,8 +101,7 @@
 		return ENOMEM;
 	
-	size_t stack_size = stack_size_get();
+	size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;
 	void *stack = as_area_create(AS_AREA_ANY, stack_size,
-	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
-	    AS_AREA_LATE_RESERVE);
+	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
 	if (stack == AS_MAP_FAILED) {
 		free(uarg);
Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/time.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 #include <sys/time.h>
 #include <time.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <libarch/barrier.h>
 #include <macros.h>
Index: uspace/lib/c/generic/tls.c
===================================================================
--- uspace/lib/c/generic/tls.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/generic/tls.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -51,5 +51,5 @@
  * @return Pointer to TCB.
  */
-tcb_t *tls_make(void)
+tcb_t *__make_tls(void)
 {
 	void *data;
@@ -57,5 +57,5 @@
 	size_t tls_size = &_tbss_end - &_tdata_start;
 	
-	tcb = tls_alloc_arch(&data, tls_size);
+	tcb = __alloc_tls(&data, tls_size);
 	if (!tcb)
 		return NULL;
@@ -74,8 +74,8 @@
 }
 
-void tls_free(tcb_t *tcb)
+void __free_tls(tcb_t *tcb)
 {
 	size_t tls_size = &_tbss_end - &_tdata_start;
-	tls_free_arch(tcb, tls_size);
+	__free_tls_arch(tcb, tls_size);
 }
 
Index: uspace/lib/c/include/adt/hash_table.h
===================================================================
--- uspace/lib/c/include/adt/hash_table.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/adt/hash_table.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <adt/list.h>
 #include <unistd.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <macros.h>
 
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/async.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #include <sys/time.h>
 #include <atomic.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <task.h>
 
Index: uspace/lib/c/include/atomicdflt.h
===================================================================
--- uspace/lib/c/include/atomicdflt.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/atomicdflt.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 
 #include <stdint.h>
-#include <stdbool.h>
+#include <bool.h>
 
 typedef struct atomic {
Index: uspace/lib/c/include/bd_srv.h
===================================================================
--- uspace/lib/c/include/bd_srv.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/bd_srv.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <async.h>
 #include <fibril_synch.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 
Index: uspace/lib/c/include/bool.h
===================================================================
--- uspace/lib/c/include/bool.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/c/include/bool.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,47 @@
+/*
+ * 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 libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_BOOL_H_
+#define LIBC_BOOL_H_
+
+#include <libarch/types.h>
+#include <abi/bool.h>
+
+#define false  0
+#define true   1
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/cfg.h
===================================================================
--- uspace/lib/c/include/cfg.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/cfg.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 #include <adt/list.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 /**
Index: uspace/lib/c/include/ddi.h
===================================================================
--- uspace/lib/c/include/ddi.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/ddi.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,7 +36,5 @@
 #define LIBC_DDI_H_
 
-#include <stdbool.h>
 #include <sys/types.h>
-#include <sys/time.h>
 #include <abi/ddi/irq.h>
 #include <task.h>
@@ -52,73 +50,6 @@
 extern int dmamem_unmap_anonymous(void *);
 
+extern int iospace_enable(task_id_t, void *, unsigned long);
 extern int pio_enable(void *, size_t, void **);
-
-typedef void (*trace_fnc)(const volatile void *place, uint32_t val,
-    volatile void* base, size_t size, void *data, bool write);
-
-extern int pio_trace_enable(void *, size_t, trace_fnc, void *);
-extern void pio_trace_log(const volatile void *, uint32_t val, bool write);
-extern void pio_trace_disable(void *);
-
-extern void pio_write_8(ioport8_t *, uint8_t);
-extern void pio_write_16(ioport16_t *, uint16_t);
-extern void pio_write_32(ioport32_t *, uint32_t);
-
-extern uint8_t pio_read_8(const ioport8_t *);
-extern uint16_t pio_read_16(const ioport16_t *);
-extern uint32_t pio_read_32(const ioport32_t *);
-
-static inline uint8_t pio_change_8(
-    ioport8_t *reg, uint8_t val, uint8_t mask, useconds_t delay)
-{
-	uint8_t v = pio_read_8(reg);
-	udelay(delay);
-	pio_write_8(reg, (v & ~mask) | val);
-	return v;
-}
-
-static inline uint16_t pio_change_16(
-    ioport16_t *reg, uint16_t val, uint16_t mask, useconds_t delay)
-{
-	uint16_t v = pio_read_16(reg);
-	udelay(delay);
-	pio_write_16(reg, (v & ~mask) | val);
-	return v;
-}
-
-static inline uint32_t pio_change_32(
-    ioport32_t *reg, uint32_t val, uint32_t mask, useconds_t delay)
-{
-	uint32_t v = pio_read_32(reg);
-	udelay(delay);
-	pio_write_32(reg, (v & ~mask) | val);
-	return v;
-}
-
-static inline uint8_t pio_set_8(ioport8_t *r, uint8_t v, useconds_t d)
-{
-	return pio_change_8(r, v, 0, d);
-}
-static inline uint16_t pio_set_16(ioport16_t *r, uint16_t v, useconds_t d)
-{
-	return pio_change_16(r, v, 0, d);
-}
-static inline uint32_t pio_set_32(ioport32_t *r, uint32_t v, useconds_t d)
-{
-	return pio_change_32(r, v, 0, d);
-}
-
-static inline uint8_t pio_clear_8(ioport8_t *r, uint8_t v, useconds_t d)
-{
-	return pio_change_8(r, 0, v, d);
-}
-static inline uint16_t pio_clear_16(ioport16_t *r, uint16_t v, useconds_t d)
-{
-	return pio_change_16(r, 0, v, d);
-}
-static inline uint32_t pio_clear_32(ioport32_t *r, uint32_t v, useconds_t d)
-{
-	return pio_change_32(r, 0, v, d);
-}
 
 extern int irq_register(int, int, int, irq_code_t *);
Index: uspace/lib/c/include/device/hw_res.h
===================================================================
--- uspace/lib/c/include/device/hw_res.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/device/hw_res.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #include <ipc/dev_iface.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #define DMA_MODE_ON_DEMAND  0
Index: uspace/lib/c/include/devman.h
===================================================================
--- uspace/lib/c/include/devman.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/devman.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <ipc/loc.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 
 extern async_exch_t *devman_exchange_begin_blocking(devman_interface_t);
Index: pace/lib/c/include/double_to_str.h
===================================================================
--- uspace/lib/c/include/double_to_str.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,55 +1,0 @@
-/*
- * Copyright (c) 2012 Adam Hraska
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 DOUBLE_TO_STR_H_
-#define DOUBLE_TO_STR_H_
-
-#include <unistd.h>
-
-/** Maximum number of digits double_to_*_str conversion functions produce. 
- *
- * Both double_to_short_str and double_to_fixed_str generate digits out
- * of a 64bit unsigned int number representation. The max number of 
- * of digits is therefore 20. Add 1 to help users who forget to reserve
- * space for a null terminator.
- */
-#define MAX_DOUBLE_STR_LEN (20 + 1)
-
-/** Maximum buffer size needed to store the output of double_to_*_str 
- *  functions. 
- */
-#define MAX_DOUBLE_STR_BUF_SIZE  21
-
-/* Fwd decl.*/
-struct ieee_double_t_tag;
-
-extern int double_to_short_str(struct ieee_double_t_tag, char *, size_t, int *);
-extern int double_to_fixed_str(struct ieee_double_t_tag, int, int, char *,
-    size_t, int *);
-
-#endif 
Index: uspace/lib/c/include/fibril_synch.h
===================================================================
--- uspace/lib/c/include/fibril_synch.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/fibril_synch.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <libarch/tls.h>
 #include <sys/time.h>
-#include <stdbool.h>
+#include <bool.h>
 
 typedef struct {
Index: pace/lib/c/include/ieee_double.h
===================================================================
--- uspace/lib/c/include/ieee_double.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*
- * Copyright (c) 2012 Adam Hraska
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 IEEE_DOUBLE_H_
-#define IEEE_DOUBLE_H_
-
-#include <stdint.h>
-#include <stdbool.h>
-
-/** Represents a non-negative floating point number: significand * 2^exponent */
-typedef struct fp_num_t_tag {
-	/** Significand (aka mantissa). */
-	uint64_t significand;
-	/** Binary exponent. */
-	int exponent;
-} fp_num_t;
-
-/** Double number description according to IEEE 754. */
-typedef struct ieee_double_t_tag {
-	/** The number is a NaN or infinity. */
-	bool is_special;
-	/** Not a number. */
-	bool is_nan;
-	bool is_negative;
-	/** The number denoted infinity. */
-	bool is_infinity;
-	/** The number could not be represented as a normalized double. */
-	bool is_denormal;
-	/**
-	 * The predecessor double is closer than the successor. This happens 
-	 * if a normal number is of the form 2^k and it is not the smallest
-	 * normal number. 
-	 */
-	bool is_accuracy_step;
-	/** 
-	 * If !is_special the double's value is:
-	 *   pos_val.significand * 2^pos_val.exponent
-	 */
-	fp_num_t pos_val;
-} ieee_double_t;
-
-extern ieee_double_t extract_ieee_double(double);
-
-#endif
Index: uspace/lib/c/include/inet/iplink_srv.h
===================================================================
--- uspace/lib/c/include/inet/iplink_srv.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/inet/iplink_srv.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #include <async.h>
 #include <fibril_synch.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 
Index: uspace/lib/c/include/io/charfield.h
===================================================================
--- uspace/lib/c/include/io/charfield.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/io/charfield.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <io/color.h>
 #include <io/style.h>
Index: uspace/lib/c/include/io/con_srv.h
===================================================================
--- uspace/lib/c/include/io/con_srv.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/io/con_srv.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #include <io/pixel.h>
 #include <io/style.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/time.h>
 #include <sys/types.h>
Index: uspace/lib/c/include/io/console.h
===================================================================
--- uspace/lib/c/include/io/console.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/io/console.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 #include <io/keycode.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <stdio.h>
 
Index: uspace/lib/c/include/io/klog.h
===================================================================
--- uspace/lib/c/include/io/klog.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/io/klog.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,5 +42,4 @@
 extern size_t klog_write(const void *, size_t);
 extern void klog_update(void);
-extern void klog_command(const void *, size_t);
 extern int klog_printf(const char *, ...)
     PRINTF_ATTRIBUTE(1, 2);
Index: uspace/lib/c/include/io/pixel.h
===================================================================
--- uspace/lib/c/include/io/pixel.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/io/pixel.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,6 +42,4 @@
 	((channel) >> (8 - (bits)))
 
-#define INVERT(pixel) ((pixel) ^ 0x00ffffff)
-
 #define ALPHA(pixel)  ((pixel) >> 24)
 #define RED(pixel)    (((pixel) & 0x00ff0000) >> 16)
Index: uspace/lib/c/include/io/pixelmap.h
===================================================================
--- uspace/lib/c/include/io/pixelmap.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/io/pixelmap.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -52,11 +52,7 @@
     sysarg_t y)
 {
-	if (x < pixelmap->width && y < pixelmap->height) {
-		size_t offset = y * pixelmap->width + x;
-		pixel_t *pixel = pixelmap->data + offset;
-		return pixel;
-	} else {
-		return NULL;
-	}
+	size_t offset = y * pixelmap->width + x;
+	pixel_t *pixel = pixelmap->data + offset;
+	return pixel;
 }
 
Index: uspace/lib/c/include/io/window.h
===================================================================
--- uspace/lib/c/include/io/window.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/io/window.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 #define LIBC_IO_WINDOW_H_
 
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 #include <async.h>
@@ -71,6 +71,4 @@
 	ET_POSITION_EVENT,
 	ET_SIGNAL_EVENT,
-	ET_WINDOW_FOCUS,
-	ET_WINDOW_UNFOCUS,
 	ET_WINDOW_RESIZE,
 	ET_WINDOW_REFRESH,
@@ -102,5 +100,5 @@
 } window_grab_flags_t;
 
-extern int win_register(async_sess_t *, service_id_t *, service_id_t *, sysarg_t, sysarg_t);
+extern int win_register(async_sess_t *, service_id_t *, service_id_t *);
 
 extern int win_get_event(async_sess_t *, window_event_t *);
Index: uspace/lib/c/include/ipc/vfs.h
===================================================================
--- uspace/lib/c/include/ipc/vfs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/ipc/vfs.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #include <ipc/common.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #define FS_NAME_MAXLEN  20
Index: uspace/lib/c/include/loc.h
===================================================================
--- uspace/lib/c/include/loc.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/loc.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #include <ipc/loc.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 
 typedef void (*loc_cat_change_cb_t)(void);
Index: uspace/lib/c/include/macros.h
===================================================================
--- uspace/lib/c/include/macros.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/macros.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,6 +38,4 @@
 #define min(a, b)  ((a) < (b) ? (a) : (b))
 #define max(a, b)  ((a) > (b) ? (a) : (b))
-#define abs(a)     ((a) >= 0 ? (a) : (-a))
-
 
 #define KiB2SIZE(kb)  ((kb) << 10)
@@ -62,10 +60,4 @@
 #endif
 
-#define _paddname(line) PADD_ ## line ## __
-#define _padd(width, line) uint ## width ## _t _paddname(line)
-#define PADD32 _padd(32, __LINE__)
-#define PADD16 _padd(16, __LINE__)
-#define PADD8 _padd(8, __LINE__)
-
 /** @}
  */
Index: uspace/lib/c/include/nic/nic.h
===================================================================
--- uspace/lib/c/include/nic/nic.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/nic/nic.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 
 #include <nic/eth_phys.h>
-#include <stdbool.h>
+#include <bool.h>
 
 /** Ethernet address length. */
Index: uspace/lib/c/include/rtld/dynamic.h
===================================================================
--- uspace/lib/c/include/rtld/dynamic.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/rtld/dynamic.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 #define LIBC_RTLD_DYNAMIC_H_
 
-#include <stdbool.h>
+#include <bool.h>
 #include <rtld/elf_dyn.h>
 #include <libarch/rtld/dynamic.h>
Index: uspace/lib/c/include/sort.h
===================================================================
--- uspace/lib/c/include/sort.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/sort.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 typedef int (* sort_cmp_t)(void *, void *, void *);
Index: pace/lib/c/include/stack.h
===================================================================
--- uspace/lib/c/include/stack.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2012 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_STACK_H_
-#define LIBC_STACK_H_
-
-#include <libarch/types.h>
-
-extern size_t stack_size_get(void);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/stacktrace.h
===================================================================
--- uspace/lib/c/include/stacktrace.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/stacktrace.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 typedef struct {
Index: uspace/lib/c/include/stats.h
===================================================================
--- uspace/lib/c/include/stats.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/stats.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <thread.h>
 #include <stdint.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 #include <abi/sysinfo.h>
Index: pace/lib/c/include/stdbool.h
===================================================================
--- uspace/lib/c/include/stdbool.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,49 +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 libc
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_BOOL_H_
-#define LIBC_BOOL_H_
-
-#include <libarch/types.h>
-#include <abi/bool.h>
-
-#define false  0
-#define true   1
-
-#define __bool_true_false_are_defined 1
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/stdio.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,4 @@
 #include <str.h>
 #include <io/verify.h>
-#include <abi/klog.h>
 
 #define EOF  (-1)
@@ -52,5 +51,5 @@
 		int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \
 		if (_n > 0) \
-			(void) __SYSCALL3(SYS_KLOG, KLOG_WRITE, (sysarg_t) _buf, str_size(_buf)); \
+			(void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) _buf, str_size(_buf)); \
 	}
 
Index: uspace/lib/c/include/str.h
===================================================================
--- uspace/lib/c/include/str.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/str.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <mem.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #define U_SPECIAL  '?'
Index: uspace/lib/c/include/sys/stat.h
===================================================================
--- uspace/lib/c/include/sys/stat.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/sys/stat.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <ipc/vfs.h>
 #include <ipc/loc.h>
Index: uspace/lib/c/include/sysinfo.h
===================================================================
--- uspace/lib/c/include/sysinfo.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/sysinfo.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <abi/sysinfo.h>
 
Index: uspace/lib/c/include/tls.h
===================================================================
--- uspace/lib/c/include/tls.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/c/include/tls.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -48,8 +48,8 @@
 extern char _tbss_end;
 
-extern tcb_t *tls_make(void);
-extern tcb_t *tls_alloc_arch(void **, size_t);
-extern void tls_free(tcb_t *);
-extern void tls_free_arch(tcb_t *, size_t);
+extern tcb_t *__make_tls(void);
+extern tcb_t *__alloc_tls(void **, size_t);
+extern void __free_tls(tcb_t *);
+extern void __free_tls_arch(tcb_t *, size_t);
 
 #ifdef CONFIG_TLS_VARIANT_1
Index: uspace/lib/clui/tinput.c
===================================================================
--- uspace/lib/clui/tinput.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/clui/tinput.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <errno.h>
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <tinput.h>
 
@@ -104,7 +104,5 @@
 static void tinput_display_tail(tinput_t *ti, size_t start, size_t pad)
 {
-	wchar_t *dbuf = malloc((INPUT_MAX_SIZE + 1) * sizeof(wchar_t));
-	if (!dbuf)
-		return;	
+	wchar_t dbuf[INPUT_MAX_SIZE + 1];
 	
 	size_t sa;
@@ -148,6 +146,4 @@
 	
 	console_flush(ti->console);
-
-	free(dbuf);
 }
 
Index: uspace/lib/draw/codec/tga.c
===================================================================
--- uspace/lib/draw/codec/tga.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/draw/codec/tga.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #include <byteorder.h>
 #include <align.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <pixconv.h>
 #include "tga.h"
Index: uspace/lib/draw/drawctx.c
===================================================================
--- uspace/lib/draw/drawctx.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/draw/drawctx.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -129,48 +129,26 @@
 	}
 
-	bool transfer_fast = source_is_fast(context->source)
-	    && (context->shall_clip == false)
-	    && (context->mask == NULL)
-	    && (context->compose == compose_src || context->compose == compose_over);
-
-	if (transfer_fast) {
-
-		for (sysarg_t _y = y; _y < y + height; ++_y) {
-			pixel_t *src = source_direct_access(context->source, x, _y);
-			pixel_t *dst = pixelmap_pixel_at(surface_pixmap_access(context->surface), x, _y);
-			if (src && dst) {
-				sysarg_t count = width;
-				while (count-- != 0) {
-					*dst++ = *src++;
-				}
+	bool clipped = false;
+	bool masked = false;
+
+	for (sysarg_t _y = y; _y < y + height; ++_y) {
+		for (sysarg_t _x = x; _x < x + width; ++_x) {
+			if (context->shall_clip) {
+				clipped = _x < context->clip_x && _x >= context->clip_width
+				    && _y < context->clip_y && _y >= context->clip_height;
+			}
+			
+			if (context->mask) {
+				pixel_t p = surface_get_pixel(context->mask, _x, _y);
+				masked = p > 0 ? false : true;
+			}
+
+			if (!clipped && !masked) {
+				pixel_t p_src = source_determine_pixel(context->source, _x, _y);
+				pixel_t p_dst = surface_get_pixel(context->surface, _x, _y);
+				pixel_t p_res = context->compose(p_src, p_dst);
+				surface_put_pixel(context->surface, _x, _y, p_res);
 			}
 		}
-		surface_add_damaged_region(context->surface, x, y, width, height);
-
-	} else {
-
-		bool clipped = false;
-		bool masked = false;
-		for (sysarg_t _y = y; _y < y + height; ++_y) {
-			for (sysarg_t _x = x; _x < x + width; ++_x) {
-				if (context->shall_clip) {
-					clipped = _x < context->clip_x && _x >= context->clip_width
-					    && _y < context->clip_y && _y >= context->clip_height;
-				}
-
-				if (context->mask) {
-					pixel_t p = surface_get_pixel(context->mask, _x, _y);
-					masked = p > 0 ? false : true;
-				}
-
-				if (!clipped && !masked) {
-					pixel_t p_src = source_determine_pixel(context->source, _x, _y);
-					pixel_t p_dst = surface_get_pixel(context->surface, _x, _y);
-					pixel_t p_res = context->compose(p_src, p_dst);
-					surface_put_pixel(context->surface, _x, _y, p_res);
-				}
-			}
-		}
-
 	}
 }
Index: uspace/lib/draw/drawctx.h
===================================================================
--- uspace/lib/draw/drawctx.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/draw/drawctx.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <compose.h>
Index: uspace/lib/draw/path.c
===================================================================
--- uspace/lib/draw/path.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/draw/path.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <malloc.h>
 
Index: uspace/lib/draw/source.c
===================================================================
--- uspace/lib/draw/source.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/draw/source.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -90,24 +90,4 @@
 }
 
-bool source_is_fast(source_t *source)
-{
-	return (source->mask == NULL)
-	    && (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0))
-	    && (source->texture != NULL)
-	    && (source->texture_tile == false)
-	    && transform_is_fast(&source->transform);
-}
-
-pixel_t *source_direct_access(source_t *source, double x, double y)
-{
-	assert(source_is_fast(source));
-
-	long _x = (long) (x + source->transform.m[0][2]);
-	long _y = (long) (y + source->transform.m[1][2]);
-
-	return pixelmap_pixel_at(
-	    surface_pixmap_access(source->texture), (sysarg_t) _x, (sysarg_t) _y);
-}
-
 pixel_t source_determine_pixel(source_t *source, double x, double y)
 {
Index: uspace/lib/draw/source.h
===================================================================
--- uspace/lib/draw/source.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/draw/source.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #include <transform.h>
@@ -71,6 +71,4 @@
 extern void source_set_mask(source_t *, surface_t *, bool);
 
-extern bool source_is_fast(source_t *);
-extern pixel_t *source_direct_access(source_t *, double, double);
 extern pixel_t source_determine_pixel(source_t *, double, double);
 
Index: uspace/lib/draw/surface.c
===================================================================
--- uspace/lib/draw/surface.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/draw/surface.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -143,17 +143,4 @@
 }
 
-void surface_add_damaged_region(surface_t *surface, surface_coord_t x, surface_coord_t y,
-    surface_coord_t width, surface_coord_t height)
-{
-	surface->dirty_x_lo = surface->dirty_x_lo > x ? x : surface->dirty_x_lo;
-	surface->dirty_y_lo = surface->dirty_y_lo > y ? y : surface->dirty_y_lo;
-
-	surface_coord_t x_hi = x + width - 1;
-	surface_coord_t y_hi = y + height - 1;
-
-	surface->dirty_x_hi = surface->dirty_x_hi < x_hi ? x_hi : surface->dirty_x_hi;
-	surface->dirty_y_hi = surface->dirty_y_hi < y_hi ? y_hi : surface->dirty_y_hi;
-}
-
 void surface_reset_damaged_region(surface_t *surface)
 {
@@ -171,10 +158,16 @@
 	surface->dirty_y_hi = surface->dirty_y_hi < y ? y : surface->dirty_y_hi;
 
-	pixelmap_put_pixel(&surface->pixmap, x, y, pixel);
+	if (x < surface->pixmap.width && y < surface->pixmap.height) {
+		pixelmap_put_pixel(&surface->pixmap, x, y, pixel);
+	}
 }
 
 pixel_t surface_get_pixel(surface_t *surface, surface_coord_t x, surface_coord_t y)
 {
-	return pixelmap_get_pixel(&surface->pixmap, x, y);
+	if (x < surface->pixmap.width && y < surface->pixmap.height) {
+		return pixelmap_get_pixel(&surface->pixmap, x, y);
+	} else {
+		return 0;
+	}
 }
 
Index: uspace/lib/draw/surface.h
===================================================================
--- uspace/lib/draw/surface.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/draw/surface.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <io/pixelmap.h>
 
@@ -61,6 +61,4 @@
 extern void surface_get_damaged_region(surface_t *, surface_coord_t *, surface_coord_t *,
     surface_coord_t *, surface_coord_t *);
-extern void surface_add_damaged_region(surface_t *, surface_coord_t , surface_coord_t ,
-    surface_coord_t , surface_coord_t );
 extern void surface_reset_damaged_region(surface_t *);
 
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/drv/generic/driver.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -45,5 +45,5 @@
 #include <stdio.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <stdlib.h>
Index: uspace/lib/drv/include/ddf/log.h
===================================================================
--- uspace/lib/drv/include/ddf/log.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/drv/include/ddf/log.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,11 +44,4 @@
     size_t);
 
-#define ddf_log_fatal(msg...) ddf_msg(LVL_FATAL, msg)
-#define ddf_log_error(msg...) ddf_msg(LVL_ERROR, msg)
-#define ddf_log_warning(msg...) ddf_msg(LVL_WARN, msg)
-#define ddf_log_note(msg...) ddf_msg(LVL_NOTE, msg)
-#define ddf_log_debug(msg...) ddf_msg(LVL_DEBUG, msg)
-#define ddf_log_verbose(msg...) ddf_msg(LVL_DEBUG2, msg)
-
 #endif
 
Index: uspace/lib/drv/include/usbhc_iface.h
===================================================================
--- uspace/lib/drv/include/usbhc_iface.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/drv/include/usbhc_iface.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,5 +42,5 @@
 #include "ddf/driver.h"
 #include <usb/usb.h>
-#include <stdbool.h>
+#include <bool.h>
 
 int usbhc_request_address(async_exch_t *, usb_address_t *, bool, usb_speed_t);
Index: uspace/lib/ext2/Makefile
===================================================================
--- uspace/lib/ext2/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 Jakub Jermar
+# Copyright (c) 2010 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 = ../..
+LIBRARY = libext2
+EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
+LIBS = $(LIBBLOCK_PREFIX)/libblock.a
+
+SOURCES = \
+	libext2_filesystem.c \
+	libext2_superblock.c \
+	libext2_block_group.c \
+	libext2_inode.c \
+	libext2_directory.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/ext2/libext2.h
===================================================================
--- uspace/lib/ext2/libext2.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef LIBEXT2_LIBEXT2_H_
+#define LIBEXT2_LIBEXT2_H_
+
+#include "libext2_superblock.h"
+#include "libext2_block_group.h"
+#include "libext2_inode.h"
+#include "libext2_filesystem.h"
+#include "libext2_directory.h"
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_block_group.c
===================================================================
--- uspace/lib/ext2/libext2_block_group.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_block_group.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include "libext2.h"
+#include "libext2_block_group.h"
+#include <byteorder.h>
+
+/**
+ * Get block ID corresponding to the block bitmap of this block group
+ * 
+ * @param bg pointer to block group descriptor
+ */
+uint32_t ext2_block_group_get_block_bitmap_block(ext2_block_group_t *bg)
+{
+	return uint32_t_le2host(bg->block_bitmap_block);
+}
+
+/**
+ * Get block ID corresponding to the inode bitmap of this block group
+ * 
+ * @param bg pointer to block group descriptor
+ */
+uint32_t ext2_block_group_get_inode_bitmap_block(ext2_block_group_t *bg)
+{
+	return uint32_t_le2host(bg->inode_bitmap_block);
+}
+
+/**
+ * Get block ID of first block in inode table
+ * 
+ * @param bg pointer to block group descriptor
+ */
+uint32_t ext2_block_group_get_inode_table_first_block(ext2_block_group_t *bg)
+{
+	return uint32_t_le2host(bg->inode_table_first_block);
+}
+
+/**
+ * Get amount of free blocks in this block group
+ * 
+ * @param bg pointer to block group descriptor
+ */
+uint16_t ext2_block_group_get_free_block_count(ext2_block_group_t *bg)
+{
+	return uint16_t_le2host(bg->free_block_count);
+}
+
+/**
+ * Set amount of free blocks in this block group
+ * 
+ * @param bg pointer to block group descriptor
+ * @param val new value
+ */
+void ext2_block_group_set_free_block_count(ext2_block_group_t *bg,
+	uint16_t val)
+{
+	bg->free_block_count = host2uint16_t_le(val);
+}
+
+/**
+ * Get amount of free inodes in this block group
+ * 
+ * @param bg pointer to block group descriptor
+ */
+uint16_t ext2_block_group_get_free_inode_count(ext2_block_group_t *bg)
+{
+	return uint16_t_le2host(bg->free_inode_count);
+}
+
+/**
+ * Get amount of inodes allocated for directories
+ * 
+ * @param bg pointer to block group descriptor
+ */
+uint16_t ext2_block_group_get_directory_inode_count(ext2_block_group_t *bg)
+{
+	return uint16_t_le2host(bg->directory_inode_count);
+}
+
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_block_group.h
===================================================================
--- uspace/lib/ext2/libext2_block_group.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_block_group.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef LIBEXT2_LIBEXT2_BLOCK_GROUP_H_
+#define LIBEXT2_LIBEXT2_BLOCK_GROUP_H_
+
+#include <block.h>
+
+typedef struct ext2_block_group {
+	uint32_t block_bitmap_block; // Block ID for block bitmap
+	uint32_t inode_bitmap_block; // Block ID for inode bitmap
+	uint32_t inode_table_first_block; // Block ID of first block of inode table 
+	uint16_t free_block_count; // Count of free blocks
+	uint16_t free_inode_count; // Count of free inodes
+	uint16_t directory_inode_count; // Number of inodes allocated to directories
+} ext2_block_group_t;
+
+typedef struct ext2_block_group_ref {
+	block_t *block; // Reference to a block containing this block group descr
+	ext2_block_group_t *block_group;
+} ext2_block_group_ref_t;
+
+#define EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE 32
+
+extern uint32_t	ext2_block_group_get_block_bitmap_block(ext2_block_group_t *);
+extern uint32_t	ext2_block_group_get_inode_bitmap_block(ext2_block_group_t *);
+extern uint32_t	ext2_block_group_get_inode_table_first_block(ext2_block_group_t *);
+extern uint16_t	ext2_block_group_get_free_block_count(ext2_block_group_t *);
+extern uint16_t	ext2_block_group_get_free_inode_count(ext2_block_group_t *);
+extern uint16_t	ext2_block_group_get_directory_inode_count(ext2_block_group_t *);
+
+extern void	ext2_block_group_set_free_block_count(ext2_block_group_t *, uint16_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_directory.c
===================================================================
--- uspace/lib/ext2/libext2_directory.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_directory.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include "libext2.h"
+#include "libext2_directory.h"
+#include <byteorder.h>
+#include <errno.h>
+#include <assert.h>
+
+static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
+    uint32_t block_size);
+
+/**
+ * Get inode number for the directory entry
+ * 
+ * @param de pointer to linked list directory entry
+ */
+uint32_t ext2_directory_entry_ll_get_inode(ext2_directory_entry_ll_t *de)
+{
+	return uint32_t_le2host(de->inode);
+}
+
+/**
+ * Get length of the directory entry
+ * 
+ * @param de pointer to linked list directory entry
+ */
+uint16_t ext2_directory_entry_ll_get_entry_length(
+    ext2_directory_entry_ll_t *de)
+{
+	return uint16_t_le2host(de->entry_length);
+}
+
+/**
+ * Get length of the name stored in the directory entry
+ * 
+ * @param de pointer to linked list directory entry
+ */
+uint16_t ext2_directory_entry_ll_get_name_length(
+    ext2_superblock_t *sb, ext2_directory_entry_ll_t *de)
+{
+	if (ext2_superblock_get_rev_major(sb) == 0 &&
+	    ext2_superblock_get_rev_minor(sb) < 5) {
+		return ((uint16_t)de->name_length_high) << 8 | 
+		    ((uint16_t)de->name_length);
+	}
+	return de->name_length;
+}
+
+/**
+ * Initialize a directory iterator
+ * 
+ * @param it pointer to iterator to initialize
+ * @param fs pointer to filesystem structure
+ * @param inode pointer to inode reference structure
+ * @param pos position within inode to start at, 0 is the first entry
+ * @return EOK on success or negative error code on failure
+ */
+int ext2_directory_iterator_init(ext2_directory_iterator_t *it,
+    ext2_filesystem_t *fs, ext2_inode_ref_t *inode_ref, aoff64_t pos)
+{	
+	it->inode_ref = inode_ref;
+	it->fs = fs;
+	it->current = NULL;
+	it->current_offset = 0;
+	it->current_block = NULL;
+	
+	return ext2_directory_iterator_seek(it, pos);
+}
+
+/**
+ * Advance the directory iterator to the next entry
+ * 
+ * @param it pointer to iterator to initialize
+ * @return EOK on success or negative error code on failure
+ */
+int ext2_directory_iterator_next(ext2_directory_iterator_t *it)
+{
+	uint16_t skip;
+	
+	assert(it->current != NULL);
+	
+	skip = ext2_directory_entry_ll_get_entry_length(it->current);
+	
+	return ext2_directory_iterator_seek(it, it->current_offset + skip);
+}
+
+/**
+ * Seek the directory iterator to the given byte offset within the inode.
+ * 
+ * @param it pointer to iterator to initialize
+ * @return EOK on success or negative error code on failure
+ */
+int ext2_directory_iterator_seek(ext2_directory_iterator_t *it, aoff64_t pos)
+{
+	int rc;
+	
+	uint64_t size;
+	aoff64_t current_block_idx;
+	aoff64_t next_block_idx;
+	uint32_t next_block_phys_idx;
+	uint32_t block_size;
+	
+	size = ext2_inode_get_size(it->fs->superblock, it->inode_ref->inode);
+	
+	/* The iterator is not valid until we seek to the desired position */
+	it->current = NULL;
+	
+	/* Are we at the end? */
+	if (pos >= size) {		
+		if (it->current_block) {
+			rc = block_put(it->current_block);
+			it->current_block = NULL;
+			if (rc != EOK) {
+				return rc;
+			}
+		}
+		
+		it->current_offset = pos;
+		return EOK;
+	}
+	
+	block_size = ext2_superblock_get_block_size(it->fs->superblock);
+	current_block_idx = it->current_offset / block_size;
+	next_block_idx = pos / block_size;
+	
+	/* If we don't have a block or are moving accross block boundary,
+	 * we need to get another block
+	 */
+	if (it->current_block == NULL || current_block_idx != next_block_idx) {		
+		if (it->current_block) {
+			rc = block_put(it->current_block);
+			it->current_block = NULL;
+			if (rc != EOK) {
+				return rc;
+			}
+		}
+		
+		rc = ext2_filesystem_get_inode_data_block_index(it->fs,
+		    it->inode_ref->inode, next_block_idx, &next_block_phys_idx);
+		if (rc != EOK) {
+			return rc;
+		}
+		
+		rc = block_get(&it->current_block, it->fs->device, next_block_phys_idx,
+		    BLOCK_FLAGS_NONE);
+		if (rc != EOK) {
+			it->current_block = NULL;
+			return rc;
+		}
+	}
+	
+	it->current_offset = pos;
+	return ext2_directory_iterator_set(it, block_size);
+}
+
+/** Setup the entry at the current iterator offset.
+ * 
+ * This function checks the validity of the directory entry,
+ * before setting the data pointer.
+ *
+ * @return EOK on success or error code on failure 
+ */
+static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
+    uint32_t block_size)
+{
+	uint32_t offset_in_block = it->current_offset % block_size;
+	
+	it->current = NULL;
+	
+	/* Ensure proper alignment */
+	if ((offset_in_block % 4) != 0) {
+		return EIO;
+	}
+	
+	/* Ensure that the core of the entry does not overflow the block */
+	if (offset_in_block > block_size - 8) {
+		return EIO;
+	}
+	
+	ext2_directory_entry_ll_t *entry = it->current_block->data + offset_in_block;
+	
+	/* Ensure that the whole entry does not overflow the block */
+	uint16_t length = ext2_directory_entry_ll_get_entry_length(entry);
+	if (offset_in_block + length > block_size) {
+		return EIO;
+	}
+	
+	/* Ensure the name length is not too large */
+	if (ext2_directory_entry_ll_get_name_length(it->fs->superblock, 
+	    entry) > length-8) {
+		return EIO;
+	}
+	
+	it->current = entry;
+	return EOK;
+}
+
+/**
+ * Release all resources asociated with the directory iterator
+ * 
+ * @param it pointer to iterator to initialize
+ * @return EOK on success or negative error code on failure
+ */
+int ext2_directory_iterator_fini(ext2_directory_iterator_t *it)
+{
+	int rc;
+	
+	it->fs = NULL;
+	it->inode_ref = NULL;
+	it->current = NULL;
+	
+	if (it->current_block) {
+		rc = block_put(it->current_block);
+		if (rc != EOK) {
+			return rc;
+		}
+	}
+	
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_directory.h
===================================================================
--- uspace/lib/ext2/libext2_directory.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_directory.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef LIBEXT2_LIBEXT2_DIRECTORY_H_
+#define LIBEXT2_LIBEXT2_DIRECTORY_H_
+
+#include <block.h>
+#include "libext2_filesystem.h"
+#include "libext2_inode.h"
+
+/**
+ * Linked list directory entry structure
+ */
+typedef struct ext2_directory_entry_ll {
+	uint32_t inode; // Inode for the entry
+	uint16_t entry_length; // Distance to the next directory entry
+	uint8_t name_length; // Lower 8 bits of name length
+	union {
+		uint8_t name_length_high; // Higher 8 bits of name length
+		uint8_t inode_type; // Type of referenced inode (in rev >= 0.5)
+	} __attribute__ ((packed));
+	uint8_t name; // First byte of name, if present
+} __attribute__ ((packed)) ext2_directory_entry_ll_t;
+
+typedef struct ext2_directory_iterator {
+	ext2_filesystem_t *fs;
+	ext2_inode_ref_t *inode_ref;
+	block_t *current_block;
+	aoff64_t current_offset;
+	ext2_directory_entry_ll_t *current;
+} ext2_directory_iterator_t;
+
+
+extern uint32_t	ext2_directory_entry_ll_get_inode(ext2_directory_entry_ll_t *);
+extern uint16_t	ext2_directory_entry_ll_get_entry_length(
+    ext2_directory_entry_ll_t *);
+extern uint16_t	ext2_directory_entry_ll_get_name_length(
+    ext2_superblock_t *, ext2_directory_entry_ll_t *);
+
+extern int ext2_directory_iterator_init(ext2_directory_iterator_t *,
+    ext2_filesystem_t *, ext2_inode_ref_t *, aoff64_t);
+extern int ext2_directory_iterator_next(ext2_directory_iterator_t *);
+extern int ext2_directory_iterator_seek(ext2_directory_iterator_t *, aoff64_t pos);
+extern int ext2_directory_iterator_fini(ext2_directory_iterator_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_filesystem.c
===================================================================
--- uspace/lib/ext2/libext2_filesystem.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_filesystem.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,532 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include "libext2_filesystem.h"
+#include "libext2_superblock.h"
+#include "libext2_block_group.h"
+#include "libext2_inode.h"
+#include <errno.h>
+#include <block.h>
+#include <malloc.h>
+#include <assert.h>
+#include <byteorder.h>
+
+/**
+ * Initialize an instance of filesystem on the device.
+ * This function reads superblock from the device and
+ * initializes libblock cache with appropriate logical block size.
+ * 
+ * @param fs			Pointer to ext2_filesystem_t to initialize
+ * @param service_id	Service ID of the block device
+ * 
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_init(ext2_filesystem_t *fs, service_id_t service_id)
+{
+	int rc;
+	ext2_superblock_t *temp_superblock;
+	size_t block_size;
+	
+	fs->device = service_id;
+	
+	rc = block_init(EXCHANGE_SERIALIZE, fs->device, 2048);
+	if (rc != EOK) {
+		return rc;
+	}
+	
+	rc = ext2_superblock_read_direct(fs->device, &temp_superblock);
+	if (rc != EOK) {
+		block_fini(fs->device);
+		return rc;
+	}
+	
+	block_size = ext2_superblock_get_block_size(temp_superblock);
+	
+	if (block_size > EXT2_MAX_BLOCK_SIZE) {
+		block_fini(fs->device);
+		return ENOTSUP;
+	}
+	
+	rc = block_cache_init(service_id, block_size, 0, CACHE_MODE_WT);
+	if (rc != EOK) {
+		block_fini(fs->device);
+		return rc;
+	}
+	
+	fs->superblock = temp_superblock;
+	
+	return EOK; 
+}
+
+/**
+ * Check filesystem for sanity
+ * 
+ * @param fs			Pointer to ext2_filesystem_t to check
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_check_sanity(ext2_filesystem_t *fs)
+{
+	int rc;
+	
+	rc = ext2_superblock_check_sanity(fs->superblock);
+	if (rc != EOK) {
+		return rc;
+	}
+	
+	return EOK;
+}
+
+/**
+ * Check feature flags
+ * 
+ * @param fs Pointer to ext2_filesystem_t to check
+ * @param read_only bool to set to true if the fs needs to be read-only
+ * @return EOK on success or negative error code on failure
+ */
+int ext2_filesystem_check_flags(ext2_filesystem_t *fs, bool *o_read_only)
+{
+	/* feature flags are present in rev 1 and later */
+	if (ext2_superblock_get_rev_major(fs->superblock) == 0) {
+		*o_read_only = false;
+		return EOK;
+	}
+	
+	uint32_t incompatible;
+	uint32_t read_only;
+	
+	incompatible = ext2_superblock_get_features_incompatible(fs->superblock);
+	read_only = ext2_superblock_get_features_read_only(fs->superblock);
+	
+	/* check whether we support all features
+	 * first unset any supported feature flags
+	 * and see whether any unspported feature remains */
+	incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES;
+	read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES;
+	
+	if (incompatible > 0) {
+		*o_read_only = true;
+		return ENOTSUP;
+	}
+	
+	if (read_only > 0) {
+		*o_read_only = true;
+	}
+	
+	return EOK;
+}
+
+/**
+ * Get a reference to block descriptor
+ * 
+ * @param fs Pointer to filesystem information
+ * @param bgid Index of block group to find
+ * @param ref Pointer where to store pointer to block group reference
+ * 
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_get_block_group_ref(ext2_filesystem_t *fs, uint32_t bgid,
+    ext2_block_group_ref_t **ref)
+{
+	int rc;
+	aoff64_t block_id;
+	uint32_t descriptors_per_block;
+	size_t offset;
+	ext2_block_group_ref_t *newref;
+	
+	newref = malloc(sizeof(ext2_block_group_ref_t));
+	if (newref == NULL) {
+		return ENOMEM;
+	}
+	
+	descriptors_per_block = ext2_superblock_get_block_size(fs->superblock)
+	    / EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
+	
+	/* Block group descriptor table starts at the next block after superblock */
+	block_id = ext2_superblock_get_first_block(fs->superblock) + 1;
+	
+	/* Find the block containing the descriptor we are looking for */
+	block_id += bgid / descriptors_per_block;
+	offset = (bgid % descriptors_per_block) * EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
+	
+	rc = block_get(&newref->block, fs->device, block_id, 0);
+	if (rc != EOK) {
+		free(newref);
+		return rc;
+	}
+	
+	newref->block_group = newref->block->data + offset;
+	
+	*ref = newref;
+	
+	return EOK;
+}
+
+/**
+ * Free a reference to block group
+ * 
+ * @param ref Pointer to block group reference to free
+ * 
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_put_block_group_ref(ext2_block_group_ref_t *ref)
+{
+	int rc;
+	
+	rc = block_put(ref->block);
+	free(ref);
+	
+	return rc;
+}
+
+/**
+ * Get a reference to inode
+ * 
+ * @param fs Pointer to filesystem information
+ * @param index The index number of the inode
+ * @param ref Pointer where to store pointer to inode reference
+ * 
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_get_inode_ref(ext2_filesystem_t *fs, uint32_t index,
+    ext2_inode_ref_t **ref)
+{
+	int rc;
+	aoff64_t block_id;
+	uint32_t block_group;
+	uint32_t offset_in_group;
+	uint32_t byte_offset_in_group;
+	size_t offset_in_block;
+	uint32_t inodes_per_group;
+	uint32_t inode_table_start;
+	uint16_t inode_size;
+	uint32_t block_size;
+	ext2_block_group_ref_t *bg_ref;
+	ext2_inode_ref_t *newref;
+	
+	newref = malloc(sizeof(ext2_inode_ref_t));
+	if (newref == NULL) {
+		return ENOMEM;
+	}
+	
+	inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock);
+	
+	/* inode numbers are 1-based, but it is simpler to work with 0-based
+	 * when computing indices
+	 */
+	index -= 1;
+	block_group = index / inodes_per_group;
+	offset_in_group = index % inodes_per_group;
+	
+	rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
+	if (rc != EOK) {
+		free(newref);
+		return rc;
+	}
+	
+	inode_table_start = ext2_block_group_get_inode_table_first_block(
+	    bg_ref->block_group);
+	
+	rc = ext2_filesystem_put_block_group_ref(bg_ref);
+	if (rc != EOK) {
+		free(newref);
+		return rc;
+	}
+
+	inode_size = ext2_superblock_get_inode_size(fs->superblock);
+	block_size = ext2_superblock_get_block_size(fs->superblock);
+	
+	byte_offset_in_group = offset_in_group * inode_size;
+	
+	block_id = inode_table_start + (byte_offset_in_group / block_size);
+	offset_in_block = byte_offset_in_group % block_size;
+	
+	rc = block_get(&newref->block, fs->device, block_id, 0);
+	if (rc != EOK) {
+		free(newref);
+		return rc;
+	}
+	
+	newref->inode = newref->block->data + offset_in_block;
+	/* we decremented index above, but need to store the original value
+	 * in the reference
+	 */
+	newref->index = index+1;
+	
+	*ref = newref;
+	
+	return EOK;
+}
+
+/**
+ * Free a reference to inode
+ * 
+ * @param ref Pointer to inode reference to free
+ * 
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_put_inode_ref(ext2_inode_ref_t *ref)
+{
+	int rc;
+	
+	rc = block_put(ref->block);
+	free(ref);
+	
+	return rc;
+}
+
+/**
+ * Find a filesystem block number where iblock-th data block
+ * of the given inode is located.
+ * 
+ * @param fblock the number of filesystem block, or 0 if no such block is allocated yet
+ * 
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_get_inode_data_block_index(ext2_filesystem_t *fs, ext2_inode_t* inode,
+    aoff64_t iblock, uint32_t* fblock)
+{
+	int rc;
+	aoff64_t limits[4];
+	uint32_t block_ids_per_block;
+	aoff64_t blocks_per_level[4];
+	uint32_t offset_in_block;
+	uint32_t current_block;
+	aoff64_t block_offset_in_level;
+	int i;
+	int level;
+	block_t *block;
+	
+	/* Handle simple case when we are dealing with direct reference */ 
+	if (iblock < EXT2_INODE_DIRECT_BLOCKS) {
+		current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock);
+		*fblock = current_block;
+		return EOK;
+	}
+	
+	/* Compute limits for indirect block levels
+	 * TODO: compute this once when loading filesystem and store in ext2_filesystem_t
+	 */
+	block_ids_per_block = ext2_superblock_get_block_size(fs->superblock) / sizeof(uint32_t);
+	limits[0] = EXT2_INODE_DIRECT_BLOCKS;
+	blocks_per_level[0] = 1;
+	for (i = 1; i < 4; i++) {
+		blocks_per_level[i]  = blocks_per_level[i-1] *
+		    block_ids_per_block;
+		limits[i] = limits[i-1] + blocks_per_level[i];
+	}
+	
+	/* Determine the indirection level needed to get the desired block */
+	level = -1;
+	for (i = 1; i < 4; i++) {
+		if (iblock < limits[i]) {
+			level = i;
+			break;
+		}
+	}
+	
+	if (level == -1) {
+		return EIO;
+	}
+	
+	/* Compute offsets for the topmost level */
+	block_offset_in_level = iblock - limits[level-1];
+	current_block = ext2_inode_get_indirect_block(inode, level-1);
+	offset_in_block = block_offset_in_level / blocks_per_level[level-1];
+	
+	/* Navigate through other levels, until we find the block number
+	 * or find null reference meaning we are dealing with sparse file
+	 */
+	while (level > 0) {
+		rc = block_get(&block, fs->device, current_block, 0);
+		if (rc != EOK) {
+			return rc;
+		}
+		
+		assert(offset_in_block < block_ids_per_block);
+		current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
+		
+		rc = block_put(block);
+		if (rc != EOK) {
+			return rc;
+		}
+		
+		if (current_block == 0) {
+			/* This is a sparse file */
+			*fblock = 0;
+			return EOK;
+		}
+		
+		level -= 1;
+		
+		/* If we are on the last level, break here as
+		 * there is no next level to visit
+		 */
+		if (level == 0) {
+			break;
+		}
+		
+		/* Visit the next level */
+		block_offset_in_level %= blocks_per_level[level];
+		offset_in_block = block_offset_in_level / blocks_per_level[level-1];
+	}
+	
+	*fblock = current_block;
+	
+	return EOK;
+}
+
+/**
+ * Allocate a given number of blocks and store their ids in blocks
+ * 
+ * @todo TODO: This function is not finished and really has never been
+ *             used (and tested) yet
+ * 
+ * @param fs pointer to filesystem
+ * @param blocks array of count uint32_t values where store block ids
+ * @param count number of blocks to allocate and elements in blocks array
+ * @param preferred_bg preferred block group number
+ * 
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_allocate_blocks(ext2_filesystem_t *fs, uint32_t *blocks,
+    size_t count, uint32_t preferred_bg)
+{
+	uint32_t bg_count = ext2_superblock_get_block_group_count(fs->superblock);
+	uint32_t bpg = ext2_superblock_get_blocks_per_group(fs->superblock);
+	uint32_t block_size = ext2_superblock_get_block_size(fs->superblock);
+	uint32_t block_group = preferred_bg;
+	uint32_t free_blocks_sb;
+	uint32_t block_groups_left;
+	size_t idx;
+	ext2_block_group_ref_t *bg;
+	int rc;
+	uint32_t bb_block;
+	block_t *block;
+	size_t bb_idx;
+	size_t bb_bit;
+	
+	free_blocks_sb = ext2_superblock_get_free_block_count(fs->superblock);
+	
+	if (count > free_blocks_sb) {
+		return EIO;
+	}
+	
+	block_groups_left = bg_count;
+	
+	idx = 0;
+	
+	/* Read the block group descriptor */
+	rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg);
+	if (rc != EOK) {
+		goto failed;
+	}
+	
+	while (idx < count && block_groups_left > 0) {
+		uint16_t fb = ext2_block_group_get_free_block_count(bg->block_group);
+		if (fb == 0) {
+			block_group = (block_group + 1) % bg_count;
+			block_groups_left -= 1;
+			
+			rc = ext2_filesystem_put_block_group_ref(bg);
+			if (rc != EOK) {
+				goto failed;
+			}
+			
+			rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg);
+			if (rc != EOK) {
+				goto failed;
+			}
+			continue;
+		}
+		
+		/* We found a block group with free block, let's look at the block bitmap */
+		bb_block = ext2_block_group_get_block_bitmap_block(bg->block_group);
+		
+		rc = block_get(&block, fs->device, bb_block, BLOCK_FLAGS_NONE);
+		if (rc != EOK) {
+			goto failed;
+		}
+		
+		/* Use all blocks from this block group */
+		for (bb_idx = 0; bb_idx < block_size && idx < count; bb_idx++) {
+			uint8_t *data = (uint8_t *) block->data;
+			if (data[bb_idx] == 0xff) {
+				continue;
+			}
+			/* find an empty bit */
+			uint8_t mask;
+			for (mask = 1, bb_bit = 0;
+				 bb_bit < 8 && idx < count; 
+				 bb_bit++, mask = mask << 1) {
+				if ((data[bb_idx] & mask) == 0) {
+					// free block found
+					blocks[idx] = block_group * bpg + bb_idx*8 + bb_bit;
+					data[bb_idx] |= mask;
+					idx += 1;
+					fb -= 1;
+					ext2_block_group_set_free_block_count(bg->block_group, fb);
+				}
+			}
+		}
+	}
+	
+	rc = ext2_filesystem_put_block_group_ref(bg);
+	if (rc != EOK) {
+		goto failed;
+	}
+	
+	// TODO update superblock
+	
+	return EOK;
+failed:
+	// TODO deallocate already allocated blocks, if possible
+	
+	return rc;
+}
+
+/**
+ * Finalize an instance of filesystem
+ * 
+ * @param fs Pointer to ext2_filesystem_t to finalize
+ */
+void ext2_filesystem_fini(ext2_filesystem_t *fs)
+{
+	free(fs->superblock);
+	block_fini(fs->device);
+}
+
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_filesystem.h
===================================================================
--- uspace/lib/ext2/libext2_filesystem.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_filesystem.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef LIBEXT2_LIBEXT2_FILESYSTEM_H_
+#define LIBEXT2_LIBEXT2_FILESYSTEM_H_
+
+#include <block.h>
+#include "libext2_superblock.h"
+#include "libext2_block_group.h"
+#include "libext2_inode.h"
+
+typedef struct ext2_filesystem {
+	service_id_t		device;
+	ext2_superblock_t *	superblock;
+} ext2_filesystem_t;
+
+// allow maximum this block size
+#define EXT2_MAX_BLOCK_SIZE			8096
+#define EXT2_REV0_FIRST_INODE		11
+#define EXT2_REV0_INODE_SIZE		128
+
+#define EXT2_FEATURE_RO_SPARSE_SUPERBLOCK	1
+#define EXT2_FEATURE_RO_LARGE_FILE			2
+#define EXT2_FEATURE_I_TYPE_IN_DIR			2
+
+#define EXT2_SUPPORTED_INCOMPATIBLE_FEATURES EXT2_FEATURE_I_TYPE_IN_DIR
+#define EXT2_SUPPORTED_READ_ONLY_FEATURES 0
+
+extern int ext2_filesystem_init(ext2_filesystem_t *, service_id_t);
+extern int ext2_filesystem_check_sanity(ext2_filesystem_t *);
+extern int ext2_filesystem_check_flags(ext2_filesystem_t *, bool *);
+extern int ext2_filesystem_get_block_group_ref(ext2_filesystem_t *, uint32_t, 
+    ext2_block_group_ref_t **);
+extern int ext2_filesystem_put_block_group_ref(ext2_block_group_ref_t *);
+extern int ext2_filesystem_get_inode_ref(ext2_filesystem_t *, uint32_t,
+    ext2_inode_ref_t **);
+extern int ext2_filesystem_put_inode_ref(ext2_inode_ref_t *);
+extern int ext2_filesystem_get_inode_data_block_index(ext2_filesystem_t *, ext2_inode_t*,
+    aoff64_t, uint32_t*);
+extern int ext2_filesystem_allocate_blocks(ext2_filesystem_t *, uint32_t *, size_t, uint32_t);
+extern void ext2_filesystem_fini(ext2_filesystem_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_inode.c
===================================================================
--- uspace/lib/ext2/libext2_inode.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_inode.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include "libext2.h"
+#include "libext2_inode.h"
+#include "libext2_superblock.h"
+#include <byteorder.h>
+#include <assert.h>
+
+/**
+ * Get mode stored in the inode
+ * 
+ * @param inode pointer to inode
+ */
+uint32_t ext2_inode_get_mode(ext2_superblock_t *sb, ext2_inode_t *inode)
+{
+	if (ext2_superblock_get_os(sb) == EXT2_SUPERBLOCK_OS_HURD) {
+		return ((uint32_t)uint16_t_le2host(inode->mode_high)) << 16 |
+		    ((uint32_t)uint16_t_le2host(inode->mode));
+	}
+	return uint16_t_le2host(inode->mode);
+}
+
+/**
+ * Check whether inode is of given type
+ * 
+ * @param sb pointer to superblock structure
+ * @param inode pointer to inode
+ * @param type EXT2_INODE_MODE_TYPE_* constant to check
+ */
+bool ext2_inode_is_type(ext2_superblock_t *sb, ext2_inode_t *inode, uint32_t type)
+{
+	uint32_t mode = ext2_inode_get_mode(sb, inode);
+	return (mode & EXT2_INODE_MODE_TYPE_MASK) == type;
+}
+
+/**
+ * Get uid this inode is belonging to
+ * 
+ * @param inode pointer to inode
+ */
+uint32_t ext2_inode_get_user_id(ext2_superblock_t *sb, ext2_inode_t *inode)
+{
+	uint32_t os = ext2_superblock_get_os(sb);
+	if (os == EXT2_SUPERBLOCK_OS_LINUX || os == EXT2_SUPERBLOCK_OS_HURD) {
+		return ((uint32_t)uint16_t_le2host(inode->user_id_high)) << 16 |
+		    ((uint32_t)uint16_t_le2host(inode->user_id));
+	}
+	return uint16_t_le2host(inode->user_id);
+}
+
+/**
+ * Get size of file
+ * 
+ * For regular files in revision 1 and later, the high 32 bits of
+ * file size are stored in inode->size_high and are 0 otherwise
+ * 
+ * @param inode pointer to inode
+ */
+uint64_t ext2_inode_get_size(ext2_superblock_t *sb, ext2_inode_t *inode)
+{
+	uint32_t major_rev = ext2_superblock_get_rev_major(sb);
+	
+	if (major_rev > 0 && ext2_inode_is_type(sb, inode, EXT2_INODE_MODE_FILE)) {
+		return ((uint64_t)uint32_t_le2host(inode->size_high)) << 32 |
+		    ((uint64_t)uint32_t_le2host(inode->size));
+	}
+	return uint32_t_le2host(inode->size);
+}
+
+/**
+ * Get gid this inode belongs to
+ * 
+ * For Linux and Hurd, the high 16 bits are stored in OS dependent part
+ * of inode structure
+ * 
+ * @param inode pointer to inode
+ */
+uint32_t ext2_inode_get_group_id(ext2_superblock_t *sb, ext2_inode_t *inode)
+{
+	uint32_t os = ext2_superblock_get_os(sb);
+	if (os == EXT2_SUPERBLOCK_OS_LINUX || os == EXT2_SUPERBLOCK_OS_HURD) {
+		return ((uint32_t)uint16_t_le2host(inode->group_id_high)) << 16 |
+		    ((uint32_t)uint16_t_le2host(inode->group_id));
+	}
+	return uint16_t_le2host(inode->group_id);
+}
+
+/**
+ * Get usage count (i.e. hard link count)
+ * A value of 1 is common, while 0 means that the inode should be freed
+ * 
+ * @param inode pointer to inode
+ */
+uint16_t ext2_inode_get_usage_count(ext2_inode_t *inode)
+{
+	return uint16_t_le2host(inode->usage_count);
+}
+
+/**
+ * Get number of 512-byte data blocks allocated for contents of the file
+ * represented by this inode.
+ * This should be multiple of block size unless fragments are used.
+ * 
+ * @param inode pointer to inode
+ */
+uint32_t ext2_inode_get_reserved_512_blocks(ext2_inode_t *inode)
+{
+	return uint32_t_le2host(inode->reserved_512_blocks);
+}
+
+/**
+ * Get number of blocks allocated for contents of the file
+ * represented by this inode.
+ * 
+ * @param inode pointer to inode
+ */
+uint32_t ext2_inode_get_reserved_blocks(ext2_superblock_t *sb,
+    ext2_inode_t *inode)
+{
+	return ext2_inode_get_reserved_512_blocks(inode) /
+	    (ext2_superblock_get_block_size(sb) / 512);
+}
+
+/**
+ * Get inode flags
+ * 
+ * @param inode pointer to inode
+ */
+uint32_t ext2_inode_get_flags(ext2_inode_t *inode) {
+	return uint32_t_le2host(inode->flags);
+}
+
+/**
+ * Get direct block ID
+ * 
+ * @param inode pointer to inode
+ * @param idx Index to block. Valid values are 0 <= idx < 12
+ */
+uint32_t ext2_inode_get_direct_block(ext2_inode_t *inode, uint8_t idx)
+{
+	assert(idx < EXT2_INODE_DIRECT_BLOCKS);
+	return uint32_t_le2host(inode->direct_blocks[idx]);
+}
+
+/**
+ * Get indirect block ID
+ * 
+ * @param inode pointer to inode
+ * @param idx Indirection level. Valid values are 0 <= idx < 3, where 0 is
+ *            singly-indirect block and 2 is triply-indirect-block
+ */
+uint32_t ext2_inode_get_indirect_block(ext2_inode_t *inode, uint8_t idx)
+{
+	assert(idx < 3);
+	return uint32_t_le2host(inode->indirect_blocks[idx]);
+}
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_inode.h
===================================================================
--- uspace/lib/ext2/libext2_inode.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_inode.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef LIBEXT2_LIBEXT2_INODE_H_
+#define LIBEXT2_LIBEXT2_INODE_H_
+
+#include <block.h>
+#include "libext2_superblock.h"
+
+typedef struct ext2_inode {
+	uint16_t mode;
+	uint16_t user_id;
+	uint32_t size;
+	uint8_t unused[16];
+	uint16_t group_id;
+	uint16_t usage_count; // Hard link count, when 0 the inode is to be freed
+	uint32_t reserved_512_blocks; // Size of this inode in 512-byte blocks
+	uint32_t flags;
+	uint8_t unused2[4];
+	uint32_t direct_blocks[12]; // Direct block ids stored in this inode
+	uint32_t indirect_blocks[3];
+	uint32_t version;
+	uint32_t file_acl;
+	union {
+		uint32_t dir_acl;
+		uint32_t size_high; // For regular files in version >= 1
+	} __attribute__ ((packed));
+	uint8_t unused3[6];
+	uint16_t mode_high; // Hurd only
+	uint16_t user_id_high; // Linux/Hurd only
+	uint16_t group_id_high; // Linux/Hurd only
+} __attribute__ ((packed)) ext2_inode_t;
+
+#define EXT2_INODE_MODE_FIFO		0x1000
+#define EXT2_INODE_MODE_CHARDEV		0x2000
+#define EXT2_INODE_MODE_DIRECTORY	0x4000
+#define EXT2_INODE_MODE_BLOCKDEV	0x6000
+#define EXT2_INODE_MODE_FILE		0x8000
+#define EXT2_INODE_MODE_SOFTLINK	0xA000
+#define EXT2_INODE_MODE_SOCKET		0xC000
+#define EXT2_INODE_MODE_ACCESS_MASK	0x0FFF
+#define EXT2_INODE_MODE_TYPE_MASK	0xF000
+#define EXT2_INODE_DIRECT_BLOCKS	12
+
+#define EXT2_INODE_ROOT_INDEX		2
+
+typedef struct ext2_inode_ref {
+	block_t *block; // Reference to a block containing this inode
+	ext2_inode_t *inode;
+	uint32_t index; // Index number of this inode
+} ext2_inode_ref_t;
+
+extern uint32_t ext2_inode_get_mode(ext2_superblock_t *, ext2_inode_t *);
+extern bool ext2_inode_is_type(ext2_superblock_t *, ext2_inode_t *, uint32_t);
+extern uint32_t ext2_inode_get_user_id(ext2_superblock_t *, ext2_inode_t *);
+extern uint64_t ext2_inode_get_size(ext2_superblock_t *, ext2_inode_t *);
+extern uint32_t ext2_inode_get_group_id(ext2_superblock_t *, ext2_inode_t *);
+extern uint16_t ext2_inode_get_usage_count(ext2_inode_t *);
+extern uint32_t ext2_inode_get_reserved_512_blocks(ext2_inode_t *);
+extern uint32_t ext2_inode_get_reserved_blocks(ext2_superblock_t *, 
+    ext2_inode_t *);
+extern uint32_t ext2_inode_get_flags(ext2_inode_t *);
+extern uint32_t ext2_inode_get_direct_block(ext2_inode_t *, uint8_t);
+extern uint32_t ext2_inode_get_indirect_block(ext2_inode_t *, uint8_t level);
+
+
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_superblock.c
===================================================================
--- uspace/lib/ext2/libext2_superblock.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_superblock.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,409 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include "libext2.h"
+#include <errno.h>
+#include <malloc.h>
+#include <block.h>
+#include <byteorder.h>
+
+/**
+ * Return a magic number from ext2 superblock, this should be equal to
+ * EXT_SUPERBLOCK_MAGIC for valid ext2 superblock
+ * 
+ * @param sb pointer to superblock
+ */
+uint16_t ext2_superblock_get_magic(ext2_superblock_t *sb)
+{
+	return uint16_t_le2host(sb->magic);
+}
+
+/**
+ * Get the position of first ext2 data block (i.e. the block number
+ * containing main superblock)
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_first_block(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->first_block);
+}
+
+/**
+ * Get the number of bits to shift a value of 1024 to the left necessary
+ * to get the size of a block
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_block_size_log2(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->block_size_log2);
+}
+
+/**
+ * Get the size of a block, in bytes 
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_block_size(ext2_superblock_t *sb)
+{
+	return 1024 << ext2_superblock_get_block_size_log2(sb);
+}
+
+/**
+ * Get the number of bits to shift a value of 1024 to the left necessary
+ * to get the size of a fragment (note that this is a signed integer and
+ * if negative, the value should be shifted to the right instead)
+ * 
+ * @param sb pointer to superblock
+ */
+int32_t ext2_superblock_get_fragment_size_log2(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->fragment_size_log2);
+}
+
+/**
+ * Get the size of a fragment, in bytes 
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_fragment_size(ext2_superblock_t *sb)
+{
+	int32_t log = ext2_superblock_get_fragment_size_log2(sb);
+	if (log >= 0) {
+		return 1024 << log;
+	}
+	else {
+		return 1024 >> -log;
+	}
+}
+
+/**
+ * Get number of blocks per block group
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_blocks_per_group(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->blocks_per_group);
+}
+
+/**
+ * Get number of fragments per block group
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_fragments_per_group(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->fragments_per_group);
+}
+
+/**
+ * Get filesystem state
+ * 
+ * @param sb pointer to superblock
+ */
+uint16_t ext2_superblock_get_state(ext2_superblock_t *sb)
+{
+	return uint16_t_le2host(sb->state);
+}
+
+/**
+ * Get minor revision number
+ * 
+ * @param sb pointer to superblock
+ */
+uint16_t ext2_superblock_get_rev_minor(ext2_superblock_t *sb)
+{
+	return uint16_t_le2host(sb->rev_minor);
+}
+
+/**
+ * Get major revision number
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_rev_major(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->rev_major);
+}
+
+/**
+ * Get index of first regular inode
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_first_inode(ext2_superblock_t *sb)
+{
+	if (ext2_superblock_get_rev_major(sb) == 0) {
+		return EXT2_REV0_FIRST_INODE;
+	}
+	return uint32_t_le2host(sb->first_inode);
+}
+
+/**
+ * Get size of inode
+ * 
+ * @param sb pointer to superblock
+ */
+uint16_t ext2_superblock_get_inode_size(ext2_superblock_t *sb)
+{
+	if (ext2_superblock_get_rev_major(sb) == 0) {
+		return EXT2_REV0_INODE_SIZE;
+	}
+	return uint16_t_le2host(sb->inode_size);
+}
+
+/**
+ * Get total inode count
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_total_inode_count(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->total_inode_count);
+}
+
+/**
+ * Get total block count
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_total_block_count(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->total_block_count);
+}
+
+/**
+ * Get amount of blocks reserved for the superuser
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_reserved_block_count(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->reserved_block_count);
+}
+
+/**
+ * Get amount of free blocks
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_free_block_count(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->free_block_count);
+}
+
+/**
+ * Get amount of free inodes
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_free_inode_count(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->free_inode_count);
+}
+
+/**
+ * Get id of operating system that created the filesystem
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_os(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->os);
+}
+
+/**
+ * Get count of inodes per block group
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_inodes_per_group(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->inodes_per_group);
+}
+
+/**
+ * Get compatible features flags
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_features_compatible(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->features_compatible);
+}
+
+/**
+ * Get incompatible features flags
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_features_incompatible(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->features_incompatible);
+}
+
+/**
+ * Get read-only compatible features flags
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_features_read_only(ext2_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->features_read_only);
+}
+
+/**
+ * Compute count of block groups present in the filesystem
+ * 
+ * Note: This function works only for correct filesystem,
+ *       i.e. it assumes that total block count > 0 and
+ *       blocks per group > 0
+ * 
+ * Example:
+ *   If there are 3 blocks per group, the result should be as follows:
+ *   Total blocks	Result
+ *   1				1
+ *   2				1
+ *   3				1
+ *   4				2
+ * 
+ * 
+ * @param sb pointer to superblock
+ */
+uint32_t ext2_superblock_get_block_group_count(ext2_superblock_t *sb)
+{
+	/* We add one to the result because e.g. 2/3 = 0, while to store
+	 *  2 blocks in 3-block group we need one (1) block group
+	 * 
+	 * We subtract one first because of special case that to store e.g.
+	 *  3 blocks in a 3-block group we need only one group
+	 *  (and 3/3 yields one - this is one more that we want as we
+	 *   already add one at the end)
+	 */ 
+	return ((ext2_superblock_get_total_block_count(sb)-1) / 
+	    ext2_superblock_get_blocks_per_group(sb))+1;
+}
+
+/** Read a superblock directly from device (i.e. no libblock cache)
+ * 
+ * @param service_id	Service ID of the block device.
+ * @param superblock	Pointer where to store pointer to new superblock
+ * 
+ * @return		EOK on success or negative error code on failure.
+ */
+int ext2_superblock_read_direct(service_id_t service_id,
+    ext2_superblock_t **superblock)
+{
+	void *data;
+	int rc;
+	
+	data = malloc(EXT2_SUPERBLOCK_SIZE);
+	if (data == NULL) {
+		return ENOMEM;
+	}
+	
+	rc = block_read_bytes_direct(service_id, EXT2_SUPERBLOCK_OFFSET,
+	    EXT2_SUPERBLOCK_SIZE, data);
+	if (rc != EOK) {
+		free(data);
+		return rc;
+	}
+	
+	(*superblock) = data;
+	return EOK;
+}
+
+/** Check a superblock for sanity
+ * 
+ * @param sb	Pointer to superblock
+ * 
+ * @return		EOK on success or negative error code on failure.
+ */
+int ext2_superblock_check_sanity(ext2_superblock_t *sb)
+{
+	if (ext2_superblock_get_magic(sb) != EXT2_SUPERBLOCK_MAGIC) {
+		return ENOTSUP;
+	}
+	
+	if (ext2_superblock_get_rev_major(sb) > 1) {
+		return ENOTSUP;
+	}
+	
+	if (ext2_superblock_get_total_inode_count(sb) == 0) {
+		return ENOTSUP;
+	}
+	
+	if (ext2_superblock_get_total_block_count(sb) == 0) {
+		return ENOTSUP;
+	}
+	
+	if (ext2_superblock_get_blocks_per_group(sb) == 0) {
+		return ENOTSUP;
+	}
+	
+	if (ext2_superblock_get_fragments_per_group(sb) == 0) {
+		return ENOTSUP;
+	}
+	
+	/* We don't support fragments smaller than block */
+	if (ext2_superblock_get_block_size(sb) != 
+		    ext2_superblock_get_fragment_size(sb)) {
+		return ENOTSUP;
+	}
+	if (ext2_superblock_get_blocks_per_group(sb) !=
+		    ext2_superblock_get_fragments_per_group(sb)) {
+		return ENOTSUP;
+	}
+	
+	if (ext2_superblock_get_inodes_per_group(sb) == 0) {
+		return ENOTSUP;
+	}
+	
+	if (ext2_superblock_get_inode_size(sb) < 128) {
+		return ENOTSUP;
+	}
+	
+	if (ext2_superblock_get_first_inode(sb) < 11) {
+		return ENOTSUP;
+	}
+	
+	return EOK;
+}
+
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2_superblock.h
===================================================================
--- uspace/lib/ext2/libext2_superblock.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/ext2/libext2_superblock.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef LIBEXT2_LIBEXT2_SUPERBLOCK_H_
+#define LIBEXT2_LIBEXT2_SUPERBLOCK_H_
+
+#include <block.h>
+
+typedef struct ext2_superblock {
+	uint32_t	total_inode_count; // Total number of inodes
+	uint32_t	total_block_count; // Total number of blocks
+	uint32_t	reserved_block_count; // Total number of reserved blocks
+	uint32_t	free_block_count; // Total number of free blocks
+	uint32_t	free_inode_count; // Total number of free inodes
+	uint32_t	first_block; // Block containing the superblock (either 0 or 1)
+	uint32_t	block_size_log2; // log_2(block_size)
+	int32_t		fragment_size_log2; // log_2(fragment size)
+	uint32_t	blocks_per_group; // Number of blocks in one block group
+	uint32_t	fragments_per_group; // Number of fragments per block group
+	uint32_t	inodes_per_group; // Number of inodes per block group
+	uint8_t		unused2[12];
+	uint16_t	magic; // Magic value
+	uint16_t	state; // State (mounted/unmounted)
+	uint16_t	error_behavior; // What to do when errors are encountered
+	uint16_t	rev_minor; // Minor revision level
+	uint8_t		unused3[8];
+	uint32_t	os; // OS that created the filesystem
+	uint32_t	rev_major; // Major revision level
+	uint8_t		unused4[4];
+	
+	// Following is for ext2 revision 1 only
+	uint32_t	first_inode;
+	uint16_t	inode_size;
+	uint16_t	unused5;
+	uint32_t	features_compatible;
+	uint32_t	features_incompatible;
+	uint32_t	features_read_only;
+	uint8_t		uuid[16]; // UUID TODO: Create a library for UUIDs
+	uint8_t		volume_name[16];
+
+// TODO: add __attribute__((aligned(...)) for better performance?
+//       (it is necessary to ensure the superblock is correctly aligned then
+//        though)
+} __attribute__ ((packed)) ext2_superblock_t;
+
+#define EXT2_SUPERBLOCK_MAGIC		0xEF53
+#define EXT2_SUPERBLOCK_SIZE		1024
+#define EXT2_SUPERBLOCK_OFFSET		1024
+#define EXT2_SUPERBLOCK_LAST_BYTE	(EXT2_SUPERBLOCK_OFFSET + \
+									 EXT2_SUPERBLOCK_SIZE -1)
+#define EXT2_SUPERBLOCK_OS_LINUX	0
+#define EXT2_SUPERBLOCK_OS_HURD		1
+
+
+extern uint16_t	ext2_superblock_get_magic(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_first_block(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_block_size_log2(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_block_size(ext2_superblock_t *);
+extern int32_t	ext2_superblock_get_fragment_size_log2(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_fragment_size(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_blocks_per_group(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_fragments_per_group(ext2_superblock_t *);
+extern uint16_t	ext2_superblock_get_state(ext2_superblock_t *);
+extern uint16_t	ext2_superblock_get_rev_minor(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_rev_major(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_os(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_first_inode(ext2_superblock_t *);
+extern uint16_t	ext2_superblock_get_inode_size(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_total_inode_count(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_total_block_count(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_reserved_block_count(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_free_block_count(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_free_inode_count(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_block_group_count(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_inodes_per_group(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_features_compatible(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_features_incompatible(ext2_superblock_t *);
+extern uint32_t	ext2_superblock_get_features_read_only(ext2_superblock_t *);
+
+extern int ext2_superblock_read_direct(service_id_t, ext2_superblock_t **);
+extern int ext2_superblock_check_sanity(ext2_superblock_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ext4/libext4_block_group.c
===================================================================
--- uspace/lib/ext4/libext4_block_group.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_block_group.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_block_group.h
===================================================================
--- uspace/lib/ext4/libext4_block_group.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_block_group.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_directory.c
===================================================================
--- uspace/lib/ext4/libext4_directory.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_directory.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_directory.h
===================================================================
--- uspace/lib/ext4/libext4_directory.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_directory.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_filesystem.h
===================================================================
--- uspace/lib/ext4/libext4_filesystem.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_filesystem.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_inode.c
===================================================================
--- uspace/lib/ext4/libext4_inode.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_inode.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_inode.h
===================================================================
--- uspace/lib/ext4/libext4_inode.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_inode.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_superblock.c
===================================================================
--- uspace/lib/ext4/libext4_superblock.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_superblock.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_superblock.h
===================================================================
--- uspace/lib/ext4/libext4_superblock.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_superblock.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/ext4/libext4_types.h
===================================================================
--- uspace/lib/ext4/libext4_types.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/ext4/libext4_types.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/lib/graph/graph.h
===================================================================
--- uspace/lib/graph/graph.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/graph/graph.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <loc.h>
 #include <async.h>
Index: uspace/lib/gui/minimal.h
===================================================================
--- uspace/lib/gui/minimal.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/gui/minimal.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 #define GUI_MINIMAL_H_
 
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 #include <io/pixel.h>
Index: uspace/lib/gui/terminal.c
===================================================================
--- uspace/lib/gui/terminal.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/gui/terminal.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -196,16 +196,15 @@
 	uint16_t glyph = fb_font_glyph(field->ch);
 	
+	// FIXME: This font drawing routine is shamelessly
+	//        suboptimal. It should be optimized for
+	//        aligned memory transfers, etc.
+	
 	for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
-		pixel_t *dst = pixelmap_pixel_at(
-		    surface_pixmap_access(surface), bx, by + y);
-		pixel_t *dst_max = pixelmap_pixel_at(
-		    surface_pixmap_access(surface), bx + FONT_WIDTH - 1, by + y);
-		if (!dst || !dst_max) continue;
-		int count = FONT_WIDTH;
-		while (count-- != 0) {
-			*dst++ = (fb_font[glyph][y] & (1 << count)) ? fgcolor : bgcolor;
+		for (unsigned int x = 0; x < FONT_WIDTH; x++) {
+			pixel_t pixel =
+			    (fb_font[glyph][y] & (1 << (7 - x))) ? fgcolor : bgcolor;
+			surface_put_pixel(surface, bx + x, by + y, pixel);
 		}
 	}
-	surface_add_damaged_region(surface, bx, by, FONT_WIDTH, FONT_SCANLINES);
 }
 
Index: uspace/lib/gui/window.c
===================================================================
--- uspace/lib/gui/window.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/gui/window.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <stdio.h>
@@ -66,8 +66,6 @@
 
 static pixel_t border_color = PIXEL(255, 0, 0, 0);
-static pixel_t header_bg_focus_color = PIXEL(255, 25, 25, 112);
-static pixel_t header_fg_focus_color = PIXEL(255, 255, 255, 255);
-static pixel_t header_bg_unfocus_color = PIXEL(255, 70, 130, 180);
-static pixel_t header_fg_unfocus_color = PIXEL(255, 255, 255, 255);
+static pixel_t header_bgcolor = PIXEL(255, 25, 25, 112);
+static pixel_t header_fgcolor = PIXEL(255, 255, 255, 255);
 
 static void paint_internal(widget_t *w)
@@ -96,6 +94,5 @@
 	    w->vpos + w->height - border_thickness, w->width, border_thickness);
 
-	source_set_color(&source, 
-	    w->window->is_focused ? header_bg_focus_color : header_bg_unfocus_color);
+	source_set_color(&source, header_bgcolor);
 	drawctx_transfer(&drawctx,
 	    w->hpos + border_thickness, w->vpos + border_thickness,
@@ -109,6 +106,5 @@
 	char cls_pict[] = "x";
 	font_get_box(&font, cls_pict, &cls_width, &cls_height);
-	source_set_color(&source, 
-	    w->window->is_focused ? header_fg_focus_color : header_fg_unfocus_color);
+	source_set_color(&source, header_fgcolor);
 	sysarg_t cls_x = ((close_width - cls_width) / 2) + w->hpos + w->width -
 	    border_thickness - close_width;
@@ -451,8 +447,4 @@
 			break;
 		case ET_POSITION_EVENT:
-			if (!win->is_focused) {
-				win->is_focused = true;
-				handle_refresh(win);
-			}
 			deliver_position_event(win, event->data.pos);
 			break;
@@ -462,16 +454,4 @@
 		case ET_WINDOW_RESIZE:
 			handle_resize(win, event->data.rsz.width, event->data.rsz.height);
-			break;
-		case ET_WINDOW_FOCUS:
-			if (!win->is_focused) {
-				win->is_focused = true;
-				handle_refresh(win);
-			}
-			break;
-		case ET_WINDOW_UNFOCUS:
-			if (win->is_focused) {
-				win->is_focused = false;
-				handle_refresh(win);
-			}
 			break;
 		case ET_WINDOW_REFRESH:
@@ -534,6 +514,5 @@
 }
 
-window_t *window_open(char *winreg, bool is_main, bool is_decorated, 
-    const char *caption, sysarg_t x_offset, sysarg_t y_offset)
+window_t *window_open(char *winreg, bool is_main, bool is_decorated, const char *caption)
 {
 	int rc;
@@ -546,5 +525,4 @@
 	win->is_main = is_main;
 	win->is_decorated = is_decorated;
-	win->is_focused = true;
 	prodcons_initialize(&win->events);
 	fibril_mutex_initialize(&win->guard);
@@ -579,5 +557,5 @@
 	service_id_t out_dsid;
 	
-	rc = win_register(reg_sess, &in_dsid, &out_dsid, x_offset, y_offset);
+	rc = win_register(reg_sess, &in_dsid, &out_dsid);
 	async_hangup(reg_sess);
 	if (rc != EOK) {
Index: uspace/lib/gui/window.h
===================================================================
--- uspace/lib/gui/window.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/gui/window.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -50,5 +50,4 @@
 	bool is_main; /**< True for the main window of the application. */
 	bool is_decorated; /**< True if the window decorations should be rendered. */
-	bool is_focused; /**< True for the top level window of the desktop. */
 	char *caption; /**< Text title of the window header. */
 	async_sess_t *isess; /**< Input events from compositor. */
@@ -66,5 +65,5 @@
  * If the window is declared as main, its closure causes termination of the
  * whole application. Note that opened window does not have any surface yet. */
-extern window_t *window_open(char *, bool, bool, const char *, sysarg_t, sysarg_t);
+extern window_t *window_open(char *, bool, bool, const char *);
 
 /**
Index: uspace/lib/nic/src/nic_addr_db.c
===================================================================
--- uspace/lib/nic/src/nic_addr_db.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/nic/src/nic_addr_db.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <assert.h>
 #include <stdlib.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <mem.h>
Index: uspace/lib/nic/src/nic_rx_control.c
===================================================================
--- uspace/lib/nic/src/nic_rx_control.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/nic/src/nic_rx_control.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #include <assert.h>
 #include <stdlib.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <mem.h>
Index: uspace/lib/posix/include/posix/stdbool.h
===================================================================
--- uspace/lib/posix/include/posix/stdbool.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/lib/posix/include/posix/stdbool.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Jiri Zarevucky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 libposix
+ * @{
+ */
+/** @file Boolean type and values.
+ */
+
+#ifndef POSIX_STDBOOL_H_
+#define POSIX_STDBOOL_H_
+
+#ifdef LIBC_BOOL_H_
+
+#if (!defined(POSIX_STDIO_H_)) && \
+    (!defined(POSIX_STDLIB_H_)) && \
+    (!defined(POSIX_STRING_H_))
+	#error "You can't include bool.h and stdbool.h at the same time."
+#endif
+
+#endif /* LIBC_BOOL_H */
+
+#define LIBC_BOOL_H_
+
+#define bool _Bool
+#define true 1
+#define false 0
+#define __bool_true_false_are_defined 1
+
+#endif /* POSIX_STDBOOL_H_ */
Index: uspace/lib/posix/source/fnmatch.c
===================================================================
--- uspace/lib/posix/source/fnmatch.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/posix/source/fnmatch.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #define LIBPOSIX_INTERNAL
 
-#include "libc/stdbool.h"
+#include "posix/stdbool.h"
 #include "posix/ctype.h"
 #include "posix/string.h"
Index: uspace/lib/posix/source/pwd.c
===================================================================
--- uspace/lib/posix/source/pwd.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/posix/source/pwd.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 #define LIBPOSIX_INTERNAL
 
-#include "libc/stdbool.h"
+#include "posix/stdbool.h"
 #include "posix/pwd.h"
 #include "posix/string.h"
Index: uspace/lib/posix/source/stdio.c
===================================================================
--- uspace/lib/posix/source/stdio.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/posix/source/stdio.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,4 +36,7 @@
 #define LIBPOSIX_INTERNAL
 
+/* Has to be first. */
+#include "posix/stdbool.h"
+
 #include "internal/common.h"
 #include "posix/stdio.h"
@@ -48,5 +51,4 @@
 #include "libc/stdio.h"
 #include "libc/io/printf_core.h"
-#include "libc/stdbool.h"
 #include "libc/str.h"
 #include "libc/malloc.h"
Index: uspace/lib/posix/source/stdio/scanf.c
===================================================================
--- uspace/lib/posix/source/stdio/scanf.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/posix/source/stdio/scanf.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,4 +35,7 @@
 #define LIBPOSIX_INTERNAL
 
+/* Must be first. */
+#include "posix/stdbool.h"
+
 #include "posix/assert.h"
 #include "posix/errno.h"
@@ -47,5 +50,4 @@
 #include "../internal/common.h"
 #include "libc/malloc.h"
-#include "libc/stdbool.h"
 
 /** Unified data type for possible data sources for scanf. */
Index: uspace/lib/posix/source/stdlib/strtold.c
===================================================================
--- uspace/lib/posix/source/stdlib/strtold.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/posix/source/stdlib/strtold.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,6 +35,8 @@
 #define LIBPOSIX_INTERNAL
 
+/* Must be first. */
+#include "posix/stdbool.h"
+
 #include "../internal/common.h"
-#include "libc/stdbool.h"
 #include "posix/stdlib.h"
 
Index: uspace/lib/posix/source/time.c
===================================================================
--- uspace/lib/posix/source/time.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/posix/source/time.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,4 +36,7 @@
 #define LIBPOSIX_INTERNAL
 
+/* Must be first. */
+#include "posix/stdbool.h"
+
 #include "internal/common.h"
 #include "posix/time.h"
@@ -47,5 +50,4 @@
 #include "libc/task.h"
 #include "libc/stats.h"
-#include "libc/stdbool.h"
 #include "libc/sys/time.h"
 
Index: uspace/lib/softfloat/common.c
===================================================================
--- uspace/lib/softfloat/common.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/softfloat/common.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 /* Table for fast leading zeroes counting. */
 char zeroTable[256] = {
-	8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, \
+	8, 7, 7, 6, 6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 4, \
 	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \
 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
@@ -307,24 +307,16 @@
 /**
  * Round and normalize number expressed by exponent and fraction with
- * first bit (equal to hidden bit) at bit 62.
+ * first bit (equal to hidden bit) at 62nd bit.
  *
  * @param exp Exponent part.
- * @param fraction Fraction with hidden bit shifted to bit 62.
+ * @param fraction Fraction with hidden bit shifted to 62nd bit.
  */
 void round_float64(int32_t *exp, uint64_t *fraction)
 {
-	/*
-	 * Rounding - if first bit after fraction is set then round up.
-	 */
-
-	/*
-	 * Add 1 to the least significant bit of the fraction respecting the
-	 * current shift to bit 62 and see if there will be a carry to bit 63.
-	 */
+	/* rounding - if first bit after fraction is set then round up */
 	(*fraction) += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3));
 	
-	/* See if there was a carry to bit 63. */
 	if ((*fraction) & 
-	    (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1))) {
+	    (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 3))) {
 		/* rounding overflow */
 		++(*exp);
Index: uspace/lib/softrend/filter.c
===================================================================
--- uspace/lib/softrend/filter.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/softrend/filter.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,4 +44,6 @@
 		_x %= pixmap->width;
 		_y %= pixmap->height;
+	} else if (_x < 0 || _x >= (long) pixmap->width || _y < 0 || _y >= (long) pixmap->height) {
+		return 0;
 	}
 
Index: uspace/lib/softrend/filter.h
===================================================================
--- uspace/lib/softrend/filter.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/softrend/filter.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 #define SOFTREND_FILTER_H_
 
-#include <stdbool.h>
+#include <bool.h>
 #include <io/pixelmap.h>
 
Index: uspace/lib/softrend/pixconv.h
===================================================================
--- uspace/lib/softrend/pixconv.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/softrend/pixconv.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #define SOFTREND_PIXCONV_H_
 
-#include <stdbool.h>
+#include <bool.h>
 #include <io/pixel.h>
 
Index: uspace/lib/softrend/rectangle.h
===================================================================
--- uspace/lib/softrend/rectangle.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/softrend/rectangle.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 extern bool rectangle_intersect(
Index: uspace/lib/softrend/transform.c
===================================================================
--- uspace/lib/softrend/transform.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/softrend/transform.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -136,12 +136,4 @@
 }
 
-bool transform_is_fast(transform_t *t)
-{
-	return (t->m[0][0] == 1) && (t->m[0][1] == 0)
-	    && (t->m[1][0] == 0) && (t->m[1][1] == 1)
-	    && ((t->m[0][2] - ((long) t->m[0][2])) == 0.0)
-	    && ((t->m[1][2] - ((long) t->m[1][2])) == 0.0);
-}
-
 void transform_apply_linear(const transform_t *t, double *x, double *y)
 {
Index: uspace/lib/softrend/transform.h
===================================================================
--- uspace/lib/softrend/transform.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/softrend/transform.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,6 +37,4 @@
 #define SOFTREND_TRANSFORM_H_
 
-#include <stdbool.h>
-
 #ifndef PI
 #define PI 3.141592653589793
@@ -55,6 +53,4 @@
 extern void transform_rotate(transform_t *, double);
 
-extern bool transform_is_fast(transform_t *);
-
 extern void transform_apply_linear(const transform_t *, double *, double *);
 extern void transform_apply_affine(const transform_t *, double *, double *);
Index: uspace/lib/usb/include/usb/hc.h
===================================================================
--- uspace/lib/usb/include/usb/hc.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/usb/include/usb/hc.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <devman.h>
 #include <ddf/driver.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <usb/usb.h>
Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/usb/include/usb/usb.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 #define LIBUSB_USB_H_
 
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 #include <byteorder.h>
Index: uspace/lib/usbdev/include/usb/dev/request.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/request.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/usbdev/include/usb/dev/request.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -93,8 +93,8 @@
 	uint8_t request;
 	/** Main parameter to the request. */
-	union __attribute__ ((packed)) {
+	union {
 		uint16_t value;
 		/* FIXME: add #ifdefs according to host endianness */
-		struct __attribute__ ((packed)) {
+		struct {
 			uint8_t value_low;
 			uint8_t value_high;
@@ -108,6 +108,4 @@
 	uint16_t length;
 } __attribute__ ((packed)) usb_device_request_setup_packet_t;
-
-int assert[(sizeof(usb_device_request_setup_packet_t) == 8) ? 1: -1];
 
 int usb_control_request_set(usb_pipe_t *,
Index: uspace/lib/usbdev/src/dp.c
===================================================================
--- uspace/lib/usbdev/src/dp.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/usbdev/src/dp.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -45,5 +45,5 @@
 #include <errno.h>
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <usb/dev/dp.h>
 #include <usb/descriptor.h>
Index: uspace/lib/usbhost/include/usb/host/endpoint.h
===================================================================
--- uspace/lib/usbhost/include/usb/host/endpoint.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/usbhost/include/usb/host/endpoint.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 #define LIBUSBHOST_HOST_ENDPOINT_H
 
-#include <stdbool.h>
+#include <bool.h>
 #include <adt/list.h>
 #include <fibril_synch.h>
Index: uspace/lib/usbhost/src/usb_endpoint_manager.c
===================================================================
--- uspace/lib/usbhost/src/usb_endpoint_manager.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/usbhost/src/usb_endpoint_manager.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -33,5 +33,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <assert.h>
 #include <errno.h>
Index: uspace/lib/usbvirt/include/usbvirt/ipc.h
===================================================================
--- uspace/lib/usbvirt/include/usbvirt/ipc.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/lib/usbvirt/include/usbvirt/ipc.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <ipc/common.h>
 #include <usb/usb.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <usbvirt/device.h>
 #include <async.h>
Index: uspace/srv/bd/ata_bd/ata_bd.c
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/bd/ata_bd/ata_bd.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -49,4 +49,5 @@
 
 #include <stdio.h>
+#include <libarch/ddi.h>
 #include <ddi.h>
 #include <async.h>
@@ -60,5 +61,5 @@
 #include <inttypes.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <byteorder.h>
 #include <task.h>
Index: uspace/srv/bd/file_bd/file_bd.c
===================================================================
--- uspace/srv/bd/file_bd/file_bd.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/bd/file_bd/file_bd.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -49,5 +49,5 @@
 #include <sys/typefmt.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <task.h>
 #include <macros.h>
Index: uspace/srv/bd/gxe_bd/gxe_bd.c
===================================================================
--- uspace/srv/bd/gxe_bd/gxe_bd.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/bd/gxe_bd/gxe_bd.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,4 +37,5 @@
 
 #include <stdio.h>
+#include <libarch/ddi.h>
 #include <ddi.h>
 #include <async.h>
Index: uspace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/bd/part/guid_part/guid_part.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -58,5 +58,5 @@
 #include <loc.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <byteorder.h>
 #include <assert.h>
Index: uspace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/bd/part/mbr_part/mbr_part.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -67,5 +67,5 @@
 #include <block.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <byteorder.h>
 #include <assert.h>
Index: uspace/srv/bd/rd/rd.c
===================================================================
--- uspace/srv/bd/rd/rd.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/bd/rd/rd.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -46,5 +46,5 @@
 #include <ddi.h>
 #include <align.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <async.h>
Index: uspace/srv/clipboard/clipboard.c
===================================================================
--- uspace/srv/clipboard/clipboard.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/clipboard/clipboard.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -28,5 +28,5 @@
 
 #include <stdio.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <async.h>
 #include <ns.h>
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/devman/devman.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <dirent.h>
 #include <str.h>
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/devman/main.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #include <errno.h>
 #include <str_error.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <stdlib.h>
Index: uspace/srv/fs/cdfs/cdfs_ops.c
===================================================================
--- uspace/srv/fs/cdfs/cdfs_ops.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/cdfs/cdfs_ops.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 
 #include "cdfs_ops.h"
-#include <stdbool.h>
+#include <bool.h>
 #include <adt/hash_table.h>
 #include <adt/hash.h>
Index: uspace/srv/fs/cdfs/cdfs_ops.h
===================================================================
--- uspace/srv/fs/cdfs/cdfs_ops.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/cdfs/cdfs_ops.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
 #define CDFS_CDFS_OPS_H_
 
-#include <stdbool.h>
+#include <bool.h>
 
 extern bool cdfs_init(void);
Index: uspace/srv/fs/exfat/exfat.h
===================================================================
--- uspace/srv/fs/exfat/exfat.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/exfat/exfat.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <atomic.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include "../../vfs/vfs.h"
 
Index: uspace/srv/fs/exfat/exfat_dentry.h
===================================================================
--- uspace/srv/fs/exfat/exfat_dentry.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/exfat/exfat_dentry.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 
 #include <stdint.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #define EXFAT_FILENAME_LEN	255
Index: uspace/srv/fs/ext2fs/Makefile
===================================================================
--- uspace/srv/fs/ext2fs/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/srv/fs/ext2fs/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 Jakub Jermar
+# Copyright (c) 2010 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 = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a $(LIBEXT2_PREFIX)/libext2.a
+EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) -I$(LIBEXT2_PREFIX)
+BINARY = ext2fs
+
+SOURCES = \
+	ext2fs.c \
+	ext2fs_ops.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/fs/ext2fs/ext2fs.c
===================================================================
--- uspace/srv/fs/ext2fs/ext2fs.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/srv/fs/ext2fs/ext2fs.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2006 Martin Decky
+ * Copyright (c) 2011 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 fs
+ * @{
+ */ 
+
+/**
+ * @file	ext2.c
+ * @brief	EXT2 file system driver for HelenOS.
+ */
+
+#include "ext2fs.h"
+#include <ipc/services.h>
+#include <ns.h>
+#include <async.h>
+#include <errno.h>
+#include <unistd.h>
+#include <task.h>
+#include <stdio.h>
+#include <libfs.h>
+#include "../../vfs/vfs.h"
+
+#define NAME	"ext2fs"
+
+vfs_info_t ext2fs_vfs_info = {
+	.name = NAME,
+	.instance = 0,
+};
+
+int main(int argc, char **argv)
+{
+	printf(NAME ": HelenOS EXT2 file system server\n");
+
+	if (argc == 3) {
+		if (!str_cmp(argv[1], "--instance"))
+			ext2fs_vfs_info.instance = strtol(argv[2], NULL, 10);
+		else {
+			printf(NAME " Unrecognized parameters");
+			return -1;
+		}
+	}
+	
+	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
+	    SERVICE_VFS, 0, 0);
+	if (!vfs_sess) {
+		printf(NAME ": failed to connect to VFS\n");
+		return -1;
+	}
+
+	int rc = ext2fs_global_init();
+	if (rc != EOK) {
+		printf(NAME ": Failed global initialization\n");
+		return 1;
+	}	
+		
+	rc = fs_register(vfs_sess, &ext2fs_vfs_info, &ext2fs_ops,
+	    &ext2fs_libfs_ops);
+	if (rc != EOK) {
+		fprintf(stdout, NAME ": Failed to register fs (%d)\n", rc);
+		return 1;
+	}
+	
+	printf(NAME ": Accepting connections\n");
+	task_retval(0);
+	async_manager();
+	/* not reached */
+	return 0;
+}
+
+/**
+ * @}
+ */ 
Index: uspace/srv/fs/ext2fs/ext2fs.h
===================================================================
--- uspace/srv/fs/ext2fs/ext2fs.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/srv/fs/ext2fs/ext2fs.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 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 fs
+ * @{
+ */ 
+
+#ifndef EXT2FS_EXT2FS_H_
+#define EXT2FS_EXT2FS_H_
+
+#include <libext2.h>
+#include <libfs.h>
+#include <sys/types.h>
+
+#define min(a, b)		((a) < (b) ? (a) : (b))
+
+extern vfs_out_ops_t ext2fs_ops;
+extern libfs_ops_t ext2fs_libfs_ops;
+
+extern int ext2fs_global_init(void);
+extern int ext2fs_global_fini(void);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/srv/fs/ext2fs/ext2fs_ops.c
===================================================================
--- uspace/srv/fs/ext2fs/ext2fs_ops.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
+++ uspace/srv/fs/ext2fs/ext2fs_ops.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -0,0 +1,976 @@
+/*
+ * Copyright (c) 2011 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 fs
+ * @{
+ */ 
+
+/**
+ * @file	ext2fs_ops.c
+ * @brief	Implementation of VFS operations for the EXT2 file system server.
+ */
+
+#include "ext2fs.h"
+#include "../../vfs/vfs.h"
+#include <libfs.h>
+#include <block.h>
+#include <libext2.h>
+#include <ipc/services.h>
+#include <ipc/loc.h>
+#include <macros.h>
+#include <async.h>
+#include <errno.h>
+#include <str.h>
+#include <byteorder.h>
+#include <adt/hash_table.h>
+#include <adt/hash.h>
+#include <adt/list.h>
+#include <assert.h>
+#include <fibril_synch.h>
+#include <sys/mman.h>
+#include <align.h>
+#include <adt/hash_table.h>
+#include <sys/typefmt.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <inttypes.h>
+
+#define EXT2FS_NODE(node)	((node) ? (ext2fs_node_t *) (node)->data : NULL)
+#define EXT2FS_DBG(format, ...) {if (false) printf("ext2fs: %s: " format "\n", __FUNCTION__, ##__VA_ARGS__);}
+
+typedef struct ext2fs_instance {
+	link_t link;
+	service_id_t service_id;
+	ext2_filesystem_t *filesystem;
+	unsigned int open_nodes_count;
+} ext2fs_instance_t;
+
+typedef struct ext2fs_node {
+	ext2fs_instance_t *instance;
+	ext2_inode_ref_t *inode_ref;
+	fs_node_t *fs_node;
+	ht_link_t link;
+	unsigned int references;
+} ext2fs_node_t;
+
+/*
+ * Forward declarations of auxiliary functions
+ */
+static int ext2fs_instance_get(service_id_t, ext2fs_instance_t **);
+static int ext2fs_read_directory(ipc_callid_t, aoff64_t, size_t,
+    ext2fs_instance_t *, ext2_inode_ref_t *, size_t *);
+static int ext2fs_read_file(ipc_callid_t, aoff64_t, size_t, ext2fs_instance_t *,
+    ext2_inode_ref_t *, size_t *);
+static bool ext2fs_is_dots(const uint8_t *, size_t);
+static int ext2fs_node_get_core(fs_node_t **, ext2fs_instance_t *, fs_index_t);
+static int ext2fs_node_put_core(ext2fs_node_t *);
+
+/*
+ * Forward declarations of EXT2 libfs operations.
+ */
+static int ext2fs_root_get(fs_node_t **, service_id_t);
+static int ext2fs_match(fs_node_t **, fs_node_t *, const char *);
+static int ext2fs_node_get(fs_node_t **, service_id_t, fs_index_t);
+static int ext2fs_node_open(fs_node_t *);
+static int ext2fs_node_put(fs_node_t *);
+static int ext2fs_create_node(fs_node_t **, service_id_t, int);
+static int ext2fs_destroy_node(fs_node_t *);
+static int ext2fs_link(fs_node_t *, fs_node_t *, const char *);
+static int ext2fs_unlink(fs_node_t *, fs_node_t *, const char *);
+static int ext2fs_has_children(bool *, fs_node_t *);
+static fs_index_t ext2fs_index_get(fs_node_t *);
+static aoff64_t ext2fs_size_get(fs_node_t *);
+static unsigned ext2fs_lnkcnt_get(fs_node_t *);
+static bool ext2fs_is_directory(fs_node_t *);
+static bool ext2fs_is_file(fs_node_t *node);
+static service_id_t ext2fs_service_get(fs_node_t *node);
+
+/*
+ * Static variables
+ */
+static LIST_INITIALIZE(instance_list);
+static FIBRIL_MUTEX_INITIALIZE(instance_list_mutex);
+static hash_table_t open_nodes;
+static FIBRIL_MUTEX_INITIALIZE(open_nodes_lock);
+
+/* 
+ * Hash table interface for open nodes hash table 
+ */
+
+typedef struct {
+	service_id_t service_id;
+	fs_index_t index;
+} node_key_t;
+
+static size_t open_nodes_key_hash(void *key)
+{
+	node_key_t *node_key = (node_key_t*)key;
+	return hash_combine(node_key->service_id, node_key->index);
+}
+
+static size_t open_nodes_hash(const ht_link_t *item)
+{
+	ext2fs_node_t *enode = hash_table_get_inst(item, ext2fs_node_t, link);
+
+	assert(enode->instance);
+	assert(enode->inode_ref);
+	
+	return hash_combine(enode->instance->service_id, enode->inode_ref->index);
+}
+
+static bool open_nodes_key_equal(void *key, const ht_link_t *item)
+{
+	node_key_t *node_key = (node_key_t*)key;
+	ext2fs_node_t *enode = hash_table_get_inst(item, ext2fs_node_t, link);
+	
+	return node_key->service_id == enode->instance->service_id
+		&& node_key->index == enode->inode_ref->index;
+}
+
+static hash_table_ops_t open_nodes_ops = {
+	.hash = open_nodes_hash,
+	.key_hash = open_nodes_key_hash,
+	.key_equal = open_nodes_key_equal,
+	.equal = NULL,
+	.remove_callback = NULL,
+};
+
+/**
+ * 
+ */
+int ext2fs_global_init(void)
+{
+	if (!hash_table_create(&open_nodes, 0, 0, &open_nodes_ops)) {
+		return ENOMEM;
+	}
+	return EOK;
+}
+
+int ext2fs_global_fini(void)
+{
+	hash_table_destroy(&open_nodes);
+	return EOK;
+}
+
+
+/*
+ * EXT2 libfs operations.
+ */
+
+/**
+ * Find an instance of filesystem for the given service_id
+ */
+int ext2fs_instance_get(service_id_t service_id, ext2fs_instance_t **inst)
+{
+	EXT2FS_DBG("(%" PRIun ", -)", service_id);
+	ext2fs_instance_t *tmp;
+	
+	fibril_mutex_lock(&instance_list_mutex);
+
+	if (list_empty(&instance_list)) {
+		EXT2FS_DBG("list empty");
+		fibril_mutex_unlock(&instance_list_mutex);
+		return EINVAL;
+	}
+
+	list_foreach(instance_list, link) {
+		tmp = list_get_instance(link, ext2fs_instance_t, link);
+		
+		if (tmp->service_id == service_id) {
+			*inst = tmp;
+			fibril_mutex_unlock(&instance_list_mutex);
+			return EOK;
+		}
+	}
+	
+	EXT2FS_DBG("not found");
+	
+	fibril_mutex_unlock(&instance_list_mutex);
+	return EINVAL;
+}
+
+
+
+int ext2fs_root_get(fs_node_t **rfn, service_id_t service_id)
+{
+	EXT2FS_DBG("(-, %" PRIun ")", service_id);
+	return ext2fs_node_get(rfn, service_id, EXT2_INODE_ROOT_INDEX);
+}
+
+int ext2fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
+{
+	EXT2FS_DBG("(-,-,%s)", component);
+	ext2fs_node_t *eparent = EXT2FS_NODE(pfn);
+	ext2_filesystem_t *fs;
+	ext2_directory_iterator_t it;
+	int rc;
+	size_t name_size;
+	size_t component_size;
+	bool found = false;
+	uint32_t inode;
+	
+	fs = eparent->instance->filesystem;
+	
+	if (!ext2_inode_is_type(fs->superblock, eparent->inode_ref->inode,
+	    EXT2_INODE_MODE_DIRECTORY)) {
+		return ENOTDIR;
+	}
+	
+	rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref, 0);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	/* Find length of component in bytes
+	 * TODO: check for library function call that does this
+	 */
+	component_size = 0;
+	while (*(component+component_size) != 0) {
+		component_size++;
+	}
+	
+	while (it.current != NULL) {
+		inode = ext2_directory_entry_ll_get_inode(it.current);
+		
+		/* ignore empty directory entries */
+		if (inode != 0) {
+			name_size = ext2_directory_entry_ll_get_name_length(fs->superblock,
+				it.current);
+
+			if (name_size == component_size && bcmp(component, &it.current->name,
+				    name_size) == 0) {
+				rc = ext2fs_node_get_core(rfn, eparent->instance,
+					inode);
+				if (rc != EOK) {
+					ext2_directory_iterator_fini(&it);
+					return rc;
+				}
+				found = true;
+				break;
+			}
+		}
+		
+		rc = ext2_directory_iterator_next(&it);
+		if (rc != EOK) {
+			ext2_directory_iterator_fini(&it);
+			return rc;
+		}
+	}
+	
+	ext2_directory_iterator_fini(&it);
+	
+	if (!found) {
+		return ENOENT;
+	}
+	
+	return EOK;
+}
+
+/** Instantiate a EXT2 in-core node. */
+int ext2fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
+{
+	EXT2FS_DBG("(-,%" PRIun ",%u)", service_id, index);
+	
+	ext2fs_instance_t *inst = NULL;
+	int rc;
+	
+	rc = ext2fs_instance_get(service_id, &inst);
+	if (rc != EOK) {
+		return rc;
+	}
+	
+	return ext2fs_node_get_core(rfn, inst, index);
+}
+
+int ext2fs_node_get_core(fs_node_t **rfn, ext2fs_instance_t *inst,
+		fs_index_t index)
+{
+	int rc;
+	fs_node_t *node = NULL;
+	ext2fs_node_t *enode = NULL;
+	
+	ext2_inode_ref_t *inode_ref = NULL;
+
+	fibril_mutex_lock(&open_nodes_lock);
+	
+	/* Check if the node is not already open */
+	node_key_t key = {
+		.service_id = inst->service_id,
+		.index = index
+	};
+	ht_link_t *already_open = hash_table_find(&open_nodes, &key);
+
+	if (already_open) {
+		enode = hash_table_get_inst(already_open, ext2fs_node_t, link);
+		*rfn = enode->fs_node;
+		enode->references++;
+
+		fibril_mutex_unlock(&open_nodes_lock);
+		return EOK;
+	}
+
+	enode = malloc(sizeof(ext2fs_node_t));
+	if (enode == NULL) {
+		fibril_mutex_unlock(&open_nodes_lock);
+		return ENOMEM;
+	}
+
+	node = malloc(sizeof(fs_node_t));
+	if (node == NULL) {
+		free(enode);
+		fibril_mutex_unlock(&open_nodes_lock);
+		return ENOMEM;
+	}	
+	fs_node_initialize(node);
+
+	rc = ext2_filesystem_get_inode_ref(inst->filesystem, index, &inode_ref);
+	if (rc != EOK) {
+		free(enode);
+		free(node);
+		fibril_mutex_unlock(&open_nodes_lock);
+		return rc;
+	}
+	
+	enode->inode_ref = inode_ref;
+	enode->instance = inst;
+	enode->references = 1;
+	enode->fs_node = node;
+	
+	node->data = enode;
+	*rfn = node;
+	
+	hash_table_insert(&open_nodes, &enode->link);
+	inst->open_nodes_count++;
+	
+	EXT2FS_DBG("inode: %u", inode_ref->index);
+	
+	EXT2FS_DBG("EOK");
+
+	fibril_mutex_unlock(&open_nodes_lock);
+	return EOK;
+}
+
+int ext2fs_node_open(fs_node_t *fn)
+{
+	EXT2FS_DBG("");
+	/*
+	 * Opening a file is stateless, nothing
+	 * to be done here.
+	 */
+	return EOK;
+}
+
+int ext2fs_node_put(fs_node_t *fn)
+{
+	EXT2FS_DBG("");
+	int rc;
+	ext2fs_node_t *enode = EXT2FS_NODE(fn);
+	
+	fibril_mutex_lock(&open_nodes_lock);
+
+	assert(enode->references > 0);
+	enode->references--;
+	if (enode->references == 0) {
+		rc = ext2fs_node_put_core(enode);
+		if (rc != EOK) {
+			fibril_mutex_unlock(&open_nodes_lock);
+			return rc;
+		}
+	}
+
+	fibril_mutex_unlock(&open_nodes_lock);
+	
+	return EOK;
+}
+
+int ext2fs_node_put_core(ext2fs_node_t *enode)
+{
+	node_key_t key = {
+		.service_id = enode->instance->service_id,
+		.index = enode->inode_ref->index
+	};
+
+	hash_table_remove(&open_nodes, &key);
+	
+	assert(enode->instance->open_nodes_count > 0);
+	enode->instance->open_nodes_count--;
+
+	int rc = ext2_filesystem_put_inode_ref(enode->inode_ref);
+	if (rc != EOK) {
+		EXT2FS_DBG("ext2_filesystem_put_inode_ref failed");
+		return rc;
+	}
+
+	free(enode->fs_node);
+	free(enode);
+	return EOK;
+}
+
+int ext2fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
+{
+	EXT2FS_DBG("");
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2fs_destroy_node(fs_node_t *fn)
+{
+	EXT2FS_DBG("");
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)
+{
+	EXT2FS_DBG("");
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
+{
+	EXT2FS_DBG("");
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2fs_has_children(bool *has_children, fs_node_t *fn)
+{
+	EXT2FS_DBG("");
+	ext2fs_node_t *enode = EXT2FS_NODE(fn);
+	ext2_directory_iterator_t it;
+	ext2_filesystem_t *fs;
+	int rc;
+	bool found = false;
+	size_t name_size;
+
+	fs = enode->instance->filesystem;
+
+	if (!ext2_inode_is_type(fs->superblock, enode->inode_ref->inode,
+	    EXT2_INODE_MODE_DIRECTORY)) {
+		*has_children = false;
+		EXT2FS_DBG("EOK - false");
+		return EOK;
+	}
+	
+	rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref, 0);
+	if (rc != EOK) {
+		EXT2FS_DBG("error %u", rc);
+		return rc;
+	}
+	
+	/* Find a non-empty directory entry */
+	while (it.current != NULL) {
+		if (it.current->inode != 0) {
+			name_size = ext2_directory_entry_ll_get_name_length(fs->superblock,
+				it.current);
+			if (!ext2fs_is_dots(&it.current->name, name_size)) {
+				found = true;
+				break;
+			}
+		}
+		
+		rc = ext2_directory_iterator_next(&it);
+		if (rc != EOK) {
+			ext2_directory_iterator_fini(&it);
+			EXT2FS_DBG("error %u", rc);
+			return rc;
+		}
+	}
+	
+	rc = ext2_directory_iterator_fini(&it);
+	if (rc != EOK) {
+		EXT2FS_DBG("error %u", rc);
+		return rc;
+	}
+
+	*has_children = found;
+	EXT2FS_DBG("EOK");
+	
+	return EOK;
+}
+
+
+fs_index_t ext2fs_index_get(fs_node_t *fn)
+{
+	ext2fs_node_t *enode = EXT2FS_NODE(fn);
+	EXT2FS_DBG("%u", enode->inode_ref->index);
+	return enode->inode_ref->index;
+}
+
+aoff64_t ext2fs_size_get(fs_node_t *fn)
+{
+	ext2fs_node_t *enode = EXT2FS_NODE(fn);
+	aoff64_t size = ext2_inode_get_size(enode->instance->filesystem->superblock,
+	    enode->inode_ref->inode);
+	EXT2FS_DBG("%" PRIu64, size);
+	return size;
+}
+
+unsigned ext2fs_lnkcnt_get(fs_node_t *fn)
+{
+	ext2fs_node_t *enode = EXT2FS_NODE(fn);
+	unsigned count = ext2_inode_get_usage_count(enode->inode_ref->inode);
+	EXT2FS_DBG("%u", count);
+	return count;
+}
+
+bool ext2fs_is_directory(fs_node_t *fn)
+{
+	ext2fs_node_t *enode = EXT2FS_NODE(fn);
+	bool is_dir = ext2_inode_is_type(enode->instance->filesystem->superblock,
+	    enode->inode_ref->inode, EXT2_INODE_MODE_DIRECTORY);
+	EXT2FS_DBG("%s", is_dir ? "true" : "false");
+	EXT2FS_DBG("%u", enode->inode_ref->index);
+	return is_dir;
+}
+
+bool ext2fs_is_file(fs_node_t *fn)
+{
+	ext2fs_node_t *enode = EXT2FS_NODE(fn);
+	bool is_file = ext2_inode_is_type(enode->instance->filesystem->superblock,
+	    enode->inode_ref->inode, EXT2_INODE_MODE_FILE);
+	EXT2FS_DBG("%s", is_file ? "true" : "false");
+	return is_file;
+}
+
+service_id_t ext2fs_service_get(fs_node_t *fn)
+{
+	EXT2FS_DBG("");
+	ext2fs_node_t *enode = EXT2FS_NODE(fn);
+	return enode->instance->service_id;
+}
+
+/** libfs operations */
+libfs_ops_t ext2fs_libfs_ops = {
+	.root_get = ext2fs_root_get,
+	.match = ext2fs_match,
+	.node_get = ext2fs_node_get,
+	.node_open = ext2fs_node_open,
+	.node_put = ext2fs_node_put,
+	.create = ext2fs_create_node,
+	.destroy = ext2fs_destroy_node,
+	.link = ext2fs_link,
+	.unlink = ext2fs_unlink,
+	.has_children = ext2fs_has_children,
+	.index_get = ext2fs_index_get,
+	.size_get = ext2fs_size_get,
+	.lnkcnt_get = ext2fs_lnkcnt_get,
+	.is_directory = ext2fs_is_directory,
+	.is_file = ext2fs_is_file,
+	.service_get = ext2fs_service_get
+};
+
+/*
+ * VFS operations.
+ */
+
+static int ext2fs_mounted(service_id_t service_id, const char *opts,
+   fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
+{
+	EXT2FS_DBG("");
+	int rc;
+	ext2_filesystem_t *fs;
+	ext2fs_instance_t *inst;
+	bool read_only;
+	
+	/* Allocate libext2 filesystem structure */
+	fs = (ext2_filesystem_t *) malloc(sizeof(ext2_filesystem_t));
+	if (fs == NULL)
+		return ENOMEM;
+	
+	/* Allocate instance structure */
+	inst = (ext2fs_instance_t *) malloc(sizeof(ext2fs_instance_t));
+	if (inst == NULL) {
+		free(fs);
+		return ENOMEM;
+	}
+	
+	/* Initialize the filesystem  */
+	rc = ext2_filesystem_init(fs, service_id);
+	if (rc != EOK) {
+		free(fs);
+		free(inst);
+		return rc;
+	}
+	
+	/* Do some sanity checking */
+	rc = ext2_filesystem_check_sanity(fs);
+	if (rc != EOK) {
+		ext2_filesystem_fini(fs);
+		free(fs);
+		free(inst);
+		return rc;
+	}
+	
+	/* Check flags */
+	rc = ext2_filesystem_check_flags(fs, &read_only);
+	if (rc != EOK) {
+		ext2_filesystem_fini(fs);
+		free(fs);
+		free(inst);
+		return rc;
+	}
+	
+	/* Initialize instance */
+	link_initialize(&inst->link);
+	inst->service_id = service_id;
+	inst->filesystem = fs;
+	inst->open_nodes_count = 0;
+	
+	/* Read root node */
+	fs_node_t *root_node;
+	rc = ext2fs_node_get_core(&root_node, inst, EXT2_INODE_ROOT_INDEX);
+	if (rc != EOK) {
+		ext2_filesystem_fini(fs);
+		free(fs);
+		free(inst);
+		return rc;
+	}
+	ext2fs_node_t *enode = EXT2FS_NODE(root_node);
+		
+	/* Add instance to the list */
+	fibril_mutex_lock(&instance_list_mutex);
+	list_append(&inst->link, &instance_list);
+	fibril_mutex_unlock(&instance_list_mutex);
+	
+	*index = EXT2_INODE_ROOT_INDEX;
+	*size = 0;
+	*lnkcnt = ext2_inode_get_usage_count(enode->inode_ref->inode);
+	
+	ext2fs_node_put(root_node);
+
+	return EOK;
+}
+
+static int ext2fs_unmounted(service_id_t service_id)
+{
+	EXT2FS_DBG("");
+	ext2fs_instance_t *inst;
+	int rc;
+	
+	rc = ext2fs_instance_get(service_id, &inst);
+	
+	if (rc != EOK)
+		return rc;
+	
+	fibril_mutex_lock(&open_nodes_lock);
+
+	EXT2FS_DBG("open_nodes_count = %d", inst->open_nodes_count)
+	if (inst->open_nodes_count != 0) {
+		fibril_mutex_unlock(&open_nodes_lock);
+		return EBUSY;
+	}
+	
+	/* Remove the instance from the list */
+	fibril_mutex_lock(&instance_list_mutex);
+	list_remove(&inst->link);
+	fibril_mutex_unlock(&instance_list_mutex);
+
+	fibril_mutex_unlock(&open_nodes_lock);
+	
+	ext2_filesystem_fini(inst->filesystem);
+	
+	return EOK;
+}
+
+static int
+ext2fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
+    size_t *rbytes)
+{
+	EXT2FS_DBG("");
+	
+	ext2fs_instance_t *inst;
+	ext2_inode_ref_t *inode_ref;
+	int rc;
+	
+	/*
+	 * Receive the read request.
+	 */
+	ipc_callid_t callid;
+	size_t size;
+	if (!async_data_read_receive(&callid, &size)) {
+		async_answer_0(callid, EINVAL);
+		return EINVAL;
+	}
+	
+	rc = ext2fs_instance_get(service_id, &inst);
+	if (rc != EOK) {
+		async_answer_0(callid, rc);
+		return rc;
+	}
+	
+	rc = ext2_filesystem_get_inode_ref(inst->filesystem, index, &inode_ref);
+	if (rc != EOK) {
+		async_answer_0(callid, rc);
+		return rc;
+	}
+	
+	if (ext2_inode_is_type(inst->filesystem->superblock, inode_ref->inode,
+	    EXT2_INODE_MODE_FILE)) {
+		rc = ext2fs_read_file(callid, pos, size, inst, inode_ref,
+		    rbytes);
+	} else if (ext2_inode_is_type(inst->filesystem->superblock,
+	    inode_ref->inode, EXT2_INODE_MODE_DIRECTORY)) {
+		rc = ext2fs_read_directory(callid, pos, size, inst, inode_ref,
+		    rbytes);
+	} else {
+		/* Other inode types not supported */
+		async_answer_0(callid, ENOTSUP);
+		rc = ENOTSUP;
+	}
+	
+	ext2_filesystem_put_inode_ref(inode_ref);
+	
+	return rc;
+}
+
+/**
+ * Determine whether given directory entry name is . or ..
+ */
+bool ext2fs_is_dots(const uint8_t *name, size_t name_size) {
+	if (name_size == 1 && name[0] == '.') {
+		return true;
+	}
+	
+	if (name_size == 2 && name[0] == '.' && name[1] == '.') {
+		return true;
+	}
+	
+	return false;
+}
+
+int ext2fs_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size,
+    ext2fs_instance_t *inst, ext2_inode_ref_t *inode_ref, size_t *rbytes)
+{
+	ext2_directory_iterator_t it;
+	aoff64_t next;
+	uint8_t *buf;
+	size_t name_size;
+	int rc;
+	bool found = false;
+	
+	rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref, pos);
+	if (rc != EOK) {
+		async_answer_0(callid, rc);
+		return rc;
+	}
+	
+	/* Find next interesting directory entry.
+	 * We want to skip . and .. entries
+	 * as these are not used in HelenOS
+	 */
+	while (it.current != NULL) {
+		if (it.current->inode == 0) {
+			goto skip;
+		}
+		
+		name_size = ext2_directory_entry_ll_get_name_length(
+		    inst->filesystem->superblock, it.current);
+		
+		/* skip . and .. */
+		if (ext2fs_is_dots(&it.current->name, name_size)) {
+			goto skip;
+		}
+		
+		/* The on-disk entry does not contain \0 at the end
+		 * end of entry name, so we copy it to new buffer
+		 * and add the \0 at the end
+		 */
+		buf = malloc(name_size+1);
+		if (buf == NULL) {
+			ext2_directory_iterator_fini(&it);
+			async_answer_0(callid, ENOMEM);
+			return ENOMEM;
+		}
+		memcpy(buf, &it.current->name, name_size);
+		*(buf + name_size) = 0;
+		found = true;
+		(void) async_data_read_finalize(callid, buf, name_size + 1);
+		free(buf);
+		break;
+		
+skip:
+		rc = ext2_directory_iterator_next(&it);
+		if (rc != EOK) {
+			ext2_directory_iterator_fini(&it);
+			async_answer_0(callid, rc);
+			return rc;
+		}
+	}
+	
+	if (found) {
+		rc = ext2_directory_iterator_next(&it);
+		if (rc != EOK)
+			return rc;
+		next = it.current_offset;
+	}
+	
+	rc = ext2_directory_iterator_fini(&it);
+	if (rc != EOK)
+		return rc;
+	
+	if (found) {
+		*rbytes = next - pos;
+		return EOK;
+	} else {
+		async_answer_0(callid, ENOENT);
+		return ENOENT;
+	}
+}
+
+int ext2fs_read_file(ipc_callid_t callid, aoff64_t pos, size_t size,
+    ext2fs_instance_t *inst, ext2_inode_ref_t *inode_ref, size_t *rbytes)
+{
+	int rc;
+	uint32_t block_size;
+	aoff64_t file_block;
+	uint64_t file_size;
+	uint32_t fs_block;
+	size_t offset_in_block;
+	size_t bytes;
+	block_t *block;
+	uint8_t *buffer;
+	
+	file_size = ext2_inode_get_size(inst->filesystem->superblock,
+		inode_ref->inode);
+	
+	if (pos >= file_size) {
+		/* Read 0 bytes successfully */
+		async_data_read_finalize(callid, NULL, 0);
+		*rbytes = 0;
+		return EOK;
+	}
+	
+	/* For now, we only read data from one block at a time */
+	block_size = ext2_superblock_get_block_size(inst->filesystem->superblock);
+	file_block = pos / block_size;
+	offset_in_block = pos % block_size;
+	bytes = min(block_size - offset_in_block, size);
+	
+	/* Handle end of file */
+	if (pos + bytes > file_size) {
+		bytes = file_size - pos;
+	}
+	
+	/* Get the real block number */
+	rc = ext2_filesystem_get_inode_data_block_index(inst->filesystem,
+		inode_ref->inode, file_block, &fs_block);
+	if (rc != EOK) {
+		async_answer_0(callid, rc);
+		return rc;
+	}
+	
+	/* Check for sparse file
+	 * If ext2_filesystem_get_inode_data_block_index returned
+	 * fs_block == 0, it means that the given block is not allocated for the 
+	 * file and we need to return a buffer of zeros
+	 */
+	if (fs_block == 0) {
+		buffer = malloc(bytes);
+		if (buffer == NULL) {
+			async_answer_0(callid, ENOMEM);
+			return ENOMEM;
+		}
+		
+		memset(buffer, 0, bytes);
+		
+		async_data_read_finalize(callid, buffer, bytes);
+		*rbytes = bytes;
+		
+		free(buffer);
+		
+		return EOK;
+	}
+	
+	/* Usual case - we need to read a block from device */
+	rc = block_get(&block, inst->service_id, fs_block, BLOCK_FLAGS_NONE);
+	if (rc != EOK) {
+		async_answer_0(callid, rc);
+		return rc;
+	}
+	
+	assert(offset_in_block + bytes <= block_size);
+	async_data_read_finalize(callid, block->data + offset_in_block, bytes);
+	
+	rc = block_put(block);
+	if (rc != EOK)
+		return rc;
+	
+	*rbytes = bytes;
+	return EOK;
+}
+
+static int
+ext2fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
+    size_t *wbytes, aoff64_t *nsize)
+{
+	EXT2FS_DBG("");
+	return ENOTSUP;
+}
+
+static int
+ext2fs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size)
+{
+	EXT2FS_DBG("");
+	return ENOTSUP;
+}
+
+static int ext2fs_close(service_id_t service_id, fs_index_t index)
+{
+	EXT2FS_DBG("");
+	return EOK;
+}
+
+static int ext2fs_destroy(service_id_t service_id, fs_index_t index)
+{
+	EXT2FS_DBG("");
+	return ENOTSUP;
+}
+
+static int ext2fs_sync(service_id_t service_id, fs_index_t index)
+{
+	EXT2FS_DBG("");
+	return ENOTSUP;
+}
+
+vfs_out_ops_t ext2fs_ops = {
+	.mounted = ext2fs_mounted,
+	.unmounted = ext2fs_unmounted,
+	.read = ext2fs_read,
+	.write = ext2fs_write,
+	.truncate = ext2fs_truncate,
+	.close = ext2fs_close,
+	.destroy = ext2fs_destroy,
+	.sync = ext2fs_sync,
+};
+
+/**
+ * @}
+ */
+
Index: uspace/srv/fs/ext4fs/ext4fs_ops.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -1,4 +1,3 @@
 /*
- * Copyright (c) 2011 Martin Sucha
  * Copyright (c) 2012 Frantisek Princ
  * All rights reserved.
Index: uspace/srv/fs/fat/fat.h
===================================================================
--- uspace/srv/fs/fat/fat.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/fat/fat.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <atomic.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include "../../vfs/vfs.h"
 
Index: uspace/srv/fs/fat/fat_dentry.h
===================================================================
--- uspace/srv/fs/fat/fat_dentry.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/fat/fat_dentry.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <stdint.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #define IS_D_CHAR(ch) (isalnum(ch) || ch == '_')
Index: uspace/srv/fs/locfs/locfs_ops.c
===================================================================
--- uspace/srv/fs/locfs/locfs_ops.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/locfs/locfs_ops.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 
 #include <macros.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <malloc.h>
Index: uspace/srv/fs/locfs/locfs_ops.h
===================================================================
--- uspace/srv/fs/locfs/locfs_ops.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/locfs/locfs_ops.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
 #define LOCFS_LOCFS_OPS_H_
 
-#include <stdbool.h>
+#include <bool.h>
 
 extern bool locfs_init(void);
Index: uspace/srv/fs/tmpfs/tmpfs.h
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/tmpfs/tmpfs.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 #include <atomic.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <adt/hash_table.h>
 
Index: uspace/srv/fs/udf/udf.h
===================================================================
--- uspace/srv/fs/udf/udf.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/udf/udf.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #include <atomic.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include "../../vfs/vfs.h"
 #include "udf_types.h"
Index: uspace/srv/fs/udf/udf_cksum.h
===================================================================
--- uspace/srv/fs/udf/udf_cksum.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/udf/udf_cksum.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 #define UDF_TAG_SIZE  16
Index: uspace/srv/fs/udf/udf_idx.c
===================================================================
--- uspace/srv/fs/udf/udf_idx.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/udf/udf_idx.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #include <adt/hash.h>
 #include <adt/list.h>
-#include <stdbool.h>
+#include <bool.h>
 #include "udf_idx.h"
 #include "udf.h"
Index: uspace/srv/fs/udf/udf_osta.h
===================================================================
--- uspace/srv/fs/udf/udf_osta.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/udf/udf_osta.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -41,5 +41,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include "udf_types.h"
 
Index: uspace/srv/fs/udf/udf_types.h
===================================================================
--- uspace/srv/fs/udf/udf_types.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/fs/udf/udf_types.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <byteorder.h>
 
Index: uspace/srv/hid/compositor/compositor.c
===================================================================
--- uspace/srv/hid/compositor/compositor.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/compositor/compositor.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <str_error.h>
@@ -87,4 +87,21 @@
 static sysarg_t coord_origin;
 static pixel_t bg_color;
+
+typedef struct {
+	link_t link;
+	sysarg_t id;
+	uint8_t state;
+	desktop_point_t pos;
+	sysarg_t btn_num;
+	desktop_point_t btn_pos;
+	desktop_vector_t accum;
+	sysarg_t grab_flags;
+	bool pressed;
+	cursor_t cursor;
+} pointer_t;
+
+static sysarg_t pointer_id = 0;
+static FIBRIL_MUTEX_INITIALIZE(pointer_list_mtx);
+static LIST_INITIALIZE(pointer_list);
 
 typedef struct {
@@ -112,23 +129,4 @@
 typedef struct {
 	link_t link;
-	sysarg_t id;
-	uint8_t state;
-	desktop_point_t pos;
-	sysarg_t btn_num;
-	desktop_point_t btn_pos;
-	desktop_vector_t accum;
-	sysarg_t grab_flags;
-	bool pressed;
-	cursor_t cursor;
-	window_t ghost;
-	desktop_vector_t accum_ghost;
-} pointer_t;
-
-static sysarg_t pointer_id = 0;
-static FIBRIL_MUTEX_INITIALIZE(pointer_list_mtx);
-static LIST_INITIALIZE(pointer_list);
-
-typedef struct {
-	link_t link;
 	service_id_t dsid;
 	vslmode_t mode;
@@ -183,17 +181,4 @@
 	cursor_init(&p->cursor, CURSOR_DECODER_EMBEDDED, NULL);
 
-	/* Ghost window for transformation animation. */
-	transform_identity(&p->ghost.transform);
-	transform_translate(&p->ghost.transform, coord_origin, coord_origin);
-	p->ghost.dx = coord_origin;
-	p->ghost.dy = coord_origin;
-	p->ghost.fx = 1;
-	p->ghost.fy = 1;
-	p->ghost.angle = 0;
-	p->ghost.opacity = 255;
-	p->ghost.surface = NULL;
-	p->accum_ghost.x = 0;
-	p->accum_ghost.y = 0;
-
 	return p;
 }
@@ -207,5 +192,5 @@
 }
 
-static window_t *window_create(sysarg_t x_offset, sysarg_t y_offset)
+static window_t *window_create()
 {
 	window_t *win = (window_t *) malloc(sizeof(window_t));
@@ -217,8 +202,7 @@
 	prodcons_initialize(&win->queue);
 	transform_identity(&win->transform);
-	transform_translate(&win->transform, 
-	    coord_origin + x_offset, coord_origin + y_offset);
-	win->dx = coord_origin + x_offset;
-	win->dy = coord_origin + y_offset;
+	transform_translate(&win->transform, coord_origin, coord_origin);
+	win->dx = coord_origin;
+	win->dy = coord_origin;
 	win->fx = 1;
 	win->fy = 1;
@@ -266,5 +250,5 @@
 }
 
-static void comp_coord_from_client(double x_in, double y_in, transform_t win_trans,
+static void comp_coord_from_client(sysarg_t x_in, sysarg_t y_in, transform_t win_trans,
     sysarg_t *x_out, sysarg_t *y_out)
 {
@@ -279,33 +263,26 @@
 }
 
-static void comp_coord_bounding_rect(double x_in, double y_in,
-    double w_in, double h_in, transform_t win_trans,
+static void comp_coord_bounding_rect(sysarg_t x_in, sysarg_t y_in,
+    sysarg_t w_in, sysarg_t h_in, transform_t win_trans,
     sysarg_t *x_out, sysarg_t *y_out, sysarg_t *w_out, sysarg_t *h_out)
 {
-	if (w_in > 0 && h_in > 0) {
-		sysarg_t x[4];
-		sysarg_t y[4];
-		comp_coord_from_client(x_in, y_in, win_trans, &x[0], &y[0]);
-		comp_coord_from_client(x_in + w_in - 1, y_in, win_trans, &x[1], &y[1]);
-		comp_coord_from_client(x_in + w_in - 1, y_in + h_in - 1, win_trans, &x[2], &y[2]);
-		comp_coord_from_client(x_in, y_in + h_in - 1, win_trans, &x[3], &y[3]);
-		(*x_out) = x[0];
-		(*y_out) = y[0];
-		(*w_out) = x[0];
-		(*h_out) = y[0];
-		for (int i = 1; i < 4; ++i) {
-			(*x_out) = (x[i] < (*x_out)) ? x[i] : (*x_out);
-			(*y_out) = (y[i] < (*y_out)) ? y[i] : (*y_out);
-			(*w_out) = (x[i] > (*w_out)) ? x[i] : (*w_out);
-			(*h_out) = (y[i] > (*h_out)) ? y[i] : (*h_out);
-		}
-		(*w_out) = (*w_out) - (*x_out) + 1;
-		(*h_out) = (*h_out) - (*y_out) + 1;
-	} else {
-		(*x_out) = 0;
-		(*y_out) = 0;
-		(*w_out) = 0;
-		(*h_out) = 0;
-	}
+	sysarg_t x[4];
+	sysarg_t y[4];
+	comp_coord_from_client(x_in, y_in, win_trans, &x[0], &y[0]);
+	comp_coord_from_client(x_in + w_in, y_in, win_trans, &x[1], &y[1]);
+	comp_coord_from_client(x_in + w_in, y_in + h_in, win_trans, &x[2], &y[2]);
+	comp_coord_from_client(x_in, y_in + h_in, win_trans, &x[3], &y[3]);
+	(*x_out) = x[0];
+	(*y_out) = y[0];
+	(*w_out) = x[0];
+	(*h_out) = y[0];
+	for (int i = 1; i < 4; ++i) {
+		(*x_out) = (x[i] < (*x_out)) ? x[i] : (*x_out);
+		(*y_out) = (y[i] < (*y_out)) ? y[i] : (*y_out);
+		(*w_out) = (x[i] > (*w_out)) ? x[i] : (*w_out);
+		(*h_out) = (y[i] > (*h_out)) ? y[i] : (*h_out);
+	}
+	(*w_out) -= (*x_out);
+	(*h_out) -= (*y_out);
 }
 
@@ -332,13 +309,8 @@
 			/* Paint background color. */
 			for (sysarg_t y = y_dmg_vp - vp->pos.y; y <  y_dmg_vp - vp->pos.y + h_dmg_vp; ++y) {
-				pixel_t *dst = pixelmap_pixel_at(
-				    surface_pixmap_access(vp->surface), x_dmg_vp - vp->pos.x, y);
-				sysarg_t count = w_dmg_vp;
-				while (count-- != 0) {
-					*dst++ = bg_color;
+				for (sysarg_t x = x_dmg_vp - vp->pos.x; x < x_dmg_vp - vp->pos.x + w_dmg_vp; ++x) {
+					surface_put_pixel(vp->surface, x, y, bg_color);
 				}
 			}
-			surface_add_damaged_region(vp->surface,
-			    x_dmg_vp - vp->pos.x, y_dmg_vp - vp->pos.y, w_dmg_vp, h_dmg_vp);
 
 			transform_t transform;
@@ -391,80 +363,4 @@
 			list_foreach(pointer_list, link) {
 
-				pointer_t *ptr = list_get_instance(link, pointer_t, link);
-				if (ptr->ghost.surface) {
-
-					sysarg_t x_bnd_ghost, y_bnd_ghost, w_bnd_ghost, h_bnd_ghost;
-					sysarg_t x_dmg_ghost, y_dmg_ghost, w_dmg_ghost, h_dmg_ghost;
-					surface_get_resolution(ptr->ghost.surface, &w_bnd_ghost, &h_bnd_ghost);
-					comp_coord_bounding_rect(0, 0, w_bnd_ghost, h_bnd_ghost, ptr->ghost.transform,
-					    &x_bnd_ghost, &y_bnd_ghost, &w_bnd_ghost, &h_bnd_ghost);
-					bool isec_ghost = rectangle_intersect(
-					    x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp,
-					    x_bnd_ghost, y_bnd_ghost, w_bnd_ghost, h_bnd_ghost,
-					    &x_dmg_ghost, &y_dmg_ghost, &w_dmg_ghost, &h_dmg_ghost);
-
-					if (isec_ghost) {
-						/* FIXME: Ghost is currently drawn based on the bounding
-						 * rectangle of the window, which is sufficient as long
-						 * as the windows can be rotated only by 90 degrees. 
-						 * For ghost to be compatible with arbitrary-angle
-						 * rotation, it should be drawn as four lines adjusted
-						 * by the transformation matrix. That would however
-						 * require to equip libdraw with line drawing functionality. */
-
-						transform_t transform = ptr->ghost.transform;
-						double_point_t pos;
-						pos.x = vp->pos.x;
-						pos.y = vp->pos.y;
-						transform_translate(&transform, -pos.x, -pos.y);
-
-						pixel_t ghost_color;
-
-						if (y_bnd_ghost == y_dmg_ghost) {
-							for (sysarg_t x = x_dmg_ghost - vp->pos.x;
-								    x < x_dmg_ghost - vp->pos.x + w_dmg_ghost; ++x) {
-								ghost_color = surface_get_pixel(vp->surface,
-								    x, y_dmg_ghost - vp->pos.y);
-								surface_put_pixel(vp->surface,
-								    x, y_dmg_ghost - vp->pos.y, INVERT(ghost_color));
-							}
-						}
-
-						if (y_bnd_ghost + h_bnd_ghost == y_dmg_ghost + h_dmg_ghost) {
-							for (sysarg_t x = x_dmg_ghost - vp->pos.x;
-								    x < x_dmg_ghost - vp->pos.x + w_dmg_ghost; ++x) {
-								ghost_color = surface_get_pixel(vp->surface,
-								    x, y_dmg_ghost - vp->pos.y + h_dmg_ghost - 1);
-								surface_put_pixel(vp->surface,
-								    x, y_dmg_ghost - vp->pos.y + h_dmg_ghost - 1, INVERT(ghost_color));
-							}
-						}
-
-						if (x_bnd_ghost == x_dmg_ghost) {
-							for (sysarg_t y = y_dmg_ghost - vp->pos.y;
-								    y < y_dmg_ghost - vp->pos.y + h_dmg_ghost; ++y) {
-								ghost_color = surface_get_pixel(vp->surface,
-								    x_dmg_ghost - vp->pos.x, y);
-								surface_put_pixel(vp->surface,
-								    x_dmg_ghost - vp->pos.x, y, INVERT(ghost_color));
-							}
-						}
-
-						if (x_bnd_ghost + w_bnd_ghost == x_dmg_ghost + w_dmg_ghost) {
-							for (sysarg_t y = y_dmg_ghost - vp->pos.y;
-								    y < y_dmg_ghost - vp->pos.y + h_dmg_ghost; ++y) {
-								ghost_color = surface_get_pixel(vp->surface,
-								    x_dmg_ghost - vp->pos.x + w_dmg_ghost - 1, y);
-								surface_put_pixel(vp->surface,
-								    x_dmg_ghost - vp->pos.x + w_dmg_ghost - 1, y, INVERT(ghost_color));
-							}
-						}
-					}
-
-				}
-			}
-
-			list_foreach(pointer_list, link) {
-
 				/* Determine what part of the pointer intersects with the
 				 * updated area of the current viewport. */
@@ -480,9 +376,10 @@
 				if (isec_ptr) {
 					/* Pointer is currently painted directly by copying pixels.
-					 * However, it is possible to draw the pointer similarly
+					 * However, it is possible to draw the painter similarly
 					 * as window by using drawctx_transfer. It would allow
 					 * more sophisticated control over drawing, but would also
 					 * cost more regarding the performance. */
 
+					pixel_t pix = 0;
 					sysarg_t x_vp = x_dmg_ptr - vp->pos.x;
 					sysarg_t y_vp = y_dmg_ptr - vp->pos.y;
@@ -491,17 +388,12 @@
 
 					for (sysarg_t y = 0; y < h_dmg_ptr; ++y) {
-						pixel_t *src = pixelmap_pixel_at(
-						    surface_pixmap_access(sf_ptr), x_ptr, y_ptr + y);
-						pixel_t *dst = pixelmap_pixel_at(
-						    surface_pixmap_access(vp->surface), x_vp, y_vp + y);
-						sysarg_t count = w_dmg_ptr;
-						while (count-- != 0) {
-							*dst = (*src & 0xff000000) ? *src : *dst;
-							++dst; ++src;
+						for (sysarg_t x = 0; x < w_dmg_ptr; ++x) {
+							pix = surface_get_pixel(sf_ptr, x_ptr + x, y_ptr + y);
+							if (ALPHA(pix) == 255) {
+								surface_put_pixel(vp->surface, x_vp + x, y_vp + y, pix);
+							}
 						}
 					}
-					surface_add_damaged_region(vp->surface, x_vp, y_vp, w_dmg_ptr, h_dmg_ptr);
 				}
-
 			}
 		}
@@ -549,8 +441,8 @@
 static void comp_window_damage(window_t *win, ipc_callid_t iid, ipc_call_t *icall)
 {
-	double x = IPC_GET_ARG1(*icall);
-	double y = IPC_GET_ARG2(*icall);
-	double width = IPC_GET_ARG3(*icall);
-	double height = IPC_GET_ARG4(*icall);
+	sysarg_t x = IPC_GET_ARG1(*icall);
+	sysarg_t y = IPC_GET_ARG2(*icall);
+	sysarg_t width = IPC_GET_ARG3(*icall);
+	sysarg_t height = IPC_GET_ARG4(*icall);
 
 	if (width == 0 || height == 0) {
@@ -558,9 +450,8 @@
 	} else {
 		fibril_mutex_lock(&window_list_mtx);
-		sysarg_t x_dmg_glob, y_dmg_glob, w_dmg_glob, h_dmg_glob;
-		comp_coord_bounding_rect(x - 1, y - 1, width + 2, height + 2,
-		    win->transform, &x_dmg_glob, &y_dmg_glob, &w_dmg_glob, &h_dmg_glob);
+		comp_coord_bounding_rect(x, y, width, height,
+		    win->transform, &x, &y, &width, &height);
 		fibril_mutex_unlock(&window_list_mtx);
-		comp_damage(x_dmg_glob, y_dmg_glob, w_dmg_glob, h_dmg_glob);
+		comp_damage(x, y, width, height);
 	}
 
@@ -577,5 +468,5 @@
 		pointer_t *pointer = list_get_instance(link, pointer_t, link);
 		if (pointer->id == pos_id) {
-			pointer->grab_flags = pointer->pressed ? grab_flags : GF_EMPTY;
+			pointer->grab_flags = grab_flags;
 			// TODO change pointer->state according to grab_flags
 			break;
@@ -650,32 +541,4 @@
 }
 
-static void comp_post_event_win(window_event_t *event, window_t *target)
-{
-	fibril_mutex_lock(&window_list_mtx);
-	window_t *window = NULL;
-	list_foreach(window_list, link) {
-		window = list_get_instance(link, window_t, link);
-		if (window == target) {
-			prodcons_produce(&window->queue, &event->link);
-		}
-	}
-	if (!window) {
-		free(event);
-	}
-	fibril_mutex_unlock(&window_list_mtx);
-}
-
-static void comp_post_event_top(window_event_t *event)
-{
-	fibril_mutex_lock(&window_list_mtx);
-	window_t *win = (window_t *) list_first(&window_list);
-	if (win) {
-		prodcons_produce(&win->queue, &event->link);
-	} else {
-		free(event);
-	}
-	fibril_mutex_unlock(&window_list_mtx);
-}
-
 static void comp_window_close(window_t *win, ipc_callid_t iid, ipc_call_t *icall)
 {
@@ -683,15 +546,5 @@
 	fibril_mutex_lock(&window_list_mtx);
 	list_remove(&win->link);
-	window_t *win_focus = (window_t *) list_first(&window_list);
-	window_event_t *event_focus = (window_event_t *) malloc(sizeof(window_event_t));
-	if (event_focus) {
-		link_initialize(&event_focus->link);
-		event_focus->type = ET_WINDOW_FOCUS;
-	}
 	fibril_mutex_unlock(&window_list_mtx);
-
-	if (event_focus && win_focus) {
-		comp_post_event_win(event_focus, win_focus);
-	}
 
 	/* Calculate damage. */
@@ -748,5 +601,5 @@
 			fibril_mutex_lock(&window_list_mtx);
 
-			window_t *win = window_create(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
+			window_t *win = window_create();
 			if (!win) {
 				async_answer_2(callid, ENOMEM, 0, 0);
@@ -777,20 +630,8 @@
 			}
 
-			window_t *win_unfocus = (window_t *) list_first(&window_list);
 			list_prepend(&win->link, &window_list);
-
-			window_event_t *event_unfocus = (window_event_t *) malloc(sizeof(window_event_t));
-			if (event_unfocus) {
-				link_initialize(&event_unfocus->link);
-				event_unfocus->type = ET_WINDOW_UNFOCUS;
-			}
 			
 			async_answer_2(callid, EOK, win->in_dsid, win->out_dsid);
 			fibril_mutex_unlock(&window_list_mtx);
-			
-			if (event_unfocus && win_unfocus) {
-				comp_post_event_win(event_unfocus, win_unfocus);
-			}
-
 			return;
 		} else {
@@ -1112,4 +953,16 @@
 }
 
+static void comp_post_event(window_event_t *event)
+{
+	fibril_mutex_lock(&window_list_mtx);
+	window_t *win = (window_t *) list_first(&window_list);
+	if (win) {
+		prodcons_produce(&win->queue, &event->link);
+	} else {
+		free(event);
+	}
+	fibril_mutex_unlock(&window_list_mtx);
+}
+
 static void comp_recalc_transform(window_t *win)
 {
@@ -1120,13 +973,9 @@
 	transform_t scale;
 	transform_identity(&scale);
-	if (win->fx != 1 || win->fy != 1) {
-		transform_scale(&scale, win->fx, win->fy);
-	}
+	transform_scale(&scale, win->fx, win->fy);
 
 	transform_t rotate;
 	transform_identity(&rotate);
-	if (win->angle != 0) {
-		transform_rotate(&rotate, win->angle);
-	}
+	transform_rotate(&rotate, win->angle);
 
 	transform_t transform;
@@ -1145,8 +994,7 @@
 
 static void comp_window_animate(pointer_t *pointer, window_t *win,
-    sysarg_t *dmg_x, sysarg_t *dmg_y, sysarg_t *dmg_width, sysarg_t *dmg_height)
+     sysarg_t *dmg_x, sysarg_t *dmg_y, sysarg_t *dmg_width, sysarg_t *dmg_height)
 {
 	/* window_list_mtx locked by caller */
-	/* pointer_list_mtx locked by caller */
 
 	int dx = pointer->accum.x;
@@ -1172,5 +1020,5 @@
 		}
 
-		if ((scale || resize) && (win->angle != 0)) {
+		if (scale || resize) {
 			transform_t rotate;
 			transform_identity(&rotate);
@@ -1189,22 +1037,15 @@
 		double _dx = dx;
 		double _dy = dy;
-		if (win->angle != 0) {
-			transform_t unrotate;
-			transform_identity(&unrotate);
-			transform_rotate(&unrotate, -win->angle);
-			transform_apply_linear(&unrotate, &_dx, &_dy);
-		}
+		transform_t unrotate;
+		transform_identity(&unrotate);
+		transform_rotate(&unrotate, -win->angle);
+		transform_apply_linear(&unrotate, &_dx, &_dy);
 		_dx = (pointer->grab_flags & GF_MOVE_X) ? -_dx : _dx;
 		_dy = (pointer->grab_flags & GF_MOVE_Y) ? -_dy : _dy;
 
 		if ((pointer->grab_flags & GF_SCALE_X) || (pointer->grab_flags & GF_RESIZE_X)) {
-			double fx = 1.0 + (_dx / ((width - 1) * win->fx));
+			double fx = 1.0 + (_dx / (width * win->fx));
 			if (fx > 0) {
-#if ANIMATE_WINDOW_TRANSFORMS == 0
-				if (scale) win->fx *= fx;
-#endif
-#if ANIMATE_WINDOW_TRANSFORMS == 1
 				win->fx *= fx;
-#endif
 				scale_back_x *= fx;
 			}
@@ -1212,12 +1053,7 @@
 
 		if ((pointer->grab_flags & GF_SCALE_Y) || (pointer->grab_flags & GF_RESIZE_Y)) {
-			double fy = 1.0 + (_dy / ((height - 1) * win->fy));
+			double fy = 1.0 + (_dy / (height * win->fy));
 			if (fy > 0) {
-#if ANIMATE_WINDOW_TRANSFORMS == 0
-				if (scale) win->fy *= fy;
-#endif
-#if ANIMATE_WINDOW_TRANSFORMS == 1
 				win->fy *= fy;
-#endif
 				scale_back_y *= fy;
 			}
@@ -1235,113 +1071,4 @@
 	    dmg_x, dmg_y, dmg_width, dmg_height);
 }
-
-#if ANIMATE_WINDOW_TRANSFORMS == 0
-static void comp_ghost_animate(pointer_t *pointer,
-    desktop_rect_t *rect1, desktop_rect_t *rect2, desktop_rect_t *rect3, desktop_rect_t *rect4)
-{
-	/* window_list_mtx locked by caller */
-	/* pointer_list_mtx locked by caller */
-
-	int dx = pointer->accum_ghost.x;
-	int dy = pointer->accum_ghost.y;
-	pointer->accum_ghost.x = 0;
-	pointer->accum_ghost.y = 0;
-
-	bool move = (pointer->grab_flags & GF_MOVE_X) || (pointer->grab_flags & GF_MOVE_Y);
-	bool scale = (pointer->grab_flags & GF_SCALE_X) || (pointer->grab_flags & GF_SCALE_Y);
-	bool resize = (pointer->grab_flags & GF_RESIZE_X) || (pointer->grab_flags & GF_RESIZE_Y);
-
-	sysarg_t width, height;
-	surface_get_resolution(pointer->ghost.surface, &width, &height);
-
-	if (move) {
-		double cx = 0;
-		double cy = 0;
-		if (pointer->grab_flags & GF_MOVE_X) {
-			cx = 1;
-		}
-		if (pointer->grab_flags & GF_MOVE_Y) {
-			cy = 1;
-		}
-
-		if (scale || resize) {
-			transform_t rotate;
-			transform_identity(&rotate);
-			transform_rotate(&rotate, pointer->ghost.angle);
-			transform_apply_linear(&rotate, &cx, &cy);
-		}
-
-		cx = (cx < 0) ? (-1 * cx) : cx;
-		cy = (cy < 0) ? (-1 * cy) : cy;
-
-		pointer->ghost.dx += (cx * dx);
-		pointer->ghost.dy += (cy * dy);
-	}
-
-	if (scale || resize) {
-		double _dx = dx;
-		double _dy = dy;
-		transform_t unrotate;
-		transform_identity(&unrotate);
-		transform_rotate(&unrotate, -pointer->ghost.angle);
-		transform_apply_linear(&unrotate, &_dx, &_dy);
-		_dx = (pointer->grab_flags & GF_MOVE_X) ? -_dx : _dx;
-		_dy = (pointer->grab_flags & GF_MOVE_Y) ? -_dy : _dy;
-
-		if ((pointer->grab_flags & GF_SCALE_X) || (pointer->grab_flags & GF_RESIZE_X)) {
-			double fx = 1.0 + (_dx / ((width - 1) * pointer->ghost.fx));
-			pointer->ghost.fx *= fx;
-		}
-
-		if ((pointer->grab_flags & GF_SCALE_Y) || (pointer->grab_flags & GF_RESIZE_Y)) {
-			double fy = 1.0 + (_dy / ((height - 1) * pointer->ghost.fy));
-			pointer->ghost.fy *= fy;
-		}
-	}
-
-	sysarg_t x1, y1, width1, height1;
-	sysarg_t x2, y2, width2, height2;
-	comp_coord_bounding_rect(0, 0, width, height, pointer->ghost.transform,
-	    &x1, &y1, &width1, &height1);
-	comp_recalc_transform(&pointer->ghost);
-	comp_coord_bounding_rect(0, 0, width, height, pointer->ghost.transform,
-	    &x2, &y2, &width2, &height2);
-
-	sysarg_t x_u, y_u, w_u, h_u;
-	rectangle_union(x1, y1, width1, height1, x2, y2, width2, height2,
-	    &x_u, &y_u, &w_u, &h_u);
-
-	sysarg_t x_i, y_i, w_i, h_i;
-	rectangle_intersect(x1, y1, width1, height1, x2, y2, width2, height2,
-	    &x_i, &y_i, &w_i, &h_i);
-
-	if (w_i == 0 || h_i == 0) {
-		rect1->x = x_u; rect2->x = 0; rect3->x = 0; rect4->x = 0;
-		rect1->y = y_u; rect2->y = 0; rect3->y = 0; rect4->y = 0;
-		rect1->w = w_u; rect2->w = 0; rect3->w = 0; rect4->w = 0;
-		rect1->h = h_u; rect2->h = 0; rect3->h = 0; rect4->h = 0;
-	} else {
-		rect1->x = x_u;
-		rect1->y = y_u;
-		rect1->w = x_i - x_u + 1;
-		rect1->h = h_u;
-
-		rect2->x = x_u;
-		rect2->y = y_u;
-		rect2->w = w_u;
-		rect2->h = y_i - y_u + 1;
-
-		rect3->x = x_i + w_i - 1;
-		rect3->y = y_u;
-		rect3->w = w_u - w_i - x_i + x_u + 1;
-		rect3->h = h_u;
-		
-		rect4->x = x_u;
-		rect4->y = y_i + h_i - 1;
-		rect4->w = w_u;
-		rect4->h = h_u - h_i - y_i + y_u + 1;
-	}
-}
-#endif
 
 static int comp_abs_move(input_t *input, unsigned x , unsigned y,
@@ -1398,5 +1125,4 @@
 
 	fibril_mutex_lock(&window_list_mtx);
-	fibril_mutex_lock(&pointer_list_mtx);
 	window_t *top = (window_t *) list_first(&window_list);
 	if (top && top->surface) {
@@ -1410,8 +1136,8 @@
 			within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
 			    top->transform, width, height, &point_x, &point_y);
-
-			window_event_t *event = NULL;
+			fibril_mutex_unlock(&window_list_mtx);
+
 			if (within_client) {
-				event = (window_event_t *) malloc(sizeof(window_event_t));
+				window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
 				if (event) {
 					link_initialize(&event->link);
@@ -1422,45 +1148,16 @@
 					event->data.pos.hpos = point_x;
 					event->data.pos.vpos = point_y;
+					comp_post_event(event);
 				}
 			}
-
-			fibril_mutex_unlock(&pointer_list_mtx);
-			fibril_mutex_unlock(&window_list_mtx);
-
-			if (event) {
-				comp_post_event_top(event);
-			}
-
 		} else {
 			/* Pointer is grabbed by top-level window action. */
 			pointer->accum.x += dx;
 			pointer->accum.y += dy;
-			pointer->accum_ghost.x += dx;
-			pointer->accum_ghost.y += dy;
-#if ANIMATE_WINDOW_TRANSFORMS == 0
-			if (pointer->ghost.surface == NULL) {
-				pointer->ghost.surface = top->surface;
-				pointer->ghost.dx = top->dx;
-				pointer->ghost.dy = top->dy;
-				pointer->ghost.fx = top->fx;
-				pointer->ghost.fy = top->fy;
-				pointer->ghost.angle = top->angle;
-				pointer->ghost.transform = top->transform;
-			}
-			desktop_rect_t dmg_rect1, dmg_rect2, dmg_rect3, dmg_rect4;
-			comp_ghost_animate(pointer, &dmg_rect1, &dmg_rect2, &dmg_rect3, &dmg_rect4);
-#endif
 #if ANIMATE_WINDOW_TRANSFORMS == 1
 			sysarg_t x, y, width, height;
 			comp_window_animate(pointer, top, &x, &y, &width, &height);
 #endif
-			fibril_mutex_unlock(&pointer_list_mtx);
 			fibril_mutex_unlock(&window_list_mtx);
-#if ANIMATE_WINDOW_TRANSFORMS == 0
-			comp_damage(dmg_rect1.x, dmg_rect1.y, dmg_rect1.w, dmg_rect1.h);
-			comp_damage(dmg_rect2.x, dmg_rect2.y, dmg_rect2.w, dmg_rect2.h);
-			comp_damage(dmg_rect3.x, dmg_rect3.y, dmg_rect3.w, dmg_rect3.h);
-			comp_damage(dmg_rect4.x, dmg_rect4.y, dmg_rect4.w, dmg_rect4.h);
-#endif
 #if ANIMATE_WINDOW_TRANSFORMS == 1
 			comp_damage(x, y, width, height);
@@ -1468,5 +1165,4 @@
 		}
 	} else {
-		fibril_mutex_unlock(&pointer_list_mtx);
 		fibril_mutex_unlock(&window_list_mtx);
 	}
@@ -1478,44 +1174,4 @@
 {
 	pointer_t *pointer = input_pointer(input);
-
-	fibril_mutex_lock(&window_list_mtx);
-	fibril_mutex_lock(&pointer_list_mtx);
-	window_t *win = NULL;
-	sysarg_t point_x = 0;
-	sysarg_t point_y = 0;
-	sysarg_t width, height;
-	bool within_client = false;
-
-	/* Determine the window which the mouse click belongs to. */
-	list_foreach(window_list, link) {
-		win = list_get_instance(link, window_t, link);
-		if (win->surface) {
-			surface_get_resolution(win->surface, &width, &height);
-			within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
-			    win->transform, width, height, &point_x, &point_y);
-		}
-		if (within_client) {
-			break;
-		}
-	}
-
-	/* Check whether the window is top-level window. */
-	window_t *top = (window_t *) list_first(&window_list);
-	if (!win || !top) {
-		fibril_mutex_unlock(&pointer_list_mtx);
-		fibril_mutex_unlock(&window_list_mtx);
-		return EOK;
-	}
-
-	window_event_t *event_top = NULL;
-	window_event_t *event_unfocus = NULL;
-	window_t *win_unfocus = NULL;
-	sysarg_t dmg_x, dmg_y;
-	sysarg_t dmg_width = 0;
-	sysarg_t dmg_height = 0;
-	
-#if ANIMATE_WINDOW_TRANSFORMS == 0
-	desktop_rect_t dmg_rect1, dmg_rect2, dmg_rect3, dmg_rect4;
-#endif
 
 	if (bpress) {
@@ -1524,37 +1180,69 @@
 		pointer->pressed = true;
 
-		/* Bring the window to the foreground. */
-		if ((win != top) && within_client) {
-			win_unfocus = (window_t *) list_first(&window_list);
-			list_remove(&win->link);
-			list_prepend(&win->link, &window_list);
-			event_unfocus = (window_event_t *) malloc(sizeof(window_event_t));
-			if (event_unfocus) {
-				link_initialize(&event_unfocus->link);
-				event_unfocus->type = ET_WINDOW_UNFOCUS;
-			}
-			comp_coord_bounding_rect(0, 0, width, height, win->transform,
-			    &dmg_x, &dmg_y, &dmg_width, &dmg_height);
-		}
-
-		/* Notify top-level window about mouse press. */
+		/* Check whether mouse press belongs to the top-level window. */
+		fibril_mutex_lock(&window_list_mtx);
+		window_t *win = (window_t *) list_first(&window_list);
+		if (!win || !win->surface) {
+			fibril_mutex_unlock(&window_list_mtx);
+			return EOK;
+		}
+		sysarg_t x, y, width, height;
+		surface_get_resolution(win->surface, &width, &height);
+		bool within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
+		    win->transform, width, height, &x, &y);
+		fibril_mutex_unlock(&window_list_mtx);
+
+		/* Send mouse press to the top-level window. */
 		if (within_client) {
-			event_top = (window_event_t *) malloc(sizeof(window_event_t));
-			if (event_top) {
-				link_initialize(&event_top->link);
-				event_top->type = ET_POSITION_EVENT;
-				event_top->data.pos.pos_id = pointer->id;
-				event_top->data.pos.type = POS_PRESS;
-				event_top->data.pos.btn_num = bnum;
-				event_top->data.pos.hpos = point_x;
-				event_top->data.pos.vpos = point_y;
-			}
-			pointer->grab_flags = GF_EMPTY;
-		}
-
+			window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
+			if (event) {
+				link_initialize(&event->link);
+				event->type = ET_POSITION_EVENT;
+				event->data.pos.pos_id = pointer->id;
+				event->data.pos.type = POS_PRESS;
+				event->data.pos.btn_num = bnum;
+				event->data.pos.hpos = x;
+				event->data.pos.vpos = y;
+				comp_post_event(event);
+			} else {
+				return ENOMEM;
+			}
+		}
 	} else if (pointer->pressed && pointer->btn_num == (unsigned)bnum) {
 		pointer->pressed = false;
 
-#if ANIMATE_WINDOW_TRANSFORMS == 0
+		fibril_mutex_lock(&window_list_mtx);
+		window_t *win = NULL;
+		sysarg_t point_x = 0;
+		sysarg_t point_y = 0;
+		sysarg_t width, height;
+		bool within_client = false;
+
+		/* Determine the window which the mouse release belongs to. */
+		list_foreach(window_list, link) {
+			win = list_get_instance(link, window_t, link);
+			if (win->surface) {
+				surface_get_resolution(win->surface, &width, &height);
+				within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
+				    win->transform, width, height, &point_x, &point_y);
+			}
+			if (within_client) {
+				break;
+			}
+		}
+
+		/* Check whether the window is top-level window. */
+		window_t *top = (window_t *) list_first(&window_list);
+		if (!win || !top) {
+			pointer->grab_flags = GF_EMPTY;
+			fibril_mutex_unlock(&window_list_mtx);
+			return EOK;
+		}
+
+		window_event_t *event = NULL;
+		sysarg_t dmg_x, dmg_y;
+		sysarg_t dmg_width = 0;
+		sysarg_t dmg_height = 0;
+
 		sysarg_t pre_x = 0; 
 		sysarg_t pre_y = 0;
@@ -1562,9 +1250,6 @@
 		sysarg_t pre_height = 0;
 
+#if ANIMATE_WINDOW_TRANSFORMS == 0
 		if (pointer->grab_flags != GF_EMPTY) {
-			if (pointer->ghost.surface) {
-				comp_ghost_animate(pointer, &dmg_rect1, &dmg_rect2, &dmg_rect3, &dmg_rect4);
-				pointer->ghost.surface = NULL;
-			}
 			comp_window_animate(pointer, top, &pre_x, &pre_y, &pre_width, &pre_height);
 			dmg_x = pre_x;
@@ -1578,15 +1263,13 @@
 
 			surface_get_resolution(top->surface, &width, &height);
-#if ANIMATE_WINDOW_TRANSFORMS == 1
 			top->fx *= (1.0 / scale_back_x);
 			top->fy *= (1.0 / scale_back_y);
 			comp_recalc_transform(top);
-#endif
 
 			/* Commit proper resize action. */
-			event_top = (window_event_t *) malloc(sizeof(window_event_t));
-			if (event_top) {
-				link_initialize(&event_top->link);
-				event_top->type = ET_WINDOW_RESIZE;
+			event = (window_event_t *) malloc(sizeof(window_event_t));
+			if (event) {
+				link_initialize(&event->link);
+				event->type = ET_WINDOW_RESIZE;
 
 				int dx = (int) (((double) width) * (scale_back_x - 1.0));
@@ -1594,15 +1277,15 @@
 
 				if (pointer->grab_flags & GF_RESIZE_X) {
-					event_top->data.rsz.width =
+					event->data.rsz.width =
 						((((int) width) + dx) >= 0) ? (width + dx) : 0;
 				} else {
-					event_top->data.rsz.width = width;
+					event->data.rsz.width = width;
 				}
 
 				if (pointer->grab_flags & GF_RESIZE_Y) {
-					event_top->data.rsz.height =
+					event->data.rsz.height =
 						((((int) height) + dy) >= 0) ? (height + dy) : 0;
 				} else {
-					event_top->data.rsz.height = height;
+					event->data.rsz.height = height;
 				}
 			}
@@ -1613,15 +1296,23 @@
 			
 			/* Notify top-level window about mouse release. */
-			event_top = (window_event_t *) malloc(sizeof(window_event_t));
-			if (event_top) {
-				link_initialize(&event_top->link);
-				event_top->type = ET_POSITION_EVENT;
-				event_top->data.pos.pos_id = pointer->id;
-				event_top->data.pos.type = POS_RELEASE;
-				event_top->data.pos.btn_num = bnum;
-				event_top->data.pos.hpos = point_x;
-				event_top->data.pos.vpos = point_y;
+			event = (window_event_t *) malloc(sizeof(window_event_t));
+			if (event) {
+				link_initialize(&event->link);
+				event->type = ET_POSITION_EVENT;
+				event->data.pos.pos_id = pointer->id;
+				event->data.pos.type = POS_RELEASE;
+				event->data.pos.btn_num = bnum;
+				event->data.pos.hpos = point_x;
+				event->data.pos.vpos = point_y;
 			}
 			pointer->grab_flags = GF_EMPTY;
+			
+		} else if (within_client && (pointer->grab_flags == GF_EMPTY) && (bnum == 1)) {
+
+			/* Bring the window to the foreground. */
+			list_remove(&win->link);
+			list_prepend(&win->link, &window_list);
+			comp_coord_bounding_rect(0, 0, width, height, win->transform,
+			    &dmg_x, &dmg_y, &dmg_width, &dmg_height);
 			
 		} else {
@@ -1629,26 +1320,13 @@
 		}
 
-	}
-
-	fibril_mutex_unlock(&pointer_list_mtx);
-	fibril_mutex_unlock(&window_list_mtx);
-
-#if ANIMATE_WINDOW_TRANSFORMS == 0
-		comp_damage(dmg_rect1.x, dmg_rect1.y, dmg_rect1.w, dmg_rect1.h);
-		comp_damage(dmg_rect2.x, dmg_rect2.y, dmg_rect2.w, dmg_rect2.h);
-		comp_damage(dmg_rect3.x, dmg_rect3.y, dmg_rect3.w, dmg_rect3.h);
-		comp_damage(dmg_rect4.x, dmg_rect4.y, dmg_rect4.w, dmg_rect4.h);
-#endif
-
-	if (dmg_width > 0 && dmg_height > 0) {
-		comp_damage(dmg_x, dmg_y, dmg_width, dmg_height);
-	}
-
-	if (event_unfocus && win_unfocus) {
-		comp_post_event_win(event_unfocus, win_unfocus);
-	}
-
-	if (event_top) {
-		comp_post_event_top(event_top);
+		fibril_mutex_unlock(&window_list_mtx);
+
+		if (dmg_width > 0 && dmg_height > 0) {
+			comp_damage(dmg_x, dmg_y, dmg_width, dmg_height);
+		}
+
+		if (event) {
+			comp_post_event(event);
+		}
 	}
 
@@ -1774,5 +1452,5 @@
 
 			fibril_mutex_unlock(&window_list_mtx);
-			comp_post_event_top(event);
+			comp_post_event(event);
 		} else {
 			fibril_mutex_unlock(&window_list_mtx);
@@ -1816,5 +1494,5 @@
 		event->type = ET_WINDOW_CLOSE;
 
-		comp_post_event_top(event);
+		comp_post_event(event);
 	} else if (win_switch) {
 		fibril_mutex_lock(&window_list_mtx);
@@ -1824,16 +1502,4 @@
 			list_append(&win1->link, &window_list);
 			window_t *win2 = (window_t *) list_first(&window_list);
-
-			window_event_t *event1 = (window_event_t *) malloc(sizeof(window_event_t));
-			if (event1) {
-				link_initialize(&event1->link);
-				event1->type = ET_WINDOW_UNFOCUS;
-			}
-
-			window_event_t *event2 = (window_event_t *) malloc(sizeof(window_event_t));
-			if (event2) {
-				link_initialize(&event2->link);
-				event2->type = ET_WINDOW_FOCUS;
-			}
 
 			sysarg_t x1 = 0;
@@ -1864,13 +1530,4 @@
 
 			fibril_mutex_unlock(&window_list_mtx);
-
-			if (event1 && win1) {
-				comp_post_event_win(event1, win1);
-			}
-
-			if (event2 && win2) {
-				comp_post_event_win(event2, win2);
-			}
-
 			comp_damage(x, y, width, height);
 		} else {
@@ -1943,5 +1600,5 @@
 		fibril_mutex_lock(&window_list_mtx);
 
-		window_t *red_win = window_create(0, 0);
+		window_t *red_win = window_create();
 		red_win->surface = surface_create(250, 150, NULL, 0);
 		pixel_t red_pix = PIXEL(255, 240, 0, 0);
@@ -1953,5 +1610,5 @@
 		list_prepend(&red_win->link, &window_list);
 
-		window_t *blue_win = window_create(0, 0);
+		window_t *blue_win = window_create();
 		blue_win->surface = surface_create(200, 100, NULL, 0);
 		pixel_t blue_pix = PIXEL(255, 0, 0, 240);
@@ -1963,9 +1620,9 @@
 		list_prepend(&blue_win->link, &window_list);
 
-		window_t *helenos_win = window_create(0, 0);
+		window_t *helenos_win = window_create();
 		helenos_win->surface = decode_tga((void *) helenos_tga, helenos_tga_size, 0);
 		list_prepend(&helenos_win->link, &window_list);
 
-		window_t *nameic_win = window_create(0, 0);
+		window_t *nameic_win = window_create();
 		nameic_win->surface = decode_tga((void *) nameic_tga, nameic_tga_size, 0);
 		list_prepend(&nameic_win->link, &window_list);
@@ -1985,5 +1642,5 @@
 		event->data.kbd.c = c;
 
-		comp_post_event_top(event);
+		comp_post_event(event);
 	}
 
@@ -2036,5 +1693,5 @@
 static void input_disconnect(void)
 {
-	pointer_t *pointer = input->user;
+    	pointer_t *pointer = input->user;
 	input_close(input);
 	pointer_destroy(pointer);
@@ -2049,5 +1706,5 @@
 {
 	/* Coordinates of the central pixel. */
-	coord_origin = UINT32_MAX / 4;
+	coord_origin = UINT32_MAX / 2;
 	
 	/* Color of the viewport background. Must be opaque. */
Index: uspace/srv/hid/compositor/compositor.h
===================================================================
--- uspace/srv/hid/compositor/compositor.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/compositor/compositor.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -43,11 +43,4 @@
 typedef desktop_point_t desktop_vector_t;
 
-typedef struct {
-	desktop_coord_t x;
-	desktop_coord_t y;
-	desktop_coord_t w;
-	desktop_coord_t h;
-} desktop_rect_t;
-
 /* TODO remove? */
 typedef struct {
Index: uspace/srv/hid/input/Makefile
===================================================================
--- uspace/srv/hid/input/Makefile	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/Makefile	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,4 @@
 	layout/us_qwerty.c \
 	layout/us_dvorak.c \
-	layout/ar.c \
 	port/adb.c \
 	port/adb_mouse.c \
Index: uspace/srv/hid/input/ctl/kbdev.c
===================================================================
--- uspace/srv/hid/input/ctl/kbdev.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/ctl/kbdev.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <fcntl.h>
Index: uspace/srv/hid/input/input.c
===================================================================
--- uspace/srv/hid/input/input.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/input.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 
 #include <adt/list.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <ipc/services.h>
@@ -62,11 +62,10 @@
 #include "input.h"
 
-#define NUM_LAYOUTS  4
+#define NUM_LAYOUTS  3
 
 static layout_ops_t *layout[NUM_LAYOUTS] = {
 	&us_qwerty_ops,
 	&us_dvorak_ops,
-	&cz_ops,
-	&ar_ops
+	&cz_ops
 };
 
@@ -161,11 +160,4 @@
 		layout_destroy(kdev->active_layout);
 		kdev->active_layout = layout_create(layout[2]);
-		return;
-	}
-	
-	if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) &&
-	    key == KC_F4) {
-		layout_destroy(kdev->active_layout);
-		kdev->active_layout = layout_create(layout[3]);
 		return;
 	}
@@ -431,4 +423,10 @@
 	kbd_add_dev(&chardev_port, &stty_ctl);
 #endif
+#if defined(UARCH_arm32) && defined(MACHINE_testarm) && defined(CONFIG_FB)
+	kbd_add_dev(&gxemul_port, &gxe_fb_ctl);
+#endif
+#if defined(UARCH_arm32) && defined(MACHINE_testarm) && !defined(CONFIG_FB)
+	kbd_add_dev(&gxemul_port, &stty_ctl);
+#endif
 #if defined(UARCH_arm32) && defined(MACHINE_integratorcp)
 	kbd_add_dev(&pl050_port, &pc_ctl);
Index: uspace/srv/hid/input/input.h
===================================================================
--- uspace/srv/hid/input/input.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/input.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 #define INPUT_H_
 
-#include <stdbool.h>
+#include <bool.h>
 #include <async.h>
 
Index: uspace/srv/hid/input/layout.h
===================================================================
--- uspace/srv/hid/input/layout.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/layout.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -60,5 +60,4 @@
 extern layout_ops_t us_dvorak_ops;
 extern layout_ops_t cz_ops;
-extern layout_ops_t ar_ops;
 
 extern layout_t *layout_create(layout_ops_t *);
Index: pace/srv/hid/input/layout/ar.c
===================================================================
--- uspace/srv/hid/input/layout/ar.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ 	(revision )
@@ -1,241 +1,0 @@
-/*
- * Copyright (c) 2011 Jiri Svoboda
- * Copyright (c) 2012 Mohammed Q. Hussain (For Arabic Keyboard)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 input
- * @brief Arabic keyboard layout (Based on US QWERTY layout's code).
- * @{
- */
-
-#include <errno.h>
-#include <io/console.h>
-#include <io/keycode.h>
-#include "../layout.h"
-#include "../kbd.h"
-
-static int ar_create(layout_t *);
-static void ar_destroy(layout_t *);
-static wchar_t ar_parse_ev(layout_t *, kbd_event_t *ev);
-
-layout_ops_t ar_ops = {
-	.create = ar_create,
-	.destroy = ar_destroy,
-	.parse_ev = ar_parse_ev
-};
-
-static wchar_t map_not_shifted[] = {
-	[KC_BACKTICK] = L'ذ',
-
-	[KC_1] = '1',
-	[KC_2] = '2',
-	[KC_3] = '3',
-	[KC_4] = '4',
-	[KC_5] = '5',
-	[KC_6] = '6',
-	[KC_7] = '7',
-	[KC_8] = '8',
-	[KC_9] = '9',
-	[KC_0] = '0',
-
-	[KC_MINUS] = '-',
-	[KC_EQUALS] = '=',
-
-	[KC_LBRACKET] = L'ج',
-	[KC_RBRACKET] = L'د',
-
-	[KC_SEMICOLON] = L'ك',
-	[KC_QUOTE] = L'ط',
-	[KC_BACKSLASH] = '\\',
-
-	[KC_COMMA] = L'و',
-	[KC_PERIOD] = L'ز',
-	[KC_SLASH] = L'ظ',
-	
-	[KC_Q] = L'ض',
-	[KC_W] = L'ص',
-	[KC_E] = L'ث',
-	[KC_R] = L'ق',
-	[KC_T] = L'ف',
-	[KC_Y] = L'غ',
-	[KC_U] = L'ع',
-	[KC_I] = L'ه',
-	[KC_O] = L'خ',
-	[KC_P] = L'ح',
-
-	[KC_A] = L'ش',
-	[KC_S] = L'س',
-	[KC_D] = L'ي',
-	[KC_F] = L'ب',
-	[KC_G] = L'ل',
-	[KC_H] = L'ا',
-	[KC_J] = L'ت',
-	[KC_K] = L'ن',
-	[KC_L] = L'م',
-
-	[KC_Z] = L'ئ',
-	[KC_X] = L'ء',
-	[KC_C] = L'ؤ',
-	[KC_V] = L'ر',
-	[KC_B] = L'ﻻ',
-	[KC_N] = L'ى',
-	[KC_M] = L'ة',
-};
-
-static wchar_t map_shifted[] = {
-	[KC_BACKTICK] = L'ّ',
-
-	[KC_1] = '!',
-	[KC_2] = '@',
-	[KC_3] = '#',
-	[KC_4] = '$',
-	[KC_5] = '%',
-	[KC_6] = '^',
-	[KC_7] = '&',
-	[KC_8] = '*',
-	[KC_9] = ')',
-	[KC_0] = '(',
-
-	[KC_MINUS] = '_',
-	[KC_EQUALS] = '+',
-
-	[KC_LBRACKET] = '<',
-	[KC_RBRACKET] = '>',
-
-	[KC_SEMICOLON] = ':',
-	[KC_QUOTE] = '"',
-	[KC_BACKSLASH] = '|',
-
-	[KC_COMMA] = ',',
-	[KC_PERIOD] = '.',
-	[KC_SLASH] = L'؟',
-	
-	[KC_Q] = L'َ',
-	[KC_W] = L'ً',
-	[KC_E] = L'ُ',
-	[KC_R] = L'ٌ',
-	[KC_T] = L'ﻹ',
-	[KC_Y] = L'إ',
-	[KC_U] = L'`',
-	[KC_I] = L'÷',
-	[KC_O] = L'×',
-	[KC_P] = L'؛',
-
-	[KC_A] = L'ِ',
-	[KC_S] = L'ٍ',
-	[KC_D] = L']',
-	[KC_F] = L'[',
-	[KC_G] = L'ﻷ',
-	[KC_H] = L'أ',
-	[KC_J] = L'ـ',
-	[KC_K] = L'،',
-	[KC_L] = L'/',
-
-	[KC_Z] = L'~',
-	[KC_X] = L'ْ',
-	[KC_C] = L'}',
-	[KC_V] = L'{',
-	[KC_B] = L'ﻵ',
-	[KC_N] = L'آ',
-	[KC_M] = L'\'',
-};
-
-static wchar_t map_neutral[] = {
-	[KC_BACKSPACE] = '\b',
-	[KC_TAB] = '\t',
-	[KC_ENTER] = '\n',
-	[KC_SPACE] = ' ',
-
-	[KC_NSLASH] = '/',
-	[KC_NTIMES] = '*',
-	[KC_NMINUS] = '-',
-	[KC_NPLUS] = '+',
-	[KC_NENTER] = '\n'
-};
-
-static wchar_t map_numeric[] = {
-	[KC_N7] = '7',
-	[KC_N8] = '8',
-	[KC_N9] = '9',
-	[KC_N4] = '4',
-	[KC_N5] = '5',
-	[KC_N6] = '6',
-	[KC_N1] = '1',
-	[KC_N2] = '2',
-	[KC_N3] = '3',
-
-	[KC_N0] = '0',
-	[KC_NPERIOD] = '.'
-};
-
-static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)
-{
-	if (key >= map_length)
-		return 0;
-	return map[key];
-}
-
-static int ar_create(layout_t *state)
-{
-	return EOK;
-}
-
-static void ar_destroy(layout_t *state)
-{
-}
-
-static wchar_t ar_parse_ev(layout_t *state, kbd_event_t *ev)
-{
-	wchar_t c;
-
-	/* Produce no characters when Ctrl or Alt is pressed. */
-	if ((ev->mods & (KM_CTRL | KM_ALT)) != 0)
-		return 0;
-
-	c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t));
-	if (c != 0)
-		return c;
-	
-	if ((ev->mods & KM_SHIFT) != 0)
-		c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t));
-	else
-		c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t));
-
-	if (c != 0)
-		return c;
-
-	if ((ev->mods & KM_NUM_LOCK) != 0)
-		c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t));
-	else
-		c = 0;
-
-	return c;
-}
-
-/**
- * @}
- */ 
Index: uspace/srv/hid/input/layout/cz.c
===================================================================
--- uspace/srv/hid/input/layout/cz.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/layout/cz.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
 #include <io/console.h>
 #include <io/keycode.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <stdlib.h>
 #include "../input.h"
Index: uspace/srv/hid/input/port/niagara.c
===================================================================
--- uspace/srv/hid/input/port/niagara.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/port/niagara.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,5 +42,5 @@
 #include <stdio.h>
 #include <thread.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include "../kbd_port.h"
Index: uspace/srv/hid/input/port/pl050.c
===================================================================
--- uspace/srv/hid/input/port/pl050.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/port/pl050.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,7 +37,9 @@
 
 #include <ddi.h>
+#include <libarch/ddi.h>
 #include <async.h>
 #include <unistd.h>
 #include <sysinfo.h>
+#include <ddi.h>
 #include <stdio.h>
 #include <errno.h>
Index: uspace/srv/hid/input/port/ski.c
===================================================================
--- uspace/srv/hid/input/port/ski.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/port/ski.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <sys/types.h>
 #include <thread.h>
-#include <stdbool.h>
+#include <bool.h>
 #include "../kbd_port.h"
 #include "../kbd.h"
Index: uspace/srv/hid/input/proto/adb.c
===================================================================
--- uspace/srv/hid/input/proto/adb.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/input/proto/adb.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include "../mouse.h"
 #include "../mouse_port.h"
Index: uspace/srv/hid/output/output.h
===================================================================
--- uspace/srv/hid/output/output.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/output/output.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -31,5 +31,5 @@
 
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <loc.h>
 #include <io/console.h>
Index: uspace/srv/hid/output/port/ega.c
===================================================================
--- uspace/srv/hid/output/port/ega.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/output/port/ega.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,4 +36,5 @@
 #include <as.h>
 #include <ddi.h>
+#include <libarch/ddi.h>
 #include <io/chargrid.h>
 #include "../output.h"
@@ -210,5 +211,6 @@
 		return rc;
 	
-	rc = pio_enable((void*)EGA_IO_BASE, EGA_IO_SIZE, NULL);
+	rc = iospace_enable(task_get_id(), (void *) EGA_IO_BASE,
+	    EGA_IO_SIZE);
 	if (rc != EOK)
 		return rc;
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,4 +38,5 @@
 
 #include <ddi.h>
+#include <libarch/ddi.h>
 #include <loc.h>
 #include <io/console.h>
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <stdlib.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <ddi.h>
 #include <libarch/ddi.h>
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,4 +38,5 @@
 
 #include <ddi.h>
+#include <libarch/ddi.h>
 #include <loc.h>
 #include <ipc/char.h>
Index: uspace/srv/hw/irc/apic/apic.c
===================================================================
--- uspace/srv/hw/irc/apic/apic.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hw/irc/apic/apic.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,5 +42,5 @@
 #include <as.h>
 #include <ddi.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <async.h>
Index: uspace/srv/hw/irc/i8259/i8259.c
===================================================================
--- uspace/srv/hw/irc/i8259/i8259.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hw/irc/i8259/i8259.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,6 +42,7 @@
 #include <as.h>
 #include <ddi.h>
+#include <libarch/ddi.h>
 #include <align.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <async.h>
Index: uspace/srv/hw/irc/obio/obio.c
===================================================================
--- uspace/srv/hw/irc/obio/obio.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/hw/irc/obio/obio.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -49,5 +49,5 @@
 #include <ddi.h>
 #include <align.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <async.h>
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/loader/main.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -47,5 +47,5 @@
 #include <stdlib.h>
 #include <unistd.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fcntl.h>
 #include <sys/types.h>
Index: uspace/srv/locsrv/locsrv.c
===================================================================
--- uspace/srv/locsrv/locsrv.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/locsrv/locsrv.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,5 +42,5 @@
 #include <stdio.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <macros.h>
Index: uspace/srv/logger/initlvl.c
===================================================================
--- uspace/srv/logger/initlvl.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/logger/initlvl.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,4 @@
 #include <sysinfo.h>
 #include <str.h>
-#include <stdlib.h>
 #include "logger.h"
 
@@ -92,5 +91,4 @@
 	char level_str[200];
 	str_cpy(level_str, 200, (const char *) argument);
-	free(argument);
 
 	parse_level_settings(level_str);
Index: uspace/srv/logger/logger.h
===================================================================
--- uspace/srv/logger/logger.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/logger/logger.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <io/log.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <stdio.h>
Index: uspace/srv/net/ethip/ethip_nic.c
===================================================================
--- uspace/srv/net/ethip/ethip_nic.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/net/ethip/ethip_nic.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -37,5 +37,5 @@
 #include <adt/list.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <fibril_synch.h>
Index: uspace/srv/net/inetsrv/inet_link.c
===================================================================
--- uspace/srv/net/inetsrv/inet_link.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/net/inetsrv/inet_link.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -35,5 +35,5 @@
  */
 
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <fibril_synch.h>
Index: uspace/srv/net/inetsrv/inetsrv.h
===================================================================
--- uspace/srv/net/inetsrv/inetsrv.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/net/inetsrv/inetsrv.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -39,5 +39,5 @@
 
 #include <adt/list.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <inet/iplink.h>
 #include <ipc/loc.h>
Index: uspace/srv/net/tcp/conn.c
===================================================================
--- uspace/srv/net/tcp/conn.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/net/tcp/conn.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <adt/list.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <io/log.h>
Index: uspace/srv/net/tcp/conn.h
===================================================================
--- uspace/srv/net/tcp/conn.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/net/tcp/conn.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 #define CONN_H
 
-#include <stdbool.h>
+#include <bool.h>
 #include "tcp_type.h"
 
Index: uspace/srv/net/tcp/seq_no.c
===================================================================
--- uspace/srv/net/tcp/seq_no.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/net/tcp/seq_no.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <sys/types.h>
 #include "seq_no.h"
Index: uspace/srv/net/tcp/tcp_type.h
===================================================================
--- uspace/srv/net/tcp/tcp_type.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/net/tcp/tcp_type.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -38,5 +38,5 @@
 #include <adt/list.h>
 #include <async.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril.h>
 #include <fibril_synch.h>
Index: uspace/srv/net/udp/assoc.c
===================================================================
--- uspace/srv/net/udp/assoc.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/net/udp/assoc.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 
 #include <adt/list.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <io/log.h>
Index: uspace/srv/ns/clonable.c
===================================================================
--- uspace/srv/ns/clonable.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/ns/clonable.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
 #include <ipc/services.h>
 #include <adt/list.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <assert.h>
Index: uspace/srv/ns/clonable.h
===================================================================
--- uspace/srv/ns/clonable.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/ns/clonable.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -36,5 +36,5 @@
 #include <ipc/common.h>
 #include <sys/types.h>
-#include <stdbool.h>
+#include <bool.h>
 
 extern int clonable_init(void);
Index: uspace/srv/ns/task.c
===================================================================
--- uspace/srv/ns/task.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/ns/task.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -34,5 +34,5 @@
 #include <ipc/ipc.h>
 #include <adt/hash_table.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <errno.h>
 #include <assert.h>
Index: uspace/srv/vfs/vfs.c
===================================================================
--- uspace/srv/vfs/vfs.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/vfs/vfs.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #include <errno.h>
 #include <stdio.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <str.h>
 #include <as.h>
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/vfs/vfs.h	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <sys/types.h>
 #include <loc.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <ipc/vfs.h>
 #include <task.h>
Index: uspace/srv/vfs/vfs_file.c
===================================================================
--- uspace/srv/vfs/vfs_file.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/vfs/vfs_file.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -40,5 +40,5 @@
 #include <str.h>
 #include <assert.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril.h>
 #include <fibril_synch.h>
Index: uspace/srv/vfs/vfs_lookup.c
===================================================================
--- uspace/srv/vfs/vfs_lookup.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/vfs/vfs_lookup.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -42,5 +42,5 @@
 #include <str.h>
 #include <stdarg.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <adt/list.h>
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/vfs/vfs_ops.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -44,5 +44,5 @@
 #include <stdlib.h>
 #include <str.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <fibril_synch.h>
 #include <adt/list.h>
Index: uspace/srv/vfs/vfs_register.c
===================================================================
--- uspace/srv/vfs/vfs_register.c	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ uspace/srv/vfs/vfs_register.c	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -45,5 +45,5 @@
 #include <str.h>
 #include <ctype.h>
-#include <stdbool.h>
+#include <bool.h>
 #include <adt/list.h>
 #include <as.h>
Index: version
===================================================================
--- version	(revision 850235d404a93a3e011befe27ef139ef8e288759)
+++ version	(revision ea906c296a71e3f2edea0bfac602ee88cf04f607)
@@ -47,3 +47,2 @@
 NAME = Fajtl
 COPYRIGHT = Copyright (c) 2001-2012 HelenOS project
-
