Index: arch/amd64/Makefile.inc
===================================================================
--- arch/amd64/Makefile.inc	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/amd64/Makefile.inc	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -84,5 +84,4 @@
 
 ARCH_SOURCES = \
-	arch/$(ARCH)/src/dummy.s \
 	arch/$(ARCH)/src/fpu_context.c \
 	arch/$(ARCH)/src/boot/boot.S \
Index: ch/amd64/src/dummy.s
===================================================================
--- arch/amd64/src/dummy.s	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ 	(revision )
@@ -1,29 +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.
-#
-
-.text
Index: arch/ppc32/Makefile.inc
===================================================================
--- arch/ppc32/Makefile.inc	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/Makefile.inc	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -63,4 +63,5 @@
 	arch/$(ARCH)/src/dummy.s \
 	arch/$(ARCH)/src/exception.S \
+	arch/$(ARCH)/src/interrupt.c \
 	arch/$(ARCH)/src/asm.S \
 	arch/$(ARCH)/src/cpu/cpu.c \
Index: arch/ppc32/include/asm/regname.h
===================================================================
--- arch/ppc32/include/asm/regname.h	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/include/asm/regname.h	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -190,3 +190,7 @@
 #define	prv		287
 
+/* MSR bits */
+#define msr_ir	(1 << 4)
+#define msr_dr	(1 << 5)
+
 #endif
Index: ch/ppc32/include/asm/spr.h
===================================================================
--- arch/ppc32/include/asm/spr.h	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ 	(revision )
@@ -1,41 +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.
- */
-
-#ifndef __ppc32_SPR_H__
-#define __ppc32_SPR_H__
-
-#define MSR_IR (1 << 4)
-#define MSR_DR (1 << 5)
-
-#define SPRN_SRR0  0x1a
-#define SPRN_SRR1  0x1b
-
-/* Works for PPC32 */
-#define L1_CACHE_BYTES (1 << 5)
-
-#endif
Index: arch/ppc32/include/drivers/cuda.h
===================================================================
--- arch/ppc32/include/drivers/cuda.h	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/include/drivers/cuda.h	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -30,7 +30,8 @@
 #define __CUDA_H__
 
+#include <arch/types.h>
 
-void cuda_init(void);
-
+extern void cuda_init(void);
+extern void cuda_packet(const __u8 data);
 
 #endif
Index: arch/ppc32/include/interrupt.h
===================================================================
--- arch/ppc32/include/interrupt.h	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/include/interrupt.h	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -30,5 +30,10 @@
 #define __ppc32_INTERRUPT_H__
 
-extern void interrupt(void);
+#define IVT_ITEMS   15
+#define INT_OFFSET  0
+
+#define VECTOR_DECREMENTER 10
+
+extern void interrupt_init(void);
 
 #endif
Index: arch/ppc32/src/asm.S
===================================================================
--- arch/ppc32/src/asm.S	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/src/asm.S	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -32,4 +32,5 @@
 
 .global cpu_sleep
+.global iret
 .global memsetb
 .global memcpy
@@ -38,4 +39,59 @@
 	b cpu_sleep
 
+iret:
+	lwz r3, 144(sp)
+	mtxer r3
+	
+	lwz r3, 140(sp)
+	mtctr r3
+	
+	lwz r3, 136(sp)
+	mtcr r3
+	
+	lwz r3, 132(sp)
+	mtlr r3
+	
+	lwz r3, 128(sp)
+	mtspr srr1, r3
+	
+	lwz r3, 124(sp)
+	mtspr srr0, r3
+	
+	lwz r0, 0(sp)
+	lwz r2, 4(sp)
+	lwz r3, 8(sp)
+	lwz r4, 12(sp)
+	lwz r5, 16(sp)
+	lwz r6, 20(sp)
+	lwz r7, 24(sp)
+	lwz r8, 28(sp)
+	lwz r9, 32(sp)
+	lwz r10, 36(sp)
+	lwz r11, 40(sp)
+	lwz r12, 44(sp)
+	lwz r13, 48(sp)
+	lwz r14, 52(sp)
+	lwz r15, 56(sp)
+	lwz r16, 60(sp)
+	lwz r17, 64(sp)
+	lwz r18, 68(sp)
+	lwz r19, 72(sp)
+	lwz r20, 76(sp)
+	lwz r21, 80(sp)
+	lwz r22, 84(sp)
+	lwz r23, 88(sp)
+	lwz r24, 92(sp)
+	lwz r25, 96(sp)
+	lwz r26, 100(sp)
+	lwz r27, 104(sp)
+	lwz r28, 108(sp)
+	lwz r29, 112(sp)
+	lwz r30, 116(sp)
+	lwz r31, 120(sp)
+	
+	mfspr sp, sprg1
+	
+	rfi
+	
 memsetb:
 	rlwimi r5, r5, 8, 16, 23
Index: arch/ppc32/src/boot/boot.S
===================================================================
--- arch/ppc32/src/boot/boot.S	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/src/boot/boot.S	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -28,5 +28,4 @@
 
 #include <arch/asm/regname.h>
-#include <arch/asm/spr.h>
 #include <arch/boot/boot.h>
 #include <arch/boot/memmap.h>
