Index: kernel/generic/include/arch.h
===================================================================
--- kernel/generic/include/arch.h	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/generic/include/arch.h	(revision 26678e5a1f0f0a6dda91a9e89a03aa3ca86e447c)
@@ -76,4 +76,5 @@
 extern void arch_pre_mm_init(void);
 extern void arch_post_mm_init(void);
+extern void arch_post_cpu_init(void);
 extern void arch_pre_smp_init(void);
 extern void arch_post_smp_init(void);
Index: kernel/generic/include/smp/smp.h
===================================================================
--- kernel/generic/include/smp/smp.h	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/generic/include/smp/smp.h	(revision 26678e5a1f0f0a6dda91a9e89a03aa3ca86e447c)
@@ -36,8 +36,13 @@
 #define KERN_SMP_H_
 
+#include <synch/waitq.h>
+
+extern waitq_t ap_completion_wq;
+
 #ifdef CONFIG_SMP
 extern void smp_init(void);
+extern void kmp(void *arg);
 #else
-#define smp_init()	;
+#define smp_init()
 #endif /* CONFIG_SMP */
 
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/generic/src/main/kinit.c	(revision 26678e5a1f0f0a6dda91a9e89a03aa3ca86e447c)
@@ -64,5 +64,5 @@
 
 #ifdef CONFIG_SMP
-#include <arch/smp/mps.h>
+#include <smp/smp.h>
 #endif /* CONFIG_SMP */
 
@@ -95,4 +95,5 @@
 #ifdef CONFIG_SMP		 	
 	if (config.cpu_count > 1) {
+		waitq_initialize(&ap_completion_wq);
 		/*
 		 * Create the kmp thread and wait for its completion.
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/generic/src/main/main.c	(revision 26678e5a1f0f0a6dda91a9e89a03aa3ca86e447c)
@@ -80,9 +80,4 @@
 #include <adt/btree.h>
 #include <console/klog.h>
-
-#ifdef CONFIG_SMP
-#include <arch/smp/apic.h>
-#include <arch/smp/mps.h>
-#endif /* CONFIG_SMP */
 #include <smp/smp.h>
 
@@ -272,5 +267,5 @@
  *
  * Executed by application processors, temporary stack
- * is at ctx.sp which was set during BP boot.
+ * is at ctx.sp which was set during BSP boot.
  * This function passes control directly to
  * main_ap_separated_stack().
@@ -283,7 +278,6 @@
 	/*
 	 * Incrementing the active CPU counter will guarantee that the
-	 * pm_init() will not attempt to build GDT and IDT tables again.
-	 * Neither frame_init() will do the complete thing. Neither cpu_init()
-	 * will do.
+	 * *_init() functions can find out that they need to
+	 * do initialization for AP only.
 	 */
 	config.cpu_active++;
@@ -301,9 +295,6 @@
 	
 	cpu_init();
-	
 	calibrate_delay_loop();
-
-	l_apic_init();
-	l_apic_debug();
+	arch_post_cpu_init();
 
 	the_copy(THE, (the_t *) CPU->stack);
Index: kernel/generic/src/smp/smp.c
===================================================================
--- kernel/generic/src/smp/smp.c	(revision 26678e5a1f0f0a6dda91a9e89a03aa3ca86e447c)
+++ kernel/generic/src/smp/smp.c	(revision 26678e5a1f0f0a6dda91a9e89a03aa3ca86e447c)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2006 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup generic	
+ * @{
+ */
+
+/**
+ * @file
+ */
+ 
+#include <smp/smp.h>
+
+#ifdef CONFIG_SMP
+
+waitq_t ap_completion_wq;
+
+#endif /* CONFIG_SMP */
+
+/** @}
+ */
