Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision bd1deed7b64271415d7ecf3951bd917d8093536f)
+++ kernel/Makefile	(revision c993e4509b7e3c511044d8e7ecb0116eeb114012)
@@ -246,5 +246,6 @@
 
 ifeq ($(CONFIG_EXPERIMENTAL),y)
-	GENERIC_SOURCES += generic/src/lib/objc.c
+	GENERIC_SOURCES += generic/src/lib/objc_ext.c \
+		generic/src/lib/objc.c
 	EXTRA_OBJECTS = $(LIBDIR)/libobjc.a
 	EXTRA_FLAGS += -x objective-c
Index: kernel/generic/include/lib/objc.h
===================================================================
--- kernel/generic/include/lib/objc.h	(revision bd1deed7b64271415d7ecf3951bd917d8093536f)
+++ kernel/generic/include/lib/objc.h	(revision c993e4509b7e3c511044d8e7ecb0116eeb114012)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2006 Martin Decky
+ * Copyright (c) 2007 Martin Decky
  * All rights reserved.
  *
@@ -36,29 +36,15 @@
 #define KERN_OBJC_H_
 
-#include <arch/types.h>
-#include <arch/arg.h>
+extern id class_create_instance(Class _class);
+extern id object_dispose(id object);
 
-extern void *stderr;
+@interface base_t {
+    Class isa;
+}
 
-extern void __assert_fail(const char *assertion, const char *file, unsigned int line, const char *function);
-extern void abort(void);
++ (id) new;
+- (id) free;
 
-extern void *fopen(const char *path, const char *mode);
-extern size_t fread(void *ptr, size_t size, size_t nmemb, void *stream);
-extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, void *stream);
-extern int fflush(void *stream);
-extern int feof(void *stream);
-extern int fclose(void *stream);
-
-extern int vfprintf(void *stream, const char *format, va_list ap);
-extern int sscanf(const char *str, const char *format, ...);
-extern const unsigned short **__ctype_b_loc(void);
-extern long int __strtol_internal(const char *__nptr, char **__endptr, int __base, int __group);
-
-extern void *memset(void *s, int c, size_t n);
-extern void *calloc(size_t nmemb, size_t size);
+@end
 
 #endif
-
-/** @}
- */
Index: kernel/generic/include/lib/objc_ext.h
===================================================================
--- kernel/generic/include/lib/objc_ext.h	(revision c993e4509b7e3c511044d8e7ecb0116eeb114012)
+++ kernel/generic/include/lib/objc_ext.h	(revision c993e4509b7e3c511044d8e7ecb0116eeb114012)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup generic	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_OBJC_EXT_H_
+#define KERN_OBJC_EXT_H_
+
+#include <arch/types.h>
+#include <arch/arg.h>
+
+extern void *stderr;
+
+extern void __assert_fail(const char *assertion, const char *file, unsigned int line, const char *function);
+extern void abort(void);
+
+extern void *fopen(const char *path, const char *mode);
+extern size_t fread(void *ptr, size_t size, size_t nmemb, void *stream);
+extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, void *stream);
+extern int fflush(void *stream);
+extern int feof(void *stream);
+extern int fclose(void *stream);
+
+extern int vfprintf(void *stream, const char *format, va_list ap);
+extern int sscanf(const char *str, const char *format, ...);
+extern const unsigned short **__ctype_b_loc(void);
+extern long int __strtol_internal(const char *__nptr, char **__endptr, int __base, int __group);
+
+extern void *memset(void *s, int c, size_t n);
+extern void *calloc(size_t nmemb, size_t size);
+
+#endif
+
+/** @}
+ */
Index: kernel/generic/include/mm/as.h
===================================================================
--- kernel/generic/include/mm/as.h	(revision bd1deed7b64271415d7ecf3951bd917d8093536f)
+++ kernel/generic/include/mm/as.h	(revision c993e4509b7e3c511044d8e7ecb0116eeb114012)
@@ -54,4 +54,8 @@
 #include <lib/elf.h>
 
+#ifdef __OBJC__
+#include <lib/objc.h>
+#endif
+
 /**
  * Defined to be true if user address space and kernel address space shadow each
@@ -82,5 +86,5 @@
 
 #ifdef __OBJC__
-@interface as_t {
+@interface as_t : base_t {
 	@public
 		/** Protected by asidlock. */
@@ -110,8 +114,10 @@
 		as_arch_t arch;
 }
+
 + (pte_t *) page_table_create: (int) flags;
 + (void) page_table_destroy: (pte_t *) page_table;
 - (void) page_table_lock: (bool) _lock;
 - (void) page_table_unlock: (bool) unlock;
+
 @end
 
