Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ kernel/Makefile	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -223,5 +223,13 @@
 		test/debug/mips1.c \
 		test/fault/fault1.c \
-		test/fpu/fpu1.c
+		test/fpu/fpu1.c \
+		test/fpu/sse1.c \
+		test/fpu/mips2.c \
+		test/mm/falloc1.c \
+		test/mm/falloc2.c \
+		test/mm/mapping1.c \
+		test/mm/slab1.c \
+		test/mm/slab2.c \
+		test/mm/purge1.c
 endif
 
Index: rnel/test/fpu/mips1/test.c
===================================================================
--- kernel/test/fpu/mips1/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ 	(revision )
@@ -1,136 +1,0 @@
-/*
- * Copyright (C) 2005 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <print.h>
-#include <debug.h>
-#include <panic.h>
-
-#include <test.h>
-#include <atomic.h>
-#include <proc/thread.h>
-#include <time/delay.h>
-
-#include <arch.h>
-
-#define THREADS		50
-#define DELAY   	10000L
-#define ATTEMPTS        5
-
-static atomic_t threads_ok;
-static waitq_t can_start;
-
-static void testit1(void *data)
-{
-	int i;
-	int arg __attribute__((aligned(16))) = (int)((unative_t) data);
-	int after_arg __attribute__((aligned(16)));
-
-	thread_detach(THREAD);
-	
-	waitq_sleep(&can_start);
-
-	for (i = 0; i<ATTEMPTS; i++) {
-		__asm__ volatile (
-			"mtc1 %0,$1"
-			:"=r"(arg)
-			);
-
-		delay(DELAY);
-		__asm__ volatile (
-			"mfc1 %0, $1"
-			:"=r"(after_arg)
-			);
-		
-		if(arg != after_arg)
-			panic("General reg tid%d: arg(%d) != %d\n", 
-			      THREAD->tid, arg, after_arg);
-	}
-
-	atomic_inc(&threads_ok);
-}
-
-static void testit2(void *data)
-{
-	int i;
-	int arg __attribute__((aligned(16))) = (int)((unative_t) data);
-	int after_arg __attribute__((aligned(16)));
-
-	thread_detach(THREAD);
-
-	waitq_sleep(&can_start);
-
-	for (i = 0; i<ATTEMPTS; i++) {
-		__asm__ volatile (
-			"mtc1 %0,$1"
-			:"=r"(arg)
-			);
-
-		scheduler();
-		__asm__ volatile (
-			"mfc1 %0,$1"
-			:"=r"(after_arg)
-			);
-		
-		if(arg != after_arg)
-			panic("General reg tid%d: arg(%d) != %d\n", 
-			      THREAD->tid, arg, after_arg);
-	}
-
-	atomic_inc(&threads_ok);
-}
-
-
-void test(void)
-{
-	thread_t *t;
-	int i;
-
-	waitq_initialize(&can_start);
-
-	printf("MIPS test #1\n");
-	printf("Creating %d threads... ", THREADS);
-
-	for (i=0; i<THREADS/2; i++) {  
-		if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1")))
-			panic("could not create thread\n");
-		thread_ready(t);
-		if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2")))
-			panic("could not create thread\n");
-		thread_ready(t);
-	}
-
-	printf("ok\n");
-	
-	thread_sleep(1);
-	waitq_wakeup(&can_start, WAKEUP_ALL);
-
-	while (atomic_get(&threads_ok) != THREADS)
-		;
-		
-	printf("Test passed.\n");
-}
Index: kernel/test/fpu/mips2.c
===================================================================
--- kernel/test/fpu/mips2.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/fpu/mips2.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2005 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <print.h>
+#include <debug.h>
+#include <panic.h>
+
+#include <test.h>
+#include <atomic.h>
+#include <proc/thread.h>
+#include <time/delay.h>
+
+#include <arch.h>
+
+#ifdef mips32
+
+#define THREADS		50
+#define DELAY   	10000L
+#define ATTEMPTS        5
+
+static atomic_t threads_ok;
+static waitq_t can_start;
+
+static void testit1(void *data)
+{
+	int i;
+	int arg __attribute__((aligned(16))) = (int)((unative_t) data);
+	int after_arg __attribute__((aligned(16)));
+
+	thread_detach(THREAD);
+	
+	waitq_sleep(&can_start);
+
+	for (i = 0; i<ATTEMPTS; i++) {
+		__asm__ volatile (
+			"mtc1 %0,$1"
+			:"=r"(arg)
+			);
+
+		delay(DELAY);
+		__asm__ volatile (
+			"mfc1 %0, $1"
+			:"=r"(after_arg)
+			);
+		
+		if(arg != after_arg)
+			panic("General reg tid%d: arg(%d) != %d\n", 
+			      THREAD->tid, arg, after_arg);
+	}
+
+	atomic_inc(&threads_ok);
+}
+
+static void testit2(void *data)
+{
+	int i;
+	int arg __attribute__((aligned(16))) = (int)((unative_t) data);
+	int after_arg __attribute__((aligned(16)));
+
+	thread_detach(THREAD);
+
+	waitq_sleep(&can_start);
+
+	for (i = 0; i<ATTEMPTS; i++) {
+		__asm__ volatile (
+			"mtc1 %0,$1"
+			:"=r"(arg)
+			);
+
+		scheduler();
+		__asm__ volatile (
+			"mfc1 %0,$1"
+			:"=r"(after_arg)
+			);
+		
+		if(arg != after_arg)
+			panic("General reg tid%d: arg(%d) != %d\n", 
+			      THREAD->tid, arg, after_arg);
+	}
+
+	atomic_inc(&threads_ok);
+}
+
+
+void test_mips2(void)
+{
+	thread_t *t;
+	int i;
+
+	waitq_initialize(&can_start);
+
+	printf("MIPS test #1\n");
+	printf("Creating %d threads... ", THREADS);
+
+	for (i=0; i<THREADS/2; i++) {  
+		if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1")))
+			panic("could not create thread\n");
+		thread_ready(t);
+		if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2")))
+			panic("could not create thread\n");
+		thread_ready(t);
+	}
+
+	printf("ok\n");
+	
+	thread_sleep(1);
+	waitq_wakeup(&can_start, WAKEUP_ALL);
+
+	while (atomic_get(&threads_ok) != THREADS)
+		;
+		
+	printf("Test passed.\n");
+}
+
+#else
+
+void test_mips2(void)
+{
+	printf("This test is availaible only on MIPS32 platform.\n");
+}
+
+#endif
Index: kernel/test/fpu/sse1.c
===================================================================
--- kernel/test/fpu/sse1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/fpu/sse1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2005 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <print.h>
+#include <debug.h>
+#include <panic.h>
+
+#include <test.h>
+#include <atomic.h>
+#include <proc/thread.h>
+#include <time/delay.h>
+
+#include <arch.h>
+
+#ifdef CONFIG_BENCH
+#include <arch/cycle.h>
+#endif
+
+#if (defined(ia32) || defined(amd64) || defined(ia32xen))
+
+#define THREADS		50
+#define DELAY   	10000L
+#define ATTEMPTS        5
+
+static atomic_t threads_ok;
+static waitq_t can_start;
+
+static void testit1(void *data)
+{
+	int i;
+	int arg __attribute__((aligned(16))) = (int)((unative_t) data);
+	int after_arg __attribute__((aligned(16)));
+
+	thread_detach(THREAD);
+	
+	waitq_sleep(&can_start);
+
+	for (i = 0; i<ATTEMPTS; i++) {
+		__asm__ volatile (
+			"movlpd	%0, %%xmm2"
+			:"=m"(arg)
+			);
+
+		delay(DELAY);
+		__asm__ volatile (
+			"movlpd %%xmm2, %0"
+			:"=m"(after_arg)
+			);
+		
+		if(arg != after_arg)
+			panic("tid%d: arg(%d) != %d\n", 
+			      THREAD->tid, arg, after_arg);
+	}
+
+	atomic_inc(&threads_ok);
+}
+
+static void testit2(void *data)
+{
+	int i;
+	int arg __attribute__((aligned(16))) = (int)((unative_t) data);
+	int after_arg __attribute__((aligned(16)));
+
+	thread_detach(THREAD);
+	
+	waitq_sleep(&can_start);
+
+	for (i = 0; i<ATTEMPTS; i++) {
+		__asm__ volatile (
+			"movlpd	%0, %%xmm2"
+			:"=m"(arg)
+			);
+
+		scheduler();
+		__asm__ volatile (
+			"movlpd %%xmm2, %0"
+			:"=m"(after_arg)
+			);
+		
+		if(arg != after_arg)
+			panic("tid%d: arg(%d) != %d\n", 
+			      THREAD->tid, arg, after_arg);
+	}
+
+	atomic_inc(&threads_ok);
+}
+
+
+void test_sse1(void)
+{
+#ifdef CONFIG_BENCH
+	uint64_t t0 = get_cycle();
+#endif
+	thread_t *t;
+	int i;
+
+	waitq_initialize(&can_start);
+
+	printf("SSE test #1\n");
+	printf("Creating %d threads... ", THREADS);
+
+	for (i=0; i<THREADS/2; i++) {  
+		if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1")))
+			panic("could not create thread\n");
+		thread_ready(t);
+		if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2")))
+			panic("could not create thread\n");
+		thread_ready(t);
+	}
+
+	printf("ok\n");
+	
+	thread_sleep(1);
+	waitq_wakeup(&can_start, WAKEUP_ALL);
+
+	while (atomic_get(&threads_ok) != THREADS)
+		;
+		
+	printf("Test passed.\n");
+#ifdef CONFIG_BENCH
+	uint64_t dt = get_cycle() - t0;
+	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
+#endif
+}
+
+#else
+
+void test_sse1(void)
+{
+	printf("This test is available only on SSE enabled platforms.");
+}
+
+#endif
Index: rnel/test/fpu/sse1/test.c
===================================================================
--- kernel/test/fpu/sse1/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ 	(revision )
@@ -1,136 +1,0 @@
-/*
- * Copyright (C) 2005 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <print.h>
-#include <debug.h>
-#include <panic.h>
-
-#include <test.h>
-#include <atomic.h>
-#include <proc/thread.h>
-#include <time/delay.h>
-
-#include <arch.h>
-
-#define THREADS		50
-#define DELAY   	10000L
-#define ATTEMPTS        5
-
-static atomic_t threads_ok;
-static waitq_t can_start;
-
-static void testit1(void *data)
-{
-	int i;
-	int arg __attribute__((aligned(16))) = (int)((unative_t) data);
-	int after_arg __attribute__((aligned(16)));
-
-	thread_detach(THREAD);
-	
-	waitq_sleep(&can_start);
-
-	for (i = 0; i<ATTEMPTS; i++) {
-		__asm__ volatile (
-			"movlpd	%0, %%xmm2"
-			:"=m"(arg)
-			);
-
-		delay(DELAY);
-		__asm__ volatile (
-			"movlpd %%xmm2, %0"
-			:"=m"(after_arg)
-			);
-		
-		if(arg != after_arg)
-			panic("tid%d: arg(%d) != %d\n", 
-			      THREAD->tid, arg, after_arg);
-	}
-
-	atomic_inc(&threads_ok);
-}
-
-static void testit2(void *data)
-{
-	int i;
-	int arg __attribute__((aligned(16))) = (int)((unative_t) data);
-	int after_arg __attribute__((aligned(16)));
-
-	thread_detach(THREAD);
-	
-	waitq_sleep(&can_start);
-
-	for (i = 0; i<ATTEMPTS; i++) {
-		__asm__ volatile (
-			"movlpd	%0, %%xmm2"
-			:"=m"(arg)
-			);
-
-		scheduler();
-		__asm__ volatile (
-			"movlpd %%xmm2, %0"
-			:"=m"(after_arg)
-			);
-		
-		if(arg != after_arg)
-			panic("tid%d: arg(%d) != %d\n", 
-			      THREAD->tid, arg, after_arg);
-	}
-
-	atomic_inc(&threads_ok);
-}
-
-
-void test(void)
-{
-	thread_t *t;
-	int i;
-
-	waitq_initialize(&can_start);
-
-	printf("SSE test #1\n");
-	printf("Creating %d threads... ", THREADS);
-
-	for (i=0; i<THREADS/2; i++) {  
-		if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1")))
-			panic("could not create thread\n");
-		thread_ready(t);
-		if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2")))
-			panic("could not create thread\n");
-		thread_ready(t);
-	}
-
-	printf("ok\n");
-	
-	thread_sleep(1);
-	waitq_wakeup(&can_start, WAKEUP_ALL);
-
-	while (atomic_get(&threads_ok) != THREADS)
-		;
-		
-	printf("Test passed.\n");
-}
Index: kernel/test/mm/falloc1.c
===================================================================
--- kernel/test/mm/falloc1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/mm/falloc1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2006 Sergey Bondari
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <print.h>
+#include <test.h>
+#include <mm/page.h>
+#include <mm/frame.h>
+#include <mm/slab.h>
+#include <arch/mm/page.h>
+#include <arch/types.h>
+#include <debug.h>
+#include <align.h>
+
+#ifdef CONFIG_BENCH
+#include <arch/cycle.h>
+#endif
+
+#define MAX_FRAMES 1024
+#define MAX_ORDER 8
+#define TEST_RUNS 2
+
+void test_falloc1(void) {
+#ifdef CONFIG_BENCH
+	uint64_t t0 = get_cycle();
+#endif
+	uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES*sizeof(uintptr_t), 0);
+	int results[MAX_ORDER+1];
+	
+	int i, order, run;
+	int allocated;
+
+	ASSERT(TEST_RUNS > 1);
+	ASSERT(frames != NULL)
+
+	for (run = 0; run < TEST_RUNS; run++) {
+		for (order = 0; order <= MAX_ORDER; order++) {
+			printf("Allocating %d frames blocks ... ", 1 << order);
+			allocated = 0;
+			for (i = 0; i < MAX_FRAMES >> order; i++) {
+				frames[allocated] = (uintptr_t) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
+				
+				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
+					panic("Test failed. Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
+				}
+				
+				if (frames[allocated]) {
+					allocated++;
+				} else {
+					printf("done. ");
+					break;
+				}
+			}
+		
+			printf("%d blocks allocated.\n", allocated);
+		
+			if (run) {
+				if (results[order] != allocated) {
+					panic("Test failed. Frame leak possible.\n");
+				}
+			} else
+				results[order] = allocated;
+			
+			printf("Deallocating ... ");
+			for (i = 0; i < allocated; i++) {
+				frame_free(KA2PA(frames[i]));
+			}
+			printf("done.\n");
+		}
+	}
+
+	free(frames);
+	
+	printf("Test passed.\n");
+#ifdef CONFIG_BENCH
+	uint64_t dt = get_cycle() - t0;
+	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
+#endif
+}
+
Index: rnel/test/mm/falloc1/test.c
===================================================================
--- kernel/test/mm/falloc1/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (C) 2006 Sergey Bondari
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <print.h>
-#include <test.h>
-#include <mm/page.h>
-#include <mm/frame.h>
-#include <mm/slab.h>
-#include <arch/mm/page.h>
-#include <arch/types.h>
-#include <debug.h>
-#include <align.h>
-
-#define MAX_FRAMES 1024
-#define MAX_ORDER 8
-#define TEST_RUNS 2
-
-void test(void) {
-	uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES*sizeof(uintptr_t), 0);
-	int results[MAX_ORDER+1];
-	
-	int i, order, run;
-	int allocated;
-
-	ASSERT(TEST_RUNS > 1);
-	ASSERT(frames != NULL)
-
-	for (run = 0; run < TEST_RUNS; run++) {
-		for (order = 0; order <= MAX_ORDER; order++) {
-			printf("Allocating %d frames blocks ... ", 1 << order);
-			allocated = 0;
-			for (i = 0; i < MAX_FRAMES >> order; i++) {
-				frames[allocated] = (uintptr_t) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
-				
-				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
-					panic("Test failed. Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
-				}
-				
-				if (frames[allocated]) {
-					allocated++;
-				} else {
-					printf("done. ");
-					break;
-				}
-			}
-		
-			printf("%d blocks allocated.\n", allocated);
-		
-			if (run) {
-				if (results[order] != allocated) {
-					panic("Test failed. Frame leak possible.\n");
-				}
-			} else
-				results[order] = allocated;
-			
-			printf("Deallocating ... ");
-			for (i = 0; i < allocated; i++) {
-				frame_free(KA2PA(frames[i]));
-			}
-			printf("done.\n");
-		}
-	}
-
-	free(frames);
-	
-	printf("Test passed.\n");
-}
-
Index: kernel/test/mm/falloc2.c
===================================================================
--- kernel/test/mm/falloc2.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/mm/falloc2.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2006 Sergey Bondari
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <print.h>
+#include <test.h>
+#include <mm/page.h>
+#include <mm/frame.h>
+#include <mm/slab.h>
+#include <arch/mm/page.h>
+#include <arch/types.h>
+#include <atomic.h>
+#include <debug.h>
+#include <proc/thread.h>
+#include <memstr.h>
+#include <arch.h>
+
+#ifdef CONFIG_BENCH
+#include <arch/cycle.h>
+#endif
+
+#define MAX_FRAMES 256
+#define MAX_ORDER 8
+
+#define THREAD_RUNS 1
+#define THREADS 8
+
+static void falloc(void * arg);
+static void failed(void);
+
+static atomic_t thread_count;
+
+void falloc(void * arg)
+{
+	int order, run, allocated, i;
+	uint8_t val = THREAD->tid % THREADS;
+	index_t k;
+	
+	uintptr_t * frames =  (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC);
+	ASSERT(frames != NULL);
+	
+	thread_detach(THREAD);
+
+	for (run = 0; run < THREAD_RUNS; run++) {
+		for (order = 0; order <= MAX_ORDER; order++) {
+			printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
+			allocated = 0;
+			for (i = 0; i < (MAX_FRAMES >> order); i++) {
+				frames[allocated] = (uintptr_t)frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
+				if (frames[allocated]) {
+					memsetb(frames[allocated], FRAME_SIZE << order, val);
+					allocated++;
+				} else {
+					break;
+				}
+			}
+			printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
+
+			printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
+			for (i = 0; i < allocated; i++) {
+				for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) {
+					if (((uint8_t *) frames[i])[k] != val) {
+						printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
+						failed();
+					}
+				}
+				frame_free(KA2PA(frames[i]));
+			}
+			printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id);
+		}
+	}
+	
+	free(frames);
+	printf("Thread #%d (cpu%d): Exiting\n", THREAD->tid, CPU->id);
+	atomic_dec(&thread_count);
+}
+
+
+void failed(void)
+{
+	panic("Test failed.\n");
+}
+
+
+void test_falloc2(void)
+{
+#ifdef CONFIG_BENCH
+	uint64_t t0 = get_cycle();
+#endif
+	int i;
+
+	atomic_set(&thread_count, THREADS);
+		
+	for (i = 0; i < THREADS; i++) {
+		thread_t * thrd;
+		thrd = thread_create(falloc, NULL, TASK, 0, "falloc");
+		if (thrd)
+			thread_ready(thrd);
+		else
+			failed();
+	}
+	
+	while (thread_count.count)
+		;
+
+	printf("Test passed.\n");
+#ifdef CONFIG_BENCH
+	uint64_t dt = get_cycle() - t0;
+	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
+#endif
+}
Index: rnel/test/mm/falloc2/test.c
===================================================================
--- kernel/test/mm/falloc2/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ 	(revision )
@@ -1,123 +1,0 @@
-/*
- * Copyright (C) 2006 Sergey Bondari
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <print.h>
-#include <test.h>
-#include <mm/page.h>
-#include <mm/frame.h>
-#include <mm/slab.h>
-#include <arch/mm/page.h>
-#include <arch/types.h>
-#include <atomic.h>
-#include <debug.h>
-#include <proc/thread.h>
-#include <memstr.h>
-#include <arch.h>
-
-#define MAX_FRAMES 256
-#define MAX_ORDER 8
-
-#define THREAD_RUNS 1
-#define THREADS 8
-
-static void falloc(void * arg);
-static void failed(void);
-
-static atomic_t thread_count;
-
-void falloc(void * arg)
-{
-	int order, run, allocated, i;
-	uint8_t val = THREAD->tid % THREADS;
-	index_t k;
-	
-	uintptr_t * frames =  (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC);
-	ASSERT(frames != NULL);
-	
-	thread_detach(THREAD);
-
-	for (run = 0; run < THREAD_RUNS; run++) {
-		for (order = 0; order <= MAX_ORDER; order++) {
-			printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
-			allocated = 0;
-			for (i = 0; i < (MAX_FRAMES >> order); i++) {
-				frames[allocated] = (uintptr_t)frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
-				if (frames[allocated]) {
-					memsetb(frames[allocated], FRAME_SIZE << order, val);
-					allocated++;
-				} else {
-					break;
-				}
-			}
-			printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
-
-			printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
-			for (i = 0; i < allocated; i++) {
-				for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) {
-					if (((uint8_t *) frames[i])[k] != val) {
-						printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
-						failed();
-					}
-				}
-				frame_free(KA2PA(frames[i]));
-			}
-			printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id);
-		}
-	}
-	
-	free(frames);
-	printf("Thread #%d (cpu%d): Exiting\n", THREAD->tid, CPU->id);
-	atomic_dec(&thread_count);
-}
-
-
-void failed(void)
-{
-	panic("Test failed.\n");
-}
-
-
-void test(void)
-{
-	int i;
-
-	atomic_set(&thread_count, THREADS);
-		
-	for (i = 0; i < THREADS; i++) {
-		thread_t * thrd;
-		thrd = thread_create(falloc, NULL, TASK, 0, "falloc");
-		if (thrd)
-			thread_ready(thrd);
-		else
-			failed();
-	}
-	
-	while (thread_count.count)
-		;
-
-	printf("Test passed.\n");
-}
Index: kernel/test/mm/mapping1.c
===================================================================
--- kernel/test/mm/mapping1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/mm/mapping1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2005 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <print.h>
+#include <test.h>
+#include <mm/page.h>
+#include <mm/frame.h>
+#include <mm/as.h>
+#include <arch/mm/page.h>
+#include <arch/types.h>
+#include <debug.h>
+
+#ifdef CONFIG_BENCH
+#include <arch/cycle.h>
+#endif
+
+#define PAGE0	0x10000000
+#define PAGE1	(PAGE0+PAGE_SIZE)
+
+#define VALUE0	0x01234567
+#define VALUE1	0x89abcdef
+
+void test_mapping1(void)
+{
+#ifdef CONFIG_BENCH
+	uint64_t t0 = get_cycle();
+#endif
+	uintptr_t frame0, frame1;
+	uint32_t v0, v1;
+
+	printf("Memory management test mapping #1\n");
+
+	frame0 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA);
+	frame1 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA);
+
+	printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0));
+	*((uint32_t *) frame0) = VALUE0;
+	printf("Writing %#x to physical address %p.\n", VALUE1, KA2PA(frame1));
+	*((uint32_t *) frame1) = VALUE1;
+	
+	printf("Mapping virtual address %p to physical address %p.\n", PAGE0, KA2PA(frame0));
+	page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE);
+	printf("Mapping virtual address %p to physical address %p.\n", PAGE1, KA2PA(frame1));	
+	page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE);
+	
+	printf("Value at virtual address %p is %#x.\n", PAGE0, v0 = *((uint32_t *) PAGE0));
+	printf("Value at virtual address %p is %#x.\n", PAGE1, v1 = *((uint32_t *) PAGE1));
+	
+	ASSERT(v0 == VALUE0);
+	ASSERT(v1 == VALUE1);
+
+	printf("Writing %#x to virtual address %p.\n", 0, PAGE0);
+	*((uint32_t *) PAGE0) = 0;
+	printf("Writing %#x to virtual address %p.\n", 0, PAGE1);
+	*((uint32_t *) PAGE1) = 0;	
+
+	v0 = *((uint32_t *) PAGE0);
+	v1 = *((uint32_t *) PAGE1);
+	
+	printf("Value at virtual address %p is %#x.\n", PAGE0, *((uint32_t *) PAGE0));	
+	printf("Value at virtual address %p is %#x.\n", PAGE1, *((uint32_t *) PAGE1));
+
+	ASSERT(v0 == 0);
+	ASSERT(v1 == 0);
+	
+	printf("Test passed.\n");
+#ifdef CONFIG_BENCH
+	uint64_t dt = get_cycle() - t0;
+	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
+#endif	
+}
Index: rnel/test/mm/mapping1/test.c
===================================================================
--- kernel/test/mm/mapping1/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ 	(revision )
@@ -1,85 +1,0 @@
-/*
- * Copyright (C) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <print.h>
-#include <test.h>
-#include <mm/page.h>
-#include <mm/frame.h>
-#include <mm/as.h>
-#include <arch/mm/page.h>
-#include <arch/types.h>
-#include <debug.h>
-
-#define PAGE0	0x10000000
-#define PAGE1	(PAGE0+PAGE_SIZE)
-
-#define VALUE0	0x01234567
-#define VALUE1	0x89abcdef
-
-void test(void)
-{
-	uintptr_t frame0, frame1;
-	uint32_t v0, v1;
-
-	printf("Memory management test mapping #1\n");
-
-	frame0 = frame_alloc(ONE_FRAME, FRAME_KA);
-	frame1 = frame_alloc(ONE_FRAME, FRAME_KA);
-
-	printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0));
-	*((uint32_t *) frame0) = VALUE0;
-	printf("Writing %#x to physical address %p.\n", VALUE1, KA2PA(frame1));
-	*((uint32_t *) frame1) = VALUE1;
-	
-	printf("Mapping virtual address %p to physical address %p.\n", PAGE0, KA2PA(frame0));
-	page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE);
-	printf("Mapping virtual address %p to physical address %p.\n", PAGE1, KA2PA(frame1));	
-	page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE);
-	
-	printf("Value at virtual address %p is %#x.\n", PAGE0, v0 = *((uint32_t *) PAGE0));
-	printf("Value at virtual address %p is %#x.\n", PAGE1, v1 = *((uint32_t *) PAGE1));
-	
-	ASSERT(v0 == VALUE0);
-	ASSERT(v1 == VALUE1);
-
-	printf("Writing %#x to virtual address %p.\n", 0, PAGE0);
-	*((uint32_t *) PAGE0) = 0;
-	printf("Writing %#x to virtual address %p.\n", 0, PAGE1);
-	*((uint32_t *) PAGE1) = 0;	
-
-	v0 = *((uint32_t *) PAGE0);
-	v1 = *((uint32_t *) PAGE1);
-	
-	printf("Value at virtual address %p is %#x.\n", PAGE0, *((uint32_t *) PAGE0));	
-	printf("Value at virtual address %p is %#x.\n", PAGE1, *((uint32_t *) PAGE1));
-
-	ASSERT(v0 == 0);
-	ASSERT(v1 == 0);
-	
-	printf("Test passed.\n");
-	
-}
Index: kernel/test/mm/purge1.c
===================================================================
--- kernel/test/mm/purge1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/mm/purge1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2005 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <print.h>
+#include <test.h>
+#include <mm/page.h>
+#include <mm/frame.h>
+#include <mm/as.h>
+#include <arch/mm/page.h>
+#include <arch/mm/tlb.h>
+#include <arch/types.h>
+#include <debug.h>
+
+#ifdef ia64
+
+extern void tlb_invalidate_all(void);
+extern void tlb_invalidate_pages(asid_t asid, uintptr_t va, count_t cnt);
+
+void test(void)
+{
+	tlb_entry_t entryi;
+	tlb_entry_t entryd;
+
+	int i;
+																																													
+	entryd.word[0] = 0;
+	entryd.word[1] = 0;
+												
+	entryd.p = true;                 /* present */
+	entryd.ma = MA_WRITEBACK;
+	entryd.a = true;                 /* already accessed */
+	entryd.d = true;                 /* already dirty */
+	entryd.pl = PL_KERNEL;
+	entryd.ar = AR_READ | AR_WRITE;
+	entryd.ppn = 0;
+	entryd.ps = PAGE_WIDTH;
+	
+	entryi.word[0] = 0;
+	entryi.word[1] = 0;
+	
+	entryi.p = true;                 /* present */
+	entryi.ma = MA_WRITEBACK;
+	entryi.a = true;                 /* already accessed */
+	entryi.d = true;                 /* already dirty */
+	entryi.pl = PL_KERNEL;
+	entryi.ar = AR_READ | AR_EXECUTE;
+	entryi.ppn = 0;
+	entryi.ps = PAGE_WIDTH;
+	
+	for (i = 0; i < 100; i++) {
+		itc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 8, entryi);
+		dtc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 9, entryd);
+	}
+	
+	tlb_invalidate_pages(8,0x0c000,14);
+	
+	/*tlb_invalidate_all();*/
+}
+
+#else
+
+void test_purge1(void)
+{
+	printf("This test is availaible only on IA64 platform.\n");
+}
+
+#endif
Index: rnel/test/mm/purge1/test.c
===================================================================
--- kernel/test/mm/purge1/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ 	(revision )
@@ -1,85 +1,0 @@
-/*
- * Copyright (C) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <print.h>
-#include <test.h>
-#include <mm/page.h>
-#include <mm/frame.h>
-#include <mm/as.h>
-#include <arch/mm/page.h>
-#include <arch/mm/tlb.h>
-#include <arch/types.h>
-#include <debug.h>
-
-
-extern void tlb_invalidate_all(void);
-extern void tlb_invalidate_pages(asid_t asid, uintptr_t va, count_t cnt);
-void test(void)
-{
-	tlb_entry_t entryi;
-	tlb_entry_t entryd;
-
-	int i;
-																																													
-  entryd.word[0] = 0;
-  entryd.word[1] = 0;
-												
-  entryd.p = true;                 /* present */
-  entryd.ma = MA_WRITEBACK;
-  entryd.a = true;                 /* already accessed */
-  entryd.d = true;                 /* already dirty */
-  entryd.pl = PL_KERNEL;
-  entryd.ar = AR_READ | AR_WRITE;
-  entryd.ppn = 0;
-  entryd.ps = PAGE_WIDTH;
-
-
-  entryi.word[0] = 0;
-  entryi.word[1] = 0;
-												
-  entryi.p = true;                 /* present */
-  entryi.ma = MA_WRITEBACK;
-  entryi.a = true;                 /* already accessed */
-  entryi.d = true;                 /* already dirty */
-  entryi.pl = PL_KERNEL;
-  entryi.ar = AR_READ | AR_EXECUTE;
-  entryi.ppn = 0;
-  entryi.ps = PAGE_WIDTH;
-
-	
-	for(i=0;i<100;i++)
-	{
-		itc_mapping_insert(0+i*(1<<PAGE_WIDTH),8,entryi);
-		dtc_mapping_insert(0+i*(1<<PAGE_WIDTH),9,entryd);
-	}	
-	
-
-	tlb_invalidate_pages(8,0x0c000,14);
-	
-	/*tlb_invalidate_all();*/
-	
-}
Index: kernel/test/mm/slab1.c
===================================================================
--- kernel/test/mm/slab1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/mm/slab1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -0,0 +1,171 @@
+/*
+ * 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.
+ */
+
+#include <test.h>
+#include <mm/slab.h>
+#include <print.h>
+#include <proc/thread.h>
+#include <arch.h>
+#include <panic.h>
+#include <memstr.h>
+
+#ifdef CONFIG_BENCH
+#include <arch/cycle.h>
+#endif
+
+#define VAL_COUNT   1024
+
+void * data[VAL_COUNT];
+
+static void testit(int size, int count) 
+{
+	slab_cache_t *cache;
+	int i;
+	
+	printf("Creating cache, object size: %d.\n", size);
+	cache = slab_cache_create("test_cache", size, 0, NULL, NULL, 
+				  SLAB_CACHE_NOMAGAZINE);	
+	printf("Allocating %d items...", count);
+	for (i=0; i < count; i++) {
+		data[i] = slab_alloc(cache, 0);
+		memsetb((uintptr_t)data[i], size, 0);
+	}
+	printf("done.\n");
+	printf("Freeing %d items...", count);
+	for (i=0; i < count; i++) {
+		slab_free(cache, data[i]);
+	}
+	printf("done.\n");
+
+	printf("Allocating %d items...", count);
+	for (i=0; i < count; i++) {
+		data[i] = slab_alloc(cache, 0);
+		memsetb((uintptr_t)data[i], size, 0);
+	}
+	printf("done.\n");
+
+	printf("Freeing %d items...", count/2);
+	for (i=count-1; i >= count/2; i--) {
+		slab_free(cache, data[i]);
+	}
+	printf("done.\n");	
+
+	printf("Allocating %d items...", count/2);
+	for (i=count/2; i < count; i++) {
+		data[i] = slab_alloc(cache, 0);
+		memsetb((uintptr_t)data[i], size, 0);
+	}
+	printf("done.\n");
+	printf("Freeing %d items...", count);
+	for (i=0; i < count; i++) {
+		slab_free(cache, data[i]);
+	}
+	printf("done.\n");	
+	slab_cache_destroy(cache);
+
+	printf("Test complete.\n");
+}
+
+static void testsimple(void)
+{
+	testit(100, VAL_COUNT);
+	testit(200, VAL_COUNT);
+	testit(1024, VAL_COUNT);
+	testit(2048, 512);
+	testit(4000, 128);
+	testit(8192, 128);
+	testit(16384, 128);
+	testit(16385, 128);
+}
+
+
+#define THREADS     6
+#define THR_MEM_COUNT   1024
+#define THR_MEM_SIZE    128
+
+void * thr_data[THREADS][THR_MEM_COUNT];
+slab_cache_t *thr_cache;
+semaphore_t thr_sem;
+
+static void slabtest(void *data)
+{
+	int offs = (int)(unative_t) data;
+	int i,j;
+	
+	thread_detach(THREAD);
+	
+	printf("Starting thread #%d...\n",THREAD->tid);
+	for (j=0; j<10; j++) {
+		for (i=0; i<THR_MEM_COUNT; i++)
+			thr_data[offs][i] = slab_alloc(thr_cache,0);
+		for (i=0; i<THR_MEM_COUNT/2; i++)
+			slab_free(thr_cache, thr_data[offs][i]);
+		for (i=0; i< THR_MEM_COUNT/2; i++)
+			thr_data[offs][i] = slab_alloc(thr_cache, 0);
+		for (i=0; i<THR_MEM_COUNT;i++)
+			slab_free(thr_cache, thr_data[offs][i]);
+	}
+	printf("Thread #%d finished\n", THREAD->tid);
+	semaphore_up(&thr_sem);
+}
+
+static void testthreads(void)
+{
+	thread_t *t;
+	int i;
+
+	thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, 
+				      NULL, NULL, 
+				      SLAB_CACHE_NOMAGAZINE);
+	semaphore_initialize(&thr_sem,0);
+	for (i=0; i<THREADS; i++) {  
+		if (!(t = thread_create(slabtest, (void *)(unative_t)i, TASK, 0, "slabtest")))
+			panic("could not create thread\n");
+		thread_ready(t);
+	}
+
+	for (i=0; i<THREADS; i++)
+		semaphore_down(&thr_sem);
+	
+	slab_cache_destroy(thr_cache);
+	printf("Test complete.\n");
+	
+}
+
+void test_slab1(void)
+{
+#ifdef CONFIG_BENCH
+	uint64_t t0 = get_cycle();
+#endif
+	testsimple();
+	testthreads();
+#ifdef CONFIG_BENCH
+	uint64_t dt = get_cycle() - t0;
+	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
+#endif
+}
Index: rnel/test/mm/slab1/test.c
===================================================================
--- kernel/test/mm/slab1/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ 	(revision )
@@ -1,160 +1,0 @@
-/*
- * Copyright (C) 2006 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <mm/slab.h>
-#include <print.h>
-#include <proc/thread.h>
-#include <arch.h>
-#include <panic.h>
-#include <memstr.h>
-
-#define VAL_COUNT   1024
-
-void * data[VAL_COUNT];
-
-static void testit(int size, int count) 
-{
-	slab_cache_t *cache;
-	int i;
-	
-	printf("Creating cache, object size: %d.\n", size);
-	cache = slab_cache_create("test_cache", size, 0, NULL, NULL, 
-				  SLAB_CACHE_NOMAGAZINE);	
-	printf("Allocating %d items...", count);
-	for (i=0; i < count; i++) {
-		data[i] = slab_alloc(cache, 0);
-		memsetb((uintptr_t)data[i], size, 0);
-	}
-	printf("done.\n");
-	printf("Freeing %d items...", count);
-	for (i=0; i < count; i++) {
-		slab_free(cache, data[i]);
-	}
-	printf("done.\n");
-
-	printf("Allocating %d items...", count);
-	for (i=0; i < count; i++) {
-		data[i] = slab_alloc(cache, 0);
-		memsetb((uintptr_t)data[i], size, 0);
-	}
-	printf("done.\n");
-
-	printf("Freeing %d items...", count/2);
-	for (i=count-1; i >= count/2; i--) {
-		slab_free(cache, data[i]);
-	}
-	printf("done.\n");	
-
-	printf("Allocating %d items...", count/2);
-	for (i=count/2; i < count; i++) {
-		data[i] = slab_alloc(cache, 0);
-		memsetb((uintptr_t)data[i], size, 0);
-	}
-	printf("done.\n");
-	printf("Freeing %d items...", count);
-	for (i=0; i < count; i++) {
-		slab_free(cache, data[i]);
-	}
-	printf("done.\n");	
-	slab_cache_destroy(cache);
-
-	printf("Test complete.\n");
-}
-
-static void testsimple(void)
-{
-	testit(100, VAL_COUNT);
-	testit(200, VAL_COUNT);
-	testit(1024, VAL_COUNT);
-	testit(2048, 512);
-	testit(4000, 128);
-	testit(8192, 128);
-	testit(16384, 128);
-	testit(16385, 128);
-}
-
-
-#define THREADS     6
-#define THR_MEM_COUNT   1024
-#define THR_MEM_SIZE    128
-
-void * thr_data[THREADS][THR_MEM_COUNT];
-slab_cache_t *thr_cache;
-semaphore_t thr_sem;
-
-static void slabtest(void *data)
-{
-	int offs = (int)(unative_t) data;
-	int i,j;
-	
-	thread_detach(THREAD);
-	
-	printf("Starting thread #%d...\n",THREAD->tid);
-	for (j=0; j<10; j++) {
-		for (i=0; i<THR_MEM_COUNT; i++)
-			thr_data[offs][i] = slab_alloc(thr_cache,0);
-		for (i=0; i<THR_MEM_COUNT/2; i++)
-			slab_free(thr_cache, thr_data[offs][i]);
-		for (i=0; i< THR_MEM_COUNT/2; i++)
-			thr_data[offs][i] = slab_alloc(thr_cache, 0);
-		for (i=0; i<THR_MEM_COUNT;i++)
-			slab_free(thr_cache, thr_data[offs][i]);
-	}
-	printf("Thread #%d finished\n", THREAD->tid);
-	semaphore_up(&thr_sem);
-}
-
-static void testthreads(void)
-{
-	thread_t *t;
-	int i;
-
-	thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, 
-				      NULL, NULL, 
-				      SLAB_CACHE_NOMAGAZINE);
-	semaphore_initialize(&thr_sem,0);
-	for (i=0; i<THREADS; i++) {  
-		if (!(t = thread_create(slabtest, (void *)(unative_t)i, TASK, 0, "slabtest")))
-			panic("could not create thread\n");
-		thread_ready(t);
-	}
-
-	for (i=0; i<THREADS; i++)
-		semaphore_down(&thr_sem);
-	
-	slab_cache_destroy(thr_cache);
-	printf("Test complete.\n");
-	
-}
-
-void test(void)
-{
-	testsimple();
-	testthreads();
-}
Index: kernel/test/mm/slab2.c
===================================================================
--- kernel/test/mm/slab2.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/mm/slab2.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -0,0 +1,234 @@
+/*
+ * 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.
+ */
+
+#include <test.h>
+#include <mm/slab.h>
+#include <print.h>
+#include <proc/thread.h>
+#include <arch.h>
+#include <panic.h>
+#include <mm/frame.h>
+#include <memstr.h>
+#include <synch/condvar.h>
+#include <synch/mutex.h>
+
+#ifdef CONFIG_BENCH
+#include <arch/cycle.h>
+#endif
+
+#define ITEM_SIZE 256
+
+/** Fill memory with 2 caches, when allocation fails,
+ *  free one of the caches. We should have everything in magazines,
+ *  now allocation should clean magazines and allow for full allocation.
+ */
+static void totalmemtest(void)
+{
+	slab_cache_t *cache1;
+	slab_cache_t *cache2;
+	int i;
+
+	void *data1, *data2;
+	void *olddata1=NULL, *olddata2=NULL;
+	
+	cache1 = slab_cache_create("cache1_tst", ITEM_SIZE, 0, NULL, NULL, 0);
+	cache2 = slab_cache_create("cache2_tst", ITEM_SIZE, 0, NULL, NULL, 0);
+
+	printf("Allocating...");
+	/* Use atomic alloc, so that we find end of memory */
+	do {
+		data1 = slab_alloc(cache1, FRAME_ATOMIC);
+		data2 = slab_alloc(cache2, FRAME_ATOMIC);
+		if (!data1 || !data2) {
+			if (data1)
+				slab_free(cache1,data1);
+			if (data2)
+				slab_free(cache2,data2);
+			break;
+		}
+		memsetb((uintptr_t)data1, ITEM_SIZE, 0);
+		memsetb((uintptr_t)data2, ITEM_SIZE, 0);
+		*((void **)data1) = olddata1;
+		*((void **)data2) = olddata2;
+		olddata1 = data1;
+		olddata2 = data2;
+	}while(1);
+	printf("done.\n");
+	/* We do not have memory - now deallocate cache2 */
+	printf("Deallocating cache2...");
+	while (olddata2) {
+		data2 = *((void **)olddata2);
+		slab_free(cache2, olddata2);
+		olddata2 = data2;
+	}
+	printf("done.\n");
+
+	printf("Allocating to cache1...\n");
+	for (i=0; i<30; i++) {
+		data1 = slab_alloc(cache1, FRAME_ATOMIC);
+		if (!data1) {
+			panic("Incorrect memory size - use another test.");
+		}
+		memsetb((uintptr_t)data1, ITEM_SIZE, 0);
+		*((void **)data1) = olddata1;
+		olddata1 = data1;
+	}
+	while (1) {
+		data1 = slab_alloc(cache1, FRAME_ATOMIC);
+		if (!data1) {
+			break;
+		}
+		memsetb((uintptr_t)data1, ITEM_SIZE, 0);
+		*((void **)data1) = olddata1;
+		olddata1 = data1;
+	}
+	printf("Deallocating cache1...");
+	while (olddata1) {
+		data1 = *((void **)olddata1);
+		slab_free(cache1, olddata1);
+		olddata1 = data1;
+	}
+	printf("done.\n");
+	slab_print_list();
+	slab_cache_destroy(cache1);
+	slab_cache_destroy(cache2);
+}
+
+slab_cache_t *thr_cache;
+semaphore_t thr_sem;
+condvar_t thread_starter;
+mutex_t starter_mutex;
+
+#define THREADS 8
+
+static void slabtest(void *priv)
+{
+	void *data=NULL, *new;
+
+	thread_detach(THREAD);
+
+	mutex_lock(&starter_mutex);
+	condvar_wait(&thread_starter,&starter_mutex);
+	mutex_unlock(&starter_mutex);
+		
+	printf("Starting thread #%d...\n",THREAD->tid);
+
+	/* Alloc all */
+	printf("Thread #%d allocating...\n", THREAD->tid);
+	while (1) {
+		/* Call with atomic to detect end of memory */
+		new = slab_alloc(thr_cache, FRAME_ATOMIC);
+		if (!new)
+			break;
+		*((void **)new) = data;
+		data = new;
+	}
+	printf("Thread #%d releasing...\n", THREAD->tid);
+	while (data) {
+		new = *((void **)data);
+		*((void **)data) = NULL;
+		slab_free(thr_cache, data);
+		data = new;
+	}
+	printf("Thread #%d allocating...\n", THREAD->tid);
+	while (1) {
+		/* Call with atomic to detect end of memory */
+		new = slab_alloc(thr_cache, FRAME_ATOMIC);
+		if (!new)
+			break;
+		*((void **)new) = data;
+		data = new;
+	}
+	printf("Thread #%d releasing...\n", THREAD->tid);
+	while (data) {
+		new = *((void **)data);
+		*((void **)data) = NULL;
+		slab_free(thr_cache, data);
+		data = new;
+	}
+
+
+	printf("Thread #%d finished\n", THREAD->tid);
+	slab_print_list();
+	semaphore_up(&thr_sem);
+}
+
+
+static void multitest(int size)
+{
+	/* Start 8 threads that just allocate as much as possible,
+	 * then release everything, then again allocate, then release
+	 */
+	thread_t *t;
+	int i;
+
+	printf("Running stress test with size %d\n", size);
+	condvar_initialize(&thread_starter);
+	mutex_initialize(&starter_mutex);
+
+	thr_cache = slab_cache_create("thread_cache", size, 0, 
+				      NULL, NULL, 
+				      0);
+	semaphore_initialize(&thr_sem,0);
+	for (i=0; i<THREADS; i++) {  
+		if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest")))
+			panic("could not create thread\n");
+		thread_ready(t);
+	}
+	thread_sleep(1);
+	condvar_broadcast(&thread_starter);
+
+	for (i=0; i<THREADS; i++)
+		semaphore_down(&thr_sem);
+	
+	slab_cache_destroy(thr_cache);
+	printf("Stress test complete.\n");
+}
+
+void test_slab2(void)
+{
+#ifdef CONFIG_BENCH
+	uint64_t t0 = get_cycle();
+#endif
+
+	printf("Running reclaim single-thread test .. pass1\n");
+	totalmemtest();
+	printf("Running reclaim single-thread test .. pass2\n");
+	totalmemtest();
+	printf("Reclaim test OK.\n");
+
+	multitest(128);
+	multitest(2048);
+	multitest(8192);
+	printf("All done.\n");
+
+#ifdef CONFIG_BENCH
+	uint64_t dt = get_cycle() - t0;
+	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
+#endif
+}
Index: rnel/test/mm/slab2/test.c
===================================================================
--- kernel/test/mm/slab2/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ 	(revision )
@@ -1,234 +1,0 @@
-/*
- * Copyright (C) 2006 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <mm/slab.h>
-#include <print.h>
-#include <proc/thread.h>
-#include <arch.h>
-#include <panic.h>
-#include <mm/frame.h>
-#include <memstr.h>
-#include <synch/condvar.h>
-#include <synch/mutex.h>
-
-#ifdef CONFIG_BENCH
-#include <arch/cycle.h>
-#endif
-
-#define ITEM_SIZE 256
-
-/** Fill memory with 2 caches, when allocation fails,
- *  free one of the caches. We should have everything in magazines,
- *  now allocation should clean magazines and allow for full allocation.
- */
-static void totalmemtest(void)
-{
-	slab_cache_t *cache1;
-	slab_cache_t *cache2;
-	int i;
-
-	void *data1, *data2;
-	void *olddata1=NULL, *olddata2=NULL;
-	
-	cache1 = slab_cache_create("cache1_tst", ITEM_SIZE, 0, NULL, NULL, 0);
-	cache2 = slab_cache_create("cache2_tst", ITEM_SIZE, 0, NULL, NULL, 0);
-
-	printf("Allocating...");
-	/* Use atomic alloc, so that we find end of memory */
-	do {
-		data1 = slab_alloc(cache1, FRAME_ATOMIC);
-		data2 = slab_alloc(cache2, FRAME_ATOMIC);
-		if (!data1 || !data2) {
-			if (data1)
-				slab_free(cache1,data1);
-			if (data2)
-				slab_free(cache2,data2);
-			break;
-		}
-		memsetb((uintptr_t)data1, ITEM_SIZE, 0);
-		memsetb((uintptr_t)data2, ITEM_SIZE, 0);
-		*((void **)data1) = olddata1;
-		*((void **)data2) = olddata2;
-		olddata1 = data1;
-		olddata2 = data2;
-	}while(1);
-	printf("done.\n");
-	/* We do not have memory - now deallocate cache2 */
-	printf("Deallocating cache2...");
-	while (olddata2) {
-		data2 = *((void **)olddata2);
-		slab_free(cache2, olddata2);
-		olddata2 = data2;
-	}
-	printf("done.\n");
-
-	printf("Allocating to cache1...\n");
-	for (i=0; i<30; i++) {
-		data1 = slab_alloc(cache1, FRAME_ATOMIC);
-		if (!data1) {
-			panic("Incorrect memory size - use another test.");
-		}
-		memsetb((uintptr_t)data1, ITEM_SIZE, 0);
-		*((void **)data1) = olddata1;
-		olddata1 = data1;
-	}
-	while (1) {
-		data1 = slab_alloc(cache1, FRAME_ATOMIC);
-		if (!data1) {
-			break;
-		}
-		memsetb((uintptr_t)data1, ITEM_SIZE, 0);
-		*((void **)data1) = olddata1;
-		olddata1 = data1;
-	}
-	printf("Deallocating cache1...");
-	while (olddata1) {
-		data1 = *((void **)olddata1);
-		slab_free(cache1, olddata1);
-		olddata1 = data1;
-	}
-	printf("done.\n");
-	slab_print_list();
-	slab_cache_destroy(cache1);
-	slab_cache_destroy(cache2);
-}
-
-slab_cache_t *thr_cache;
-semaphore_t thr_sem;
-condvar_t thread_starter;
-mutex_t starter_mutex;
-
-#define THREADS 8
-
-static void slabtest(void *priv)
-{
-	void *data=NULL, *new;
-
-	thread_detach(THREAD);
-
-	mutex_lock(&starter_mutex);
-	condvar_wait(&thread_starter,&starter_mutex);
-	mutex_unlock(&starter_mutex);
-		
-	printf("Starting thread #%d...\n",THREAD->tid);
-
-	/* Alloc all */
-	printf("Thread #%d allocating...\n", THREAD->tid);
-	while (1) {
-		/* Call with atomic to detect end of memory */
-		new = slab_alloc(thr_cache, FRAME_ATOMIC);
-		if (!new)
-			break;
-		*((void **)new) = data;
-		data = new;
-	}
-	printf("Thread #%d releasing...\n", THREAD->tid);
-	while (data) {
-		new = *((void **)data);
-		*((void **)data) = NULL;
-		slab_free(thr_cache, data);
-		data = new;
-	}
-	printf("Thread #%d allocating...\n", THREAD->tid);
-	while (1) {
-		/* Call with atomic to detect end of memory */
-		new = slab_alloc(thr_cache, FRAME_ATOMIC);
-		if (!new)
-			break;
-		*((void **)new) = data;
-		data = new;
-	}
-	printf("Thread #%d releasing...\n", THREAD->tid);
-	while (data) {
-		new = *((void **)data);
-		*((void **)data) = NULL;
-		slab_free(thr_cache, data);
-		data = new;
-	}
-
-
-	printf("Thread #%d finished\n", THREAD->tid);
-	slab_print_list();
-	semaphore_up(&thr_sem);
-}
-
-
-static void multitest(int size)
-{
-	/* Start 8 threads that just allocate as much as possible,
-	 * then release everything, then again allocate, then release
-	 */
-	thread_t *t;
-	int i;
-
-	printf("Running stress test with size %d\n", size);
-	condvar_initialize(&thread_starter);
-	mutex_initialize(&starter_mutex);
-
-	thr_cache = slab_cache_create("thread_cache", size, 0, 
-				      NULL, NULL, 
-				      0);
-	semaphore_initialize(&thr_sem,0);
-	for (i=0; i<THREADS; i++) {  
-		if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest")))
-			panic("could not create thread\n");
-		thread_ready(t);
-	}
-	thread_sleep(1);
-	condvar_broadcast(&thread_starter);
-
-	for (i=0; i<THREADS; i++)
-		semaphore_down(&thr_sem);
-	
-	slab_cache_destroy(thr_cache);
-	printf("Stress test complete.\n");
-}
-
-void test(void)
-{
-#ifdef CONFIG_BENCH
-	uint64_t t0 = get_cycle();
-#endif
-
-	printf("Running reclaim single-thread test .. pass1\n");
-	totalmemtest();
-	printf("Running reclaim single-thread test .. pass2\n");
-	totalmemtest();
-	printf("Reclaim test OK.\n");
-
-	multitest(128);
-	multitest(2048);
-	multitest(8192);
-	printf("All done.\n");
-
-#ifdef CONFIG_BENCH
-	uint64_t dt = get_cycle() - t0;
-	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
-#endif
-}
Index: kernel/test/test.c
===================================================================
--- kernel/test/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ kernel/test/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -66,4 +66,52 @@
 		true
 	},
