Index: kernel/arch/mips32/include/asm.h
===================================================================
--- kernel/arch/mips32/include/asm.h	(revision ae318d3535cba06a6996f270db31a961fae402ad)
+++ kernel/arch/mips32/include/asm.h	(revision edd7aa6d2706f6923818608ee4bd2df91876ad58)
@@ -56,5 +56,9 @@
 	uintptr_t v;
 	
-	asm volatile ("and %0, $29, %1\n" : "=r" (v) : "r" (~(STACK_SIZE-1)));
+	asm volatile (
+		"and %0, $29, %1\n"
+		: "=r" (v)
+		: "r" (~(STACK_SIZE-1))
+	);
 	
 	return v;
@@ -64,5 +68,5 @@
 extern void asm_delay_loop(uint32_t t);
 extern void userspace_asm(uintptr_t ustack, uintptr_t uspace_uarg,
-			  uintptr_t entry);
+    uintptr_t entry);
 
 extern ipl_t interrupts_disable(void);
@@ -70,4 +74,5 @@
 extern void interrupts_restore(ipl_t ipl);
 extern ipl_t interrupts_read(void);
+extern void asm_delay_loop(uint32_t t);
 
 static inline void pio_write_8(ioport_t port, uint8_t v)
Index: kernel/arch/mips32/include/atomic.h
===================================================================
--- kernel/arch/mips32/include/atomic.h	(revision ae318d3535cba06a6996f270db31a961fae402ad)
+++ kernel/arch/mips32/include/atomic.h	(revision edd7aa6d2706f6923818608ee4bd2df91876ad58)
@@ -36,12 +36,12 @@
 #define KERN_mips32_ATOMIC_H_
 
-#define atomic_inc(x)	((void) atomic_add(x, 1))
-#define atomic_dec(x)	((void) atomic_add(x, -1))
+#define atomic_inc(x)  ((void) atomic_add(x, 1))
+#define atomic_dec(x)  ((void) atomic_add(x, -1))
 
-#define atomic_postinc(x) (atomic_add(x, 1) - 1)
-#define atomic_postdec(x) (atomic_add(x, -1) + 1)
+#define atomic_postinc(x)  (atomic_add(x, 1) - 1)
+#define atomic_postdec(x)  (atomic_add(x, -1) + 1)
 
-#define atomic_preinc(x) atomic_add(x, 1)
-#define atomic_predec(x) atomic_add(x, -1)
+#define atomic_preinc(x)  atomic_add(x, 1)
+#define atomic_predec(x)  atomic_add(x, -1)
 
 /* Atomic addition of immediate value.
@@ -55,17 +55,35 @@
 {
 	long tmp, v;
-
+	
 	asm volatile (
 		"1:\n"
 		"	ll %0, %1\n"
-		"	addu %0, %0, %3\n"	/* same as addi, but never traps on overflow */
-		"       move %2, %0\n"
+		"	addu %0, %0, %3\n"  /* same as addi, but never traps on overflow */
+		"	move %2, %0\n"
 		"	sc %0, %1\n"
-		"	beq %0, %4, 1b\n"	/* if the atomic operation failed, try again */
+		"	beq %0, %4, 1b\n"   /* if the atomic operation failed, try again */
 		"	nop\n"
 		: "=&r" (tmp), "+m" (val->count), "=&r" (v)
 		: "r" (i), "i" (0)
-		);
+	);
+	
+	return v;
+}
 
+static inline uint32_t test_and_set(atomic_t *val) {
+	uint32_t tmp, v;
+	
+	asm volatile (
+		"1:\n"
+		"	ll %2, %1\n"
+		"	bnez %2, 2f\n"
+		"	li %0, %3\n"
+		"	sc %0, %1\n"
+		"	beqz %0, 1b\n"
+		"2:\n"
+		: "=&r" (tmp), "+m" (val->count), "=&r" (v)
+		: "i" (1)
+	);
+	
 	return v;
 }
Index: kernel/arch/mips32/include/cpu.h
===================================================================
--- kernel/arch/mips32/include/cpu.h	(revision ae318d3535cba06a6996f270db31a961fae402ad)
+++ kernel/arch/mips32/include/cpu.h	(revision edd7aa6d2706f6923818608ee4bd2df91876ad58)
@@ -43,5 +43,5 @@
 	uint32_t rev_num;
 } cpu_arch_t;
-	
+
 #endif
 
Index: kernel/arch/mips32/include/interrupt.h
===================================================================
--- kernel/arch/mips32/include/interrupt.h	(revision ae318d3535cba06a6996f270db31a961fae402ad)
+++ kernel/arch/mips32/include/interrupt.h	(revision edd7aa6d2706f6923818608ee4bd2df91876ad58)
@@ -39,6 +39,8 @@
 #include <arch/exception.h>
 
-#define IVT_ITEMS 32
-#define IVT_FIRST 0
+#define IVT_ITEMS  32
+#define IVT_FIRST  0
+
+#define VECTOR_TLB_SHOOTDOWN_IPI  EXC_Int
 
 extern function virtual_timer_fnc;
Index: kernel/arch/mips32/include/smp/dorder.h
===================================================================
--- kernel/arch/mips32/include/smp/dorder.h	(revision edd7aa6d2706f6923818608ee4bd2df91876ad58)
+++ kernel/arch/mips32/include/smp/dorder.h	(revision edd7aa6d2706f6923818608ee4bd2df91876ad58)
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+#ifndef KERN_mips32_DORDER_H_
+#define KERN_mips32_DORDER_H_
+
+extern void ipi_broadcast_arch(int ipi);
+
+#endif
Index: kernel/arch/mips32/include/smp/order.h
===================================================================
--- kernel/arch/mips32/include/smp/order.h	(revision ae318d3535cba06a6996f270db31a961fae402ad)
+++ 	(revision )
@@ -1,34 +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.
- */
-
-#ifndef KERN_mips32_ORDER_H_
-#define KERN_mips32_ORDER_H_
-
-extern void ipi_broadcast_arch(int ipi);
-
-#endif