Index: rnel/generic/src/lib/objc.c
===================================================================
--- kernel/generic/src/lib/objc.c	(revision bd1deed7b64271415d7ecf3951bd917d8093536f)
+++ 	(revision )
@@ -1,174 +1,0 @@
-/*
- * Copyright (c) 2007 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup generic	
- * @{
- */
-
-/**
- * @file
- * @brief	Objective C bindings.
- *
- * This file provides architecture independent binding
- * functions which are needed to link with libobjc run-time
- * library. Many of the functions are just dummy.
- */
-
-#include <lib/objc.h>
-#include <panic.h>
-#include <arch/memstr.h>
-#include <mm/slab.h>
-
-void *stderr;
-
-static unsigned short __ctype_b[384] = {
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    2,     2,     2,     2,     2,     2,     2,     2, 
-	    2,  8195,  8194,  8194,  8194,  8194,     2,     2, 
-	    2,     2,     2,     2,     2,     2,     2,     2, 
-	    2,     2,     2,     2,     2,     2,     2,     2, 
-	24577, 49156, 49156, 49156, 49156, 49156, 49156, 49156, 
-	49156, 49156, 49156, 49156, 49156, 49156, 49156, 49156, 
-	55304, 55304, 55304, 55304, 55304, 55304, 55304, 55304, 
-	55304, 55304, 49156, 49156, 49156, 49156, 49156, 49156, 
-	49156, 54536, 54536, 54536, 54536, 54536, 54536, 50440, 
-	50440, 50440, 50440, 50440, 50440, 50440, 50440, 50440, 
-	50440, 50440, 50440, 50440, 50440, 50440, 50440, 50440, 
-	50440, 50440, 50440, 49156, 49156, 49156, 49156, 49156, 
-	49156, 54792, 54792, 54792, 54792, 54792, 54792, 50696, 
-	50696, 50696, 50696, 50696, 50696, 50696, 50696, 50696, 
-	50696, 50696, 50696, 50696, 50696, 50696, 50696, 50696, 
-	50696, 50696, 50696, 49156, 49156, 49156, 49156,     2, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0, 
-	    0,     0,     0,     0,     0,     0,     0,     0
-};
-
-static const unsigned short *__ctype_b_ptr = __ctype_b + 128;
-
-void __assert_fail(const char *assertion, const char *file, unsigned int line, const char *function)
-{
-	panic("Run-time assertion (%s:%d:%s) failed (%s)", file, line, function ? function : "", assertion);
-}
-
-void abort(void)
-{
-	panic("Run-time scheduled abort");
-}
-
-void *fopen(const char *path, const char *mode)
-{
-	return NULL;
-}
-
-size_t fread(void *ptr, size_t size, size_t nmemb, void *stream)
-{
-	return 0;
-}
-
-size_t fwrite(const void *ptr, size_t size, size_t nmemb, void *stream)
-{
-	return 0;
-}
-
-int fflush(void *stream)
-{
-	return 0;
-}
-
-int feof(void *stream)
-{
-	return 1;
-}
-
-int fclose(void *stream)
-{
-	return 0;
-}
-
-int vfprintf(void *stream, const char *format, va_list ap)
-{
-	return 0;
-}
-
-int sscanf(const char *str, const char *format, ...)
-{
-	return 0;
-}
-
-const unsigned short **__ctype_b_loc(void)
-{
-	return &__ctype_b_ptr;
-}
-
-long int __strtol_internal(const char *__nptr, char **__endptr, int __base, int __group)
-{
-	return 0;
-}
-
-void *memset(void *s, int c, size_t n)
-{
-	memsetb((uintptr_t) s, n, c);
-	return s;
-}
-
-void *calloc(size_t nmemb, size_t size)
-{
-	return malloc(nmemb * size, 0);
-}
-
-/** @}
- */
Index: kernel/generic/src/lib/objc_ext.c
===================================================================
--- kernel/generic/src/lib/objc_ext.c	(revision c993e4509b7e3c511044d8e7ecb0116eeb114012)
+++ kernel/generic/src/lib/objc_ext.c	(revision c993e4509b7e3c511044d8e7ecb0116eeb114012)
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2007 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup generic	
+ * @{
+ */
+
+/**
+ * @file
+ * @brief	Objective C bindings.
+ *
+ * This file provides architecture independent binding
+ * functions which are needed to link with libobjc run-time
+ * library. Many of the functions are just dummy.
+ */
+
+#include <lib/objc_ext.h>
+#include <panic.h>
+#include <arch/memstr.h>
+#include <mm/slab.h>
+
+void *stderr;
+
+static unsigned short __ctype_b[384] = {
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    2,     2,     2,     2,     2,     2,     2,     2, 
+	    2,  8195,  8194,  8194,  8194,  8194,     2,     2, 
+	    2,     2,     2,     2,     2,     2,     2,     2, 
+	    2,     2,     2,     2,     2,     2,     2,     2, 
+	24577, 49156, 49156, 49156, 49156, 49156, 49156, 49156, 
+	49156, 49156, 49156, 49156, 49156, 49156, 49156, 49156, 
+	55304, 55304, 55304, 55304, 55304, 55304, 55304, 55304, 
+	55304, 55304, 49156, 49156, 49156, 49156, 49156, 49156, 
+	49156, 54536, 54536, 54536, 54536, 54536, 54536, 50440, 
+	50440, 50440, 50440, 50440, 50440, 50440, 50440, 50440, 
+	50440, 50440, 50440, 50440, 50440, 50440, 50440, 50440, 
+	50440, 50440, 50440, 49156, 49156, 49156, 49156, 49156, 
+	49156, 54792, 54792, 54792, 54792, 54792, 54792, 50696, 
+	50696, 50696, 50696, 50696, 50696, 50696, 50696, 50696, 
+	50696, 50696, 50696, 50696, 50696, 50696, 50696, 50696, 
+	50696, 50696, 50696, 49156, 49156, 49156, 49156,     2, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0, 
+	    0,     0,     0,     0,     0,     0,     0,     0
+};
+
+static const unsigned short *__ctype_b_ptr = __ctype_b + 128;
+
+void __assert_fail(const char *assertion, const char *file, unsigned int line, const char *function)
+{
+	panic("Run-time assertion (%s:%d:%s) failed (%s)", file, line, function ? function : "", assertion);
+}
+
+void abort(void)
+{
+	panic("Run-time scheduled abort");
+}
+
+void *fopen(const char *path, const char *mode)
+{
+	return NULL;
+}
+
+size_t fread(void *ptr, size_t size, size_t nmemb, void *stream)
+{
+	return 0;
+}
+
+size_t fwrite(const void *ptr, size_t size, size_t nmemb, void *stream)
+{
+	return 0;
+}
+
+int fflush(void *stream)
+{
+	return 0;
+}
+
+int feof(void *stream)
+{
+	return 1;
+}
+
+int fclose(void *stream)
+{
+	return 0;
+}
+
+int vfprintf(void *stream, const char *format, va_list ap)
+{
+	return 0;
+}
+
+int sscanf(const char *str, const char *format, ...)
+{
+	return 0;
+}
+
+const unsigned short **__ctype_b_loc(void)
+{
+	return &__ctype_b_ptr;
+}
+
+long int __strtol_internal(const char *__nptr, char **__endptr, int __base, int __group)
+{
+	return 0;
+}
+
+void *memset(void *s, int c, size_t n)
+{
+	memsetb((uintptr_t) s, n, c);
+	return s;
+}
+
+void *calloc(size_t nmemb, size_t size)
+{
+	return malloc(nmemb * size, 0);
+}
+
+/** @}
+ */
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision bd1deed7b64271415d7ecf3951bd917d8093536f)
+++ kernel/generic/src/mm/as.c	(revision c993e4509b7e3c511044d8e7ecb0116eeb114012)
@@ -88,5 +88,4 @@
  */
 as_operations_t *as_operations = NULL;