+	{
+		"sse1",
+		"Intel SEE test",
+		&test_sse1,
+		true
+	},
+	{
+		"mips2",
+		"MIPS FPU test",
+		&test_mips2,
+		true
+	},
+	{
+		"falloc1",
+		"Frame allocator test 1",
+		&test_falloc1,
+		true
+	},
+	{
+		"falloc2",
+		"Frame allocator test 2",
+		&test_falloc2,
+		true
+	},
+	{
+		"mapping1",
+		"Mapping test",
+		&test_mapping1,
+		true
+	},
+	{
+		"slab1",
+		"SLAB test 1",
+		&test_slab1,
+		true
+	},
+	{
+		"slab2",
+		"SLAB test 2",
+		&test_slab2,
+		true
+	},
+	{
+		"purge1",
+		"Itanium TLB purge test",
+		&test_purge1,
+		true
+	},
 	{NULL, NULL, NULL}
 };
Index: kernel/test/test.h
===================================================================
--- kernel/test/test.h	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ kernel/test/test.h	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
@@ -51,4 +51,12 @@
 extern void test_fault1(void);
 extern void test_fpu1(void);
+extern void test_sse1(void);
+extern void test_mips2(void);
+extern void test_falloc1(void);
+extern void test_falloc2(void);
+extern void test_mapping1(void);
+extern void test_purge1(void);
+extern void test_slab1(void);
+extern void test_slab2(void);
 
 extern test_t tests[];