Index: arch/ppc32/src/drivers/cuda.c
===================================================================
--- arch/ppc32/src/drivers/cuda.c	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/src/drivers/cuda.c	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -54,5 +54,5 @@
 
 
-static void cuda_packet(const __u8 data)
+void cuda_packet(const __u8 data)
 {
 	cuda[B] = cuda[B] | TIP;
@@ -70,6 +70,7 @@
 
 void cpu_halt(void) {
+#ifdef CONFIG_POWEROFF
 	cuda_packet(CUDA_POWERDOWN);
-	
+#endif
 	cpu_sleep();
 }
Index: arch/ppc32/src/exception.S
===================================================================
--- arch/ppc32/src/exception.S	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/src/exception.S	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -28,5 +28,5 @@
 
 #include <arch/asm/regname.h>
-#include <arch/asm/spr.h>
+#include <arch/mm/page.h>
 
 .section K_UNMAPPED_TEXT_START, "ax"
@@ -85,6 +85,74 @@
 .global exc_decrementer
 exc_decrementer:
+	mtspr sprg1, sp
+	
+	subis sp, sp, 0x8000
+	
+	subi sp, sp, 144
+	stw r0, 0(sp)
+	stw r2, 4(sp)
+	stw r3, 8(sp)
+	stw r4, 12(sp)
+	stw r5, 16(sp)
+	stw r6, 20(sp)
+	stw r7, 24(sp)
+	stw r8, 28(sp)
+	stw r9, 32(sp)
+	stw r10, 36(sp)
+	stw r11, 40(sp)
+	stw r12, 44(sp)
+	stw r13, 48(sp)
+	stw r14, 52(sp)
+	stw r15, 56(sp)
+	stw r16, 60(sp)
+	stw r17, 64(sp)
+	stw r18, 68(sp)
+	stw r19, 72(sp)
+	stw r20, 76(sp)
+	stw r21, 80(sp)
+	stw r22, 84(sp)
+	stw r23, 88(sp)
+	stw r24, 92(sp)
+	stw r25, 96(sp)
+	stw r26, 100(sp)
+	stw r27, 104(sp)
+	stw r28, 108(sp)
+	stw r29, 112(sp)
+	stw r30, 116(sp)
+	stw r31, 120(sp)
+	
+	mfspr r3, srr0
+	stw r3, 124(sp)
+	
+	mfspr r3, srr1
+	stw r3, 128(sp)
+	
+	mflr r3
+	stw r3, 132(sp)
+	
+	mfcr r3
+	stw r3, 136(sp)
+	
+	mfctr r3
+	stw r3, 140(sp)
+	
+	mfxer r3
+	stw r3, 144(sp)
+
+	lis r3, exc_dispatch@ha
+	addi r3, r3, exc_dispatch@l
+	mtspr srr0, r3
+	
+	mfmsr r3
+	ori r3, r3, (msr_ir | msr_dr)@l
+	mtspr srr1, r3
+	
+	lis r3, iret@ha
+	addi r3, r3, iret@l
+	mtlr r3
+	
+	addis sp, sp, 0x8000
+	li r3, 10
 	rfi
-	b exc_decrementer
 
 .org 0xa00
Index: arch/ppc32/src/interrupt.c
===================================================================
--- arch/ppc32/src/interrupt.c	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
+++ arch/ppc32/src/interrupt.c	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2006 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <interrupt.h>
+#include <arch/interrupt.h>
+#include <arch/types.h>
+#include <arch.h>
+#include <time/clock.h>
+#include <print.h>
+
+static void exception_decrementer(int n, istate_t *istate)
+{
+	clock();
+}
+
+
+/* Initialize basic tables for exception dispatching */
+void interrupt_init(void)
+{
+	exc_register(VECTOR_DECREMENTER, "timer", exception_decrementer);
+}
Index: arch/ppc32/src/ppc32.c
===================================================================
--- arch/ppc32/src/ppc32.c	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/src/ppc32.c	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -31,7 +31,11 @@
 #include <arch/drivers/cuda.h>
 #include <arch/mm/memory_init.h>
+#include <arch/interrupt.h>
 
 void arch_pre_mm_init(void)
 {
+	/* Initialize dispatch table */
+	interrupt_init();	
+
 	ppc32_console_init();
 	cuda_init();
Index: arch/ppc32/src/proc/scheduler.c
===================================================================
--- arch/ppc32/src/proc/scheduler.c	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ arch/ppc32/src/proc/scheduler.c	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -27,8 +27,16 @@
  */
 
+#include <arch/mm/page.h>
 #include <proc/scheduler.h>
+#include <proc/thread.h>
+#include <arch.h>
+
+__address supervisor_sp;
+__address supervisor_sp_physical;
 
 void before_thread_runs_arch(void)
 {
+	supervisor_sp = (__address) &THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA];
+	supervisor_sp_physical = KA2PA(supervisor_sp_physical);
 }
 
Index: kernel.config
===================================================================
--- kernel.config	(revision d1e414c63e2033f906d3c12947392b421a0998d6)
+++ kernel.config	(revision 91d5ad627944c61ab128cd4a6e7fa14a370648d5)
@@ -60,4 +60,7 @@
 ! [(ARCH=mips32&MIPS_MACHINE!=msim&MIPS_MACHINE!=simics)|ARCH=amd64|ARCH=ia32] CONFIG_FPU_LAZY (y/n)
 
+# Power off on halt
+! [ARCH=ppc32] CONFIG_POWEROFF (y/n)
+
 ## Debugging configuration directives
 