-#endif
 
 /**
@@ -94,4 +93,5 @@
  */
 static slab_cache_t *as_slab;
+#endif
 
 /**
@@ -116,4 +116,5 @@
 static void sh_info_remove_reference(share_info_t *sh_info);
 
+#ifndef __OBJC__
 static int as_constructor(void *obj, int flags)
 {
@@ -135,4 +136,5 @@
 	return as_destructor_arch(as);
 }
+#endif
 
 /** Initialize address space subsystem. */
@@ -140,7 +142,9 @@
 {
 	as_arch_init();
-	
+
+#ifndef __OBJC__
 	as_slab = slab_cache_create("as_slab", sizeof(as_t), 0,
 	    as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED);
+#endif
 	
 	AS_KERNEL = as_create(FLAG_AS_KERNEL);
@@ -158,5 +162,12 @@
 	as_t *as;
 
+#ifdef __OBJC__
+	as = [as_t new];
+	link_initialize(&as->inactive_as_with_asid_link);
+	mutex_initialize(&as->lock);	
+	(void) as_constructor_arch(as, flags);
+#else
 	as = (as_t *) slab_alloc(as_slab, 0);
+#endif
 	(void) as_create_arch(as, 0);
 	
@@ -229,6 +240,10 @@
 
 	interrupts_restore(ipl);
-	
+
+#ifdef __OBJC__
+	[as free];
+#else
 	slab_free(as_slab, as);
+#endif
 }
 
