Index: arch/ppc32/Makefile.inc
===================================================================
--- arch/ppc32/Makefile.inc	(revision 7f6e755b66aa78968eca1b1d352fb8316da04312)
+++ arch/ppc32/Makefile.inc	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -39,4 +39,5 @@
 #
 
+CFLAGS += -mcpu=powerpc -m32
 LFLAGS += -no-check-sections -N
 
@@ -46,5 +47,4 @@
 #
 
-CONFIG_OFW = y
 CONFIG_FB = y
 
Index: arch/ppc64/Makefile.inc
===================================================================
--- arch/ppc64/Makefile.inc	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/Makefile.inc	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,73 @@
+#
+# 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.
+#
+
+## Toolchain configuration
+#
+
+BFD_NAME = elf64-powerpc
+BFD_ARCH = powerpc
+BFD = binary
+TARGET = ppc-linux-gnu
+TOOLCHAIN_DIR = /usr/local/ppc/bin
+
+## Make some default assumptions
+#
+
+CFLAGS += -mcpu=powerpc64 -m64
+LFLAGS += -no-check-sections -N
+
+DEFS += -D__64_BITS__
+
+## Own configuration directives
+#
+
+CONFIG_FB = y
+
+## Compile with hierarchical page tables support.
+#
+
+CONFIG_PAGE_PT = y
+DEFS += -DCONFIG_PAGE_PT
+
+ARCH_SOURCES = \
+	arch/$(ARCH)/src/console.c \
+	arch/$(ARCH)/src/context.S \
+	arch/$(ARCH)/src/debug/panic.s \
+	arch/$(ARCH)/src/fpu_context.S \
+	arch/$(ARCH)/src/boot/boot.S \
+	arch/$(ARCH)/src/ppc64.c \
+	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 \
+	arch/$(ARCH)/src/proc/scheduler.c \
+	arch/$(ARCH)/src/mm/as.c \
+	arch/$(ARCH)/src/mm/frame.c \
+	arch/$(ARCH)/src/mm/memory_init.c \
+	arch/$(ARCH)/src/mm/page.c 
Index: arch/ppc64/_link.ld.in
===================================================================
--- arch/ppc64/_link.ld.in	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/_link.ld.in	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,57 @@
+/** PPC64 linker script
+ *
+ * umapped section:
+ * 	kernel text
+ * 	kernel data
+ * mapped section:
+ *	kernel text
+ *	kernel data 
+ *
+ */
+
+#define __ASM__
+#include <arch/boot/boot.h>
+#include <arch/mm/page.h>
+
+ENTRY(kernel_image_start)
+
+SECTIONS {
+	.unmapped 0: AT (0) {
+		unmapped_ktext_start = .;
+		*(K_UNMAPPED_TEXT_START);
+		unmapped_ktext_end = .;
+		
+		unmapped_kdata_start = .;
+		*(K_UNMAPPED_DATA_START);
+		unmapped_kdata_start = .;
+	}
+	
+	.mapped PA2KA(BOOT_OFFSET): AT (BOOT_OFFSET) { 
+		ktext_start = .;
+		*(K_TEXT_START);
+		*(.text);
+		ktext_end = .;
+		
+		kdata_start = .;
+		*(K_DATA_START);
+		*(.rodata);
+		*(.rodata.*);
+		*(.data);		/* initialized data */
+		*(.sdata);
+		*(.sdata2);
+		*(.sbss);
+		hardcoded_ktext_size = .;
+		LONG(ktext_end - ktext_start);	
+		hardcoded_kdata_size = .;
+		LONG(kdata_end - kdata_start);
+		hardcoded_load_address = .;
+		LONG(PA2KA(BOOT_OFFSET));
+		*(.bss);		/* uninitialized static variables */	
+		*(COMMON); 		/* global variables */
+
+		symbol_table = .;
+		*(symtab.*);            /* Symbol table, must be LAST symbol!*/
+
+		kdata_end = .;
+	}
+}
Index: arch/ppc64/include/arch.h
===================================================================
--- arch/ppc64/include/arch.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/arch.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_ARCH_H__
+#define __ppc64_ARCH_H__
+
+#endif
Index: arch/ppc64/include/arg.h
===================================================================
--- arch/ppc64/include/arg.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/arg.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_ARG_H__
+#define __ppc64_ARG_H__
+
+#include <stdarg.h>
+
+#endif
Index: arch/ppc64/include/asm.h
===================================================================
--- arch/ppc64/include/asm.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/asm.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_ASM_H__
+#define __ppc64_ASM_H__
+
+#include <arch/types.h>
+#include <config.h>
+
+/** Enable interrupts.
+ *
+ * Enable interrupts and return previous
+ * value of EE.
+ *
+ * @return Old interrupt priority level.
+ */
+static inline ipl_t interrupts_enable(void) {
+	ipl_t v;
+	ipl_t tmp;
+	
+	__asm__ volatile (
+		"mfmsr %0\n"
+		"mfmsr %1\n"
+		"ori %1, %1, 1 << 15\n"
+		"mtmsr %1\n"
+		: "=r" (v), "=r" (tmp)
+	);
+	return v;
+}
+
+/** Disable interrupts.
+ *
+ * Disable interrupts and return previous
+ * value of EE.
+ *
+ * @return Old interrupt priority level.
+ */
+static inline ipl_t interrupts_disable(void) {
+	ipl_t v;
+	ipl_t tmp;
+	
+	__asm__ volatile (
+		"mfmsr %0\n"
+		"mfmsr %1\n"
+		"rlwinm %1, %1, 0, 17, 15\n"
+		"mtmsr %1\n"
+		: "=r" (v), "=r" (tmp)
+	);
+	return v;
+}
+
+/** Restore interrupt priority level.
+ *
+ * Restore EE.
+ *
+ * @param ipl Saved interrupt priority level.
+ */
+static inline void interrupts_restore(ipl_t ipl) {
+	ipl_t tmp;
+	
+	__asm__ volatile (
+		"mfmsr %1\n"
+		"rlwimi  %0, %1, 0, 17, 15\n"
+		"cmpw 0, %0, %1\n"
+		"beq 0f\n"
+		"mtmsr %0\n"
+		"0:\n"
+		: "=r" (ipl), "=r" (tmp)
+		: "0" (ipl)
+	);
+}
+
+/** Return interrupt priority level.
+ *
+ * Return EE.
+ *
+ * @return Current interrupt priority level.
+ */
+static inline ipl_t interrupts_read(void) {
+	ipl_t v;
+	__asm__ volatile (
+		"mfmsr %0\n"
+		: "=r" (v)
+	);
+	return v;
+}
+
+/** Return base address of current stack.
+ *
+ * Return the base address of the current stack.
+ * The stack is assumed to be STACK_SIZE bytes long.
+ * The stack must start on page boundary.
+ */
+static inline __address get_stack_base(void)
+{
+	__address v;
+	
+	__asm__ volatile ("and %0, %%sp, %1\n" : "=r" (v) : "r" (~(STACK_SIZE-1)));
+	
+	return v;
+}
+
+static inline void cpu_sleep(void)
+{
+}
+
+void cpu_halt(void);
+void asm_delay_loop(__u32 t);
+
+#endif
Index: arch/ppc64/include/asm/regname.h
===================================================================
--- arch/ppc64/include/asm/regname.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/asm/regname.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_REGNAME_H__
+#define __ppc64_REGNAME_H__
+
+/* Condition Register Bit Fields */
+#define	cr0	0
+#define	cr1	1
+#define	cr2	2
+#define	cr3	3
+#define	cr4	4
+#define	cr5	5
+#define	cr6	6
+#define	cr7	7
+
+/* General Purpose Registers (GPRs) */
+#define	r0	0
+#define	r1	1
+#define	r2	2
+#define	r3	3
+#define	r4	4
+#define	r5	5
+#define	r6	6
+#define	r7	7
+#define	r8	8
+#define	r9	9
+#define	r10	10
+#define	r11	11
+#define	r12	12
+#define	r13	13
+#define	r14	14
+#define	r15	15
+#define	r16	16
+#define	r17	17
+#define	r18	18
+#define	r19	19
+#define	r20	20
+#define	r21	21
+#define	r22	22
+#define	r23	23
+#define	r24	24
+#define	r25	25
+#define	r26	26
+#define	r27	27
+#define	r28	28
+#define	r29	29
+#define	r30	30
+#define	r31	31
+
+/* GPR Aliases */
+#define	sp	1
+
+/* Floating Point Registers (FPRs) */
+#define	fr0		0
+#define	fr1		1
+#define	fr2		2
+#define	fr3		3
+#define	fr4		4
+#define	fr5		5
+#define	fr6		6
+#define	fr7		7
+#define	fr8		8
+#define	fr9		9
+#define	fr10	10
+#define	fr11	11
+#define	fr12	12
+#define	fr13	13
+#define	fr14	14
+#define	fr15	15
+#define	fr16	16
+#define	fr17	17
+#define	fr18	18
+#define	fr19	19
+#define	fr20	20
+#define	fr21	21
+#define	fr22	22
+#define	fr23	23
+#define	fr24	24
+#define	fr25	25
+#define	fr26	26
+#define	fr27	27
+#define	fr28	28
+#define	fr29	29
+#define	fr30	30
+#define	fr31	31
+
+#define	vr0		0
+#define	vr1		1
+#define	vr2		2
+#define	vr3		3
+#define	vr4		4
+#define	vr5		5
+#define	vr6		6
+#define	vr7		7
+#define	vr8		8
+#define	vr9		9
+#define	vr10	10
+#define	vr11	11
+#define	vr12	12
+#define	vr13	13
+#define	vr14	14
+#define	vr15	15
+#define	vr16	16
+#define	vr17	17
+#define	vr18	18
+#define	vr19	19
+#define	vr20	20
+#define	vr21	21
+#define	vr22	22
+#define	vr23	23
+#define	vr24	24
+#define	vr25	25
+#define	vr26	26
+#define	vr27	27
+#define	vr28	28
+#define	vr29	29
+#define	vr30	30
+#define	vr31	31
+
+#define	evr0	0
+#define	evr1	1
+#define	evr2	2
+#define	evr3	3
+#define	evr4	4
+#define	evr5	5
+#define	evr6	6
+#define	evr7	7
+#define	evr8	8
+#define	evr9	9
+#define	evr10	10
+#define	evr11	11
+#define	evr12	12
+#define	evr13	13
+#define	evr14	14
+#define	evr15	15
+#define	evr16	16
+#define	evr17	17
+#define	evr18	18
+#define	evr19	19
+#define	evr20	20
+#define	evr21	21
+#define	evr22	22
+#define	evr23	23
+#define	evr24	24
+#define	evr25	25
+#define	evr26	26
+#define	evr27	27
+#define	evr28	28
+#define	evr29	29
+#define	evr30	30
+#define	evr31	31
+
+/* Special Purpose Registers (SPRs) */
+#define	xer		1
+#define lr		8
+#define ctr		9
+#define	dec		22
+#define	sdr1	25
+#define	srr0	26
+#define srr1	27
+#define	sprg0	272
+#define	sprg1	273
+#define	sprg2	274
+#define	sprg3	275
+#define	prv		287
+#define hid0	1008
+
+/* MSR bits */
+#define msr_ir	(1 << 4)
+#define msr_dr	(1 << 5)
+
+/* HID0 bits */
+#define hid0_ice	(1 << 15)
+#define hid0_dce	(1 << 14)
+#define hid0_icfi	(1 << 11)
+#define hid0_dci	(1 << 10)
+
+#endif
Index: arch/ppc64/include/atomic.h
===================================================================
--- arch/ppc64/include/atomic.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/atomic.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_ATOMIC_H__
+#define __ppc64_ATOMIC_H__
+
+static inline void atomic_inc(atomic_t *val)
+{
+	long tmp;
+
+	asm __volatile__ (
+		"1:\n"
+		"lwarx %0, 0, %2\n"
+		"addic %0, %0, 1\n"
+		"stwcx. %0, 0, %2\n"
+		"bne- 1b"
+		: "=&r" (tmp), "=m" (val->count)
+		: "r" (&val->count), "m" (val->count)
+		: "cc");
+}
+
+static inline void atomic_dec(atomic_t *val)
+{
+	long tmp;
+
+	asm __volatile__(
+		"1:\n"
+		"lwarx %0, 0, %2\n"
+		"addic %0, %0, -1\n"
+		"stwcx.	%0, 0, %2\n"
+		"bne- 1b"
+		: "=&r" (tmp), "=m" (val->count)
+		: "r" (&val->count), "m" (val->count)
+		: "cc");
+}
+
+static inline long atomic_postinc(atomic_t *val)
+{
+	atomic_inc(val);
+	return val->count - 1;
+}
+
+static inline long atomic_postdec(atomic_t *val)
+{
+	atomic_dec(val);
+	return val->count + 1;
+}
+
+static inline long atomic_preinc(atomic_t *val)
+{
+	atomic_inc(val);
+	return val->count;
+}
+
+static inline long atomic_predec(atomic_t *val)
+{
+	atomic_dec(val);
+	return val->count;
+}
+
+#endif
Index: arch/ppc64/include/barrier.h
===================================================================
--- arch/ppc64/include/barrier.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/barrier.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_BARRIER_H__
+#define __ppc64_BARRIER_H__
+
+#define CS_ENTER_BARRIER()	__asm__ volatile ("" ::: "memory")
+#define CS_LEAVE_BARRIER()	__asm__ volatile ("" ::: "memory")
+
+#define memory_barrier() __asm__ volatile ("sync" ::: "memory")
+#define read_barrier() __asm__ volatile ("sync" ::: "memory")
+#define write_barrier() __asm__ volatile ("eieio" ::: "memory")
+
+#endif
Index: arch/ppc64/include/boot/boot.h
===================================================================
--- arch/ppc64/include/boot/boot.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/boot/boot.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_BOOT_H__
+#define __ppc64_BOOT_H__
+
+#define BOOT_OFFSET		0x4000
+
+/* Temporary stack size for boot process */
+#define TEMP_STACK_SIZE 0x100
+
+#define MEMMAP_MAX_RECORDS 32
+
+#ifndef __ASM__
+
+#include <arch/types.h>
+
+typedef struct {
+	__address start;
+	__u32 size;
+} memzone_t;
+
+typedef struct {
+	__u32 total;
+	__u32 count;
+	memzone_t zones[MEMMAP_MAX_RECORDS];
+} memmap_t;
+
+typedef struct {
+	__address addr;
+	unsigned int width;
+	unsigned int height;
+	unsigned int bpp;
+	unsigned int scanline;
+} screen_t;
+
+typedef struct {
+	memmap_t memmap;
+	screen_t screen;
+} bootinfo_t;
+
+extern bootinfo_t bootinfo;
+
+#endif
+
+#endif
Index: arch/ppc64/include/byteorder.h
===================================================================
--- arch/ppc64/include/byteorder.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/byteorder.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_BYTEORDER_H__
+#define __ppc64_BYTEORDER_H__
+
+#include <arch/types.h>
+#include <byteorder.h>
+
+static inline __u64 __u64_le2host(__u64 n)
+{
+	return __u64_byteorder_swap(n);
+}
+
+
+/** Convert little-endian __native to host __native
+ *
+ * Convert little-endian __native parameter to host endianess.
+ *
+ * @param n Little-endian __native argument.
+ *
+ * @return Result in host endianess.
+ *
+ */
+static inline __native __native_le2host(__native n)
+{
+	__address v;
+	
+	__asm__ volatile ("lwbrx %0, %1, %2\n" : "=r" (v) : "i" (0) , "r" (&n));
+	
+	return v;
+}
+#endif
Index: arch/ppc64/include/console.h
===================================================================
--- arch/ppc64/include/console.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/console.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_CONSOLE_H__
+#define __ppc64_CONSOLE_H__
+
+extern void ppc64_console_init(void);
+
+#endif
Index: arch/ppc64/include/context.h
===================================================================
--- arch/ppc64/include/context.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/context.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_CONTEXT_H__
+#define __ppc64_CONTEXT_H__
+
+#ifndef __ppc64_TYPES_H__
+# include <arch/types.h>
+#endif
+
+#define SP_DELTA	16
+
+struct context {
+	__address sp;
+	__address pc;
+	
+	__u64 r2;
+	__u64 r13;
+	__u64 r14;
+	__u64 r15;
+	__u64 r16;
+	__u64 r17;
+	__u64 r18;
+	__u64 r19;
+	__u64 r20;
+	__u64 r21;
+	__u64 r22;
+	__u64 r23;
+	__u64 r24;
+	__u64 r25;
+	__u64 r26;
+	__u64 r27;
+	__u64 r28;
+	__u64 r29;
+	__u64 r30;
+	__u64 r31;
+	
+	__u64 cr;
+	
+	ipl_t ipl;
+} __attribute__ ((packed));
+
+#endif
Index: arch/ppc64/include/context_offset.h
===================================================================
--- arch/ppc64/include/context_offset.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/context_offset.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,45 @@
+/* This file is automatically generated by gencontext.c. */
+/* struct context */
+#define OFFSET_SP    0x0
+#define OFFSET_PC    0x8
+#define OFFSET_R2    0x10
+#define OFFSET_R13   0x18
+#define OFFSET_R14   0x20
+#define OFFSET_R15   0x28
+#define OFFSET_R16   0x30
+#define OFFSET_R17   0x38
+#define OFFSET_R18   0x40
+#define OFFSET_R19   0x48
+#define OFFSET_R20   0x50
+#define OFFSET_R21   0x58
+#define OFFSET_R22   0x60
+#define OFFSET_R23   0x68
+#define OFFSET_R24   0x70
+#define OFFSET_R25   0x78
+#define OFFSET_R26   0x80
+#define OFFSET_R27   0x88
+#define OFFSET_R28   0x90
+#define OFFSET_R29   0x98
+#define OFFSET_R30   0xa0
+#define OFFSET_R31   0xa8
+#define OFFSET_CR    0xb0
+
+#define OFFSET_FR14  0x0
+#define OFFSET_FR15  0x8
+#define OFFSET_FR16  0x10
+#define OFFSET_FR17  0x18
+#define OFFSET_FR18  0x20
+#define OFFSET_FR19  0x28
+#define OFFSET_FR20  0x30
+#define OFFSET_FR21  0x38
+#define OFFSET_FR22  0x40
+#define OFFSET_FR23  0x48
+#define OFFSET_FR24  0x50
+#define OFFSET_FR25  0x58
+#define OFFSET_FR26  0x60
+#define OFFSET_FR27  0x68
+#define OFFSET_FR28  0x70
+#define OFFSET_FR29  0x78
+#define OFFSET_FR30  0x80
+#define OFFSET_FR31  0x88
+#define OFFSET_FPSCR 0x90
Index: arch/ppc64/include/cpu.h
===================================================================
--- arch/ppc64/include/cpu.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/cpu.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_CPU_H__
+#define __ppc64_CPU_H__
+
+#include <typedefs.h>
+
+struct cpu_arch {
+	int version;
+	int revision;
+};
+	
+#endif
Index: arch/ppc64/include/cpuid.h
===================================================================
--- arch/ppc64/include/cpuid.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/cpuid.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_CPUID_H__
+#define __ppc64_CPUID_H__
+
+#include <arch/types.h>
+
+struct cpu_info {
+	__u16 version;
+	__u16 revision;
+} __attribute__ ((packed));
+
+static inline void cpu_version(struct cpu_info *info)
+{
+	__asm__ volatile (
+		"mfspr %0, 287\n"
+		: "=r" (*info)
+	);
+}
+
+#endif
Index: arch/ppc64/include/debug.h
===================================================================
--- arch/ppc64/include/debug.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/debug.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2005 
+ * 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 __ppc64_DEBUG_H__
+#define __ppc64_DEBUG_H__
+
+#endif
Index: arch/ppc64/include/elf.h
===================================================================
--- arch/ppc64/include/elf.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/elf.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_ELF_H__
+#define __ppc64_ELF_H__
+
+#define	ELF_MACHINE		EM_PPC
+#define ELF_DATA_ENCODING	ELFDATA2MSB
+#define ELF_CLASS		ELFCLASS32
+
+#endif
Index: arch/ppc64/include/faddr.h
===================================================================
--- arch/ppc64/include/faddr.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/faddr.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_FADDR_H__
+#define __ppc64_FADDR_H__
+
+#include <arch/types.h>
+
+#define FADDR(fptr)		((__address) (fptr))
+
+#endif
Index: arch/ppc64/include/fpu_context.h
===================================================================
--- arch/ppc64/include/fpu_context.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/fpu_context.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_FPU_CONTEXT_H__
+#define __ppc64_FPU_CONTEXT_H__
+
+#ifndef __ppc64_TYPES_H__
+# include <arch/types.h>
+#endif
+
+struct fpu_context {
+	__u64 fr14;
+	__u64 fr15;
+	__u64 fr16;
+	__u64 fr17;
+	__u64 fr18;
+	__u64 fr19;
+	__u64 fr20;
+	__u64 fr21;
+	__u64 fr22;
+	__u64 fr23;
+	__u64 fr24;
+	__u64 fr25;
+	__u64 fr26;
+	__u64 fr27;
+	__u64 fr28;
+	__u64 fr29;
+	__u64 fr30;
+	__u64 fr31;
+	__u32 fpscr;
+} __attribute__ ((packed));
+
+#endif
Index: arch/ppc64/include/interrupt.h
===================================================================
--- arch/ppc64/include/interrupt.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/interrupt.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_INTERRUPT_H__
+#define __ppc64_INTERRUPT_H__
+
+#define IVT_ITEMS   15
+#define INT_OFFSET  0
+
+#define VECTOR_DECREMENTER 10
+
+extern void start_decrementer(void);
+extern void interrupt_init(void);
+
+#endif
Index: arch/ppc64/include/memstr.h
===================================================================
--- arch/ppc64/include/memstr.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/memstr.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2005 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.
+ */
+
+#ifndef __ppc64_MEMSTR_H__
+#define __ppc64_MEMSTR_H__
+
+#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
+
+extern void memsetw(__address dst, size_t cnt, __u16 x);
+extern void memsetb(__address dst, size_t cnt, __u8 x);
+
+extern int memcmp(__address src, __address dst, int cnt);
+
+#endif
Index: arch/ppc64/include/mm/as.h
===================================================================
--- arch/ppc64/include/mm/as.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/mm/as.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_AS_H__
+#define __ppc64_AS_H__
+
+#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH	0
+
+#define KERNEL_ADDRESS_SPACE_START_ARCH		((__address) 0x80000000)
+#define KERNEL_ADDRESS_SPACE_END_ARCH		((__address) 0xffffffff)
+#define USER_ADDRESS_SPACE_START_ARCH		((__address) 0x00000000)
+#define USER_ADDRESS_SPACE_END_ARCH		((__address) 0x7fffffff)
+
+#define USTACK_ADDRESS_ARCH	(0x7fffffff-(PAGE_SIZE-1))
+
+#define as_install_arch(as)
+
+extern void as_arch_init(void);
+
+#endif
Index: arch/ppc64/include/mm/asid.h
===================================================================
--- arch/ppc64/include/mm/asid.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/mm/asid.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_ASID_H__
+#define __ppc64_ASID_H__
+
+typedef int asid_t;
+
+#define ASID_MAX_ARCH	3
+
+#define asid_get()	(ASID_START+1)
+
+#endif
Index: arch/ppc64/include/mm/frame.h
===================================================================
--- arch/ppc64/include/mm/frame.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/mm/frame.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_FRAME_H__
+#define __ppc64_FRAME_H__
+
+#define FRAME_WIDTH		12	/* 4K */
+#define FRAME_SIZE		(1<<FRAME_WIDTH)
+
+#ifdef KERNEL
+#ifndef __ASM__
+
+extern void frame_arch_init(void);
+
+#endif /* __ASM__ */
+#endif /* KERNEL */
+
+#endif
Index: arch/ppc64/include/mm/memory_init.h
===================================================================
--- arch/ppc64/include/mm/memory_init.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/mm/memory_init.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_MEMORY_INIT_H__
+#define __ppc64_MEMORY_INIT_H__
+
+#include <typedefs.h>
+
+size_t get_memory_size(void);
+
+void memory_print_map(void);
+
+#endif
Index: arch/ppc64/include/mm/page.h
===================================================================
--- arch/ppc64/include/mm/page.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/mm/page.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_PAGE_H__
+#define __ppc64_PAGE_H__
+
+#include <arch/mm/frame.h>
+
+#define PAGE_WIDTH	FRAME_WIDTH
+#define PAGE_SIZE	FRAME_SIZE
+
+#ifdef KERNEL
+
+#ifndef __ASM__
+#	define KA2PA(x)	(((__address) (x)) - 0x80000000)
+#	define PA2KA(x)	(((__address) (x)) + 0x80000000)
+#else
+#	define KA2PA(x)	((x) - 0x80000000)
+#	define PA2KA(x)	((x) + 0x80000000)
+#endif
+
+#define PTL0_ENTRIES_ARCH		0
+#define PTL1_ENTRIES_ARCH		0
+#define PTL2_ENTRIES_ARCH		0
+#define PTL3_ENTRIES_ARCH		0
+
+#define PTL0_INDEX_ARCH(vaddr)		0
+#define PTL1_INDEX_ARCH(vaddr)		0
+#define PTL2_INDEX_ARCH(vaddr)		0
+#define PTL3_INDEX_ARCH(vaddr)		0
+
+#define SET_PTL0_ADDRESS_ARCH(ptl0)
+
+#define GET_PTL1_ADDRESS_ARCH(ptl0, i)		((pte_t *) 0)
+#define GET_PTL2_ADDRESS_ARCH(ptl1, i)		((pte_t *) 0)
+#define GET_PTL3_ADDRESS_ARCH(ptl2, i)		((pte_t *) 0)
+#define GET_FRAME_ADDRESS_ARCH(ptl3, i)		((pte_t *) 0)
+
+#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a)
+#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
+#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
+#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a)
+
+#define GET_PTL1_FLAGS_ARCH(ptl0, i)		0
+#define GET_PTL2_FLAGS_ARCH(ptl1, i)		0
+#define GET_PTL3_FLAGS_ARCH(ptl2, i)		0
+#define GET_FRAME_FLAGS_ARCH(ptl3, i)		0
+
+#define SET_PTL1_FLAGS_ARCH(ptl0, i, x)
+#define SET_PTL2_FLAGS_ARCH(ptl1, i, x)
+#define SET_PTL3_FLAGS_ARCH(ptl2, i, x)
+#define SET_FRAME_FLAGS_ARCH(ptl3, i, x)
+
+#define PTE_VALID_ARCH(p)		1
+#define PTE_PRESENT_ARCH(p)		1
+#define PTE_GET_FRAME_ARCH(p)		0
+
+#ifndef __ASM__
+
+#include <mm/page.h>
+#include <arch/mm/frame.h>
+#include <arch/types.h>
+
+extern void page_arch_init(void);
+
+#endif /* __ASM__ */
+
+#endif /* KERNEL */
+
+#endif
Index: arch/ppc64/include/mm/tlb.h
===================================================================
--- arch/ppc64/include/mm/tlb.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/mm/tlb.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_TLB_H__
+#define __ppc64_TLB_H__
+
+#define tlb_arch_init()
+#define tlb_print()
+
+#endif
Index: arch/ppc64/include/thread.h
===================================================================
--- arch/ppc64/include/thread.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/thread.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2005 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 __ppc64_THREAD_H__
+#define __ppc64_THREAD_H__
+
+#define ARCH_THREAD_DATA
+
+#endif
Index: arch/ppc64/include/types.h
===================================================================
--- arch/ppc64/include/types.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/include/types.h	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc64_TYPES_H__
+#define __ppc64_TYPES_H__
+
+#define NULL 0
+
+typedef signed char __s8;
+typedef signed short __s16;
+typedef signed long __s32;
+typedef signed long long __s64;
+
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+typedef unsigned long __u32;
+typedef unsigned long long __u64;
+
+typedef __u64 __address;
+typedef __u32 pfn_t;
+
+typedef __u64 ipl_t;
+
+typedef __u64 __native;
+
+typedef __u32 pte_t;
+
+#endif
Index: arch/ppc64/src/asm.S
===================================================================
--- arch/ppc64/src/asm.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/asm.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,195 @@
+#
+# 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 <arch/asm/regname.h>
+
+.text
+
+.global iret
+.global memsetb
+.global memcpy
+
+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
+	rlwimi r5, r5, 16, 0, 15
+	
+	addi r14, r3, -4
+	
+	cmplwi 0, r4, 4
+	blt 7f
+	
+	stwu r5, 4(r14)
+	beqlr
+	
+	andi. r15, r14, 3
+	add r4, r15, r4
+	subf r14, r15, r14
+	srwi r15, r4, 2
+	mtctr r15
+	
+	bdz 6f
+	
+	1:
+		stwu r5, 4(r14)
+		bdnz 1b
+	
+	6:
+	
+	andi. r4, r4, 3
+	
+	7:
+	
+	cmpwi 0, r4, 0
+	beqlr
+	
+	mtctr r4
+	addi r6, r6, 3
+	
+	8:
+	
+	stbu r5, 1(r14)
+	bdnz 8b
+	
+	blr
+
+memcpy:
+	srwi. r7, r5, 3
+	addi r6, r3, -4
+	addi r4, r4, -4
+	beq	2f
+	
+	andi. r0, r6, 3
+	mtctr r7
+	bne 5f
+	
+	1:
+	
+	lwz r7, 4(r4)
+	lwzu r8, 8(r4)
+	stw r7, 4(r6)
+	stwu r8, 8(r6)
+	bdnz 1b
+	
+	andi. r5, r5, 7
+	
+	2:
+	
+	cmplwi 0, r5, 4
+	blt 3f
+	
+	lwzu r0, 4(r4)
+	addi r5, r5, -4
+	stwu r0, 4(r6)
+	
+	3:
+	
+	cmpwi 0, r5, 0
+	beqlr
+	mtctr r5
+	addi r4, r4, 3
+	addi r6, r6, 3
+	
+	4:
+	
+	lbzu r0, 1(r4)
+	stbu r0, 1(r6)
+	bdnz 4b
+	blr
+	
+	5:
+	
+	subfic r0, r0, 4
+	mtctr r0
+	
+	6:
+	
+	lbz r7, 4(r4)
+	addi r4, r4, 1
+	stb r7, 4(r6)
+	addi r6, r6, 1
+	bdnz 6b
+	subf r5, r0, r5
+	rlwinm. r7, r5, 32-3, 3, 31
+	beq 2b
+	mtctr r7
+	b 1b
Index: arch/ppc64/src/boot/boot.S
===================================================================
--- arch/ppc64/src/boot/boot.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/boot/boot.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,75 @@
+#
+# 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 <arch/asm/regname.h>
+#include <arch/boot/boot.h>
+
+.section K_TEXT_START, "ax"
+
+.global kernel_image_start
+kernel_image_start:
+
+	# load temporary stack
+	
+	lis sp, end_stack@ha
+	addi sp, sp, end_stack@l
+	
+	# r3 contains physical address of bootinfo_t
+	# r4 contains size of bootinfo_t
+	
+	lis r31, 0x80000000@ha
+	addi r31, r31, 0x80000000@l
+	
+	add r3, r3, r31
+
+	lis r31, bootinfo@ha
+	addi r31, r31, bootinfo@l  # r31 = bootinfo
+	
+	cmpwi r4, 0
+	beq bootinfo_end
+	
+	bootinfo_loop:
+		
+		lwz r30, 0(r3)
+		stw r30, 0(r31)
+		
+		addi r3, r3, 4
+		addi r31, r31, 4
+		subi r4, r4, 4
+		
+		cmpwi r4, 0
+		bgt bootinfo_loop
+		
+	bootinfo_end:
+	
+	b main_bsp
+
+.section K_DATA_START, "aw", @progbits
+
+	.space TEMP_STACK_SIZE
+end_stack:
Index: arch/ppc64/src/console.c
===================================================================
--- arch/ppc64/src/console.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/console.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,41 @@
+/*
+ * 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 <arch/boot/boot.h>
+#include <arch/console.h>
+#include <console/chardev.h>
+#include <console/console.h>
+#include <genarch/fb/fb.h>
+
+
+/** Initialize console to use frame buffer. */
+void ppc64_console_init(void)
+{
+	/* TODO: Framebuffer mapping */
+	fb_init(0xf0000000 + (bootinfo.screen.addr & ((__address) ~0 >> 15)), bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
+}
Index: arch/ppc64/src/context.S
===================================================================
--- arch/ppc64/src/context.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/context.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2005 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 <arch/asm/regname.h>
+#include <arch/context_offset.h>
+
+.text   
+
+.global context_save_arch
+.global context_restore_arch
+
+.macro CONTEXT_STORE r
+	stw sp, OFFSET_SP(\r)
+	stw r2, OFFSET_R2(\r)
+	stw r13, OFFSET_R13(\r)
+	stw r14, OFFSET_R14(\r)
+	stw r15, OFFSET_R15(\r)
+	stw r16, OFFSET_R16(\r)
+	stw r17, OFFSET_R17(\r)
+	stw r18, OFFSET_R18(\r)
+	stw r19, OFFSET_R19(\r)
+	stw r20, OFFSET_R20(\r)
+	stw r21, OFFSET_R21(\r)
+	stw r22, OFFSET_R22(\r)
+	stw r23, OFFSET_R23(\r)
+	stw r24, OFFSET_R24(\r)
+	stw r25, OFFSET_R25(\r)
+	stw r26, OFFSET_R26(\r)
+	stw r27, OFFSET_R27(\r)
+	stw r28, OFFSET_R28(\r)
+	stw r29, OFFSET_R29(\r)
+	stw r30, OFFSET_R30(\r)
+	stw r31, OFFSET_R31(\r)
+.endm
+
+.macro CONTEXT_LOAD r
+	lwz sp, OFFSET_SP(\r)
+	lwz r2, OFFSET_R2(\r)
+	lwz r13, OFFSET_R13(\r)
+	lwz r14, OFFSET_R14(\r)
+	lwz r15, OFFSET_R15(\r)
+	lwz r16, OFFSET_R16(\r)
+	lwz r17, OFFSET_R17(\r)
+	lwz r18, OFFSET_R18(\r)
+	lwz r19, OFFSET_R19(\r)
+	lwz r20, OFFSET_R20(\r)
+	lwz r21, OFFSET_R21(\r)
+	lwz r22, OFFSET_R22(\r)
+	lwz r23, OFFSET_R23(\r)
+	lwz r24, OFFSET_R24(\r)
+	lwz r25, OFFSET_R25(\r)
+	lwz r26, OFFSET_R26(\r)
+	lwz r27, OFFSET_R27(\r)
+	lwz r28, OFFSET_R28(\r)
+	lwz r29, OFFSET_R29(\r)
+	lwz r30, OFFSET_R30(\r)
+	lwz r31, OFFSET_R31(\r)
+.endm
+
+context_save_arch:
+	CONTEXT_STORE r3
+	
+	mflr r4
+	stw r4, OFFSET_PC(r3)
+	
+	mfcr r4
+	stw r4, OFFSET_CR(r3)
+	
+	# context_save returns 1
+	li r3, 1
+	blr
+	
+context_restore_arch:
+	CONTEXT_LOAD r3
+	
+	lwz r4, OFFSET_CR(r3)
+	mtcr r4
+	
+	lwz r4, OFFSET_PC(r3)
+	mtlr r4
+	
+	# context_restore returns 0
+	li r3, 0
+	blr
Index: arch/ppc64/src/cpu/cpu.c
===================================================================
--- arch/ppc64/src/cpu/cpu.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/cpu/cpu.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2005 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 <arch/cpu.h>
+#include <arch/cpuid.h>
+#include <cpu.h>
+
+#include <arch.h>
+
+#include <typedefs.h>
+#include <print.h>
+
+void cpu_arch_init(void)
+{
+}
+
+void cpu_identify(void)
+{
+	cpu_info_t info;
+	
+	cpu_version(&info);
+	CPU->arch.version = info.version;
+	CPU->arch.revision = info.revision;
+}
+
+void cpu_print_report(cpu_t *m)
+{
+	printf("cpu%d: version=%d, revision=%d\n", m->id, m->arch.version, m->arch.revision);
+}
Index: arch/ppc64/src/debug/panic.s
===================================================================
--- arch/ppc64/src/debug/panic.s	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/debug/panic.s	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2005 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 <arch/asm/macro.h>
+
+.text
+.global panic_printf
+
+panic_printf:
+	lis %r14, halt@ha
+	addi %r14, %r14, halt@l
+	mtlr %r14	# fake stack to make printf return to halt
+	b printf
Index: arch/ppc64/src/dummy.s
===================================================================
--- arch/ppc64/src/dummy.s	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/dummy.s	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,54 @@
+#
+# 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
+
+.global asm_delay_loop
+.global userspace
+.global sys_tls_set
+.global tlb_invalidate_all
+.global tlb_invalidate_asid
+.global tlb_invalidate_pages
+
+tlb_invalidate_all:
+	b tlb_invalidate_all
+
+tlb_invalidate_asid:
+	b tlb_invalidate_asid
+
+tlb_invalidate_pages:
+	b tlb_invalidate_pages
+
+userspace:
+	b userspace
+
+sys_tls_set:
+	b sys_tls_set
+
+asm_delay_loop:
+	blr
Index: arch/ppc64/src/exception.S
===================================================================
--- arch/ppc64/src/exception.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/exception.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,176 @@
+#
+# 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 <arch/asm/regname.h>
+#include <arch/mm/page.h>
+
+.section K_UNMAPPED_TEXT_START, "ax"
+
+.org 0x100
+.global exc_system_reset
+exc_system_reset:
+	b exc_system_reset
+
+.org 0x200
+.global exc_machine_check
+exc_machine_check:
+	b exc_machine_check
+
+.org 0x300
+.global exc_data_storage
+exc_data_storage:
+	b exc_data_storage
+
+.org 0x380
+.global exc_data_segment
+exc_data_segment:
+	b exc_data_segment
+
+.org 0x400
+.global exc_instruction_storage
+exc_instruction_storage:
+	b exc_instruction_storage
+
+.org 0x480
+.global exc_instruction_segment
+exc_instruction_segment:
+	b exc_instruction_segment
+
+.org 0x500
+.global exc_external
+exc_external:
+	b exc_external
+
+.org 0x600
+.global exc_alignment
+exc_alignment:
+	b exc_alignment
+
+.org 0x700
+.global exc_program
+exc_program:
+	b exc_program
+
+.org 0x800
+.global exc_fp_unavailable
+exc_fp_unavailable:
+	b exc_fp_unavailable
+
+.org 0x900
+.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
+	rfid
+
+.org 0xa00
+.global exc_reserved0
+exc_reserved0:
+	b exc_reserved0
+
+.org 0xb00
+.global exc_reserved1
+exc_reserved1:
+	b exc_reserved1
+
+.org 0xc00
+.global exc_syscall
+exc_syscall:
+	b exc_syscall
+
+.org 0xd00
+.global exc_trace
+exc_trace:
+	b exc_trace
Index: arch/ppc64/src/fpu_context.S
===================================================================
--- arch/ppc64/src/fpu_context.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/fpu_context.S	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,105 @@
+#
+# 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 <arch/asm/regname.h>
+#include <arch/context_offset.h>
+
+.text   
+
+.global fpu_context_save
+.global fpu_context_restore
+.global fpu_init
+.global fpu_enable
+.global fpu_disable
+
+.macro FPU_CONTEXT_STORE r
+	stfd fr14, OFFSET_FR14(\r)
+	stfd fr15, OFFSET_FR15(\r)
+	stfd fr16, OFFSET_FR16(\r)
+	stfd fr17, OFFSET_FR17(\r)
+	stfd fr18, OFFSET_FR18(\r)
+	stfd fr19, OFFSET_FR19(\r)
+	stfd fr20, OFFSET_FR20(\r)
+	stfd fr21, OFFSET_FR21(\r)
+	stfd fr22, OFFSET_FR22(\r)
+	stfd fr23, OFFSET_FR23(\r)
+	stfd fr24, OFFSET_FR24(\r)
+	stfd fr25, OFFSET_FR25(\r)
+	stfd fr26, OFFSET_FR26(\r)
+	stfd fr27, OFFSET_FR27(\r)
+	stfd fr28, OFFSET_FR28(\r)
+	stfd fr29, OFFSET_FR29(\r)
+	stfd fr30, OFFSET_FR30(\r)
+	stfd fr31, OFFSET_FR31(\r)
+.endm
+
+.macro FPU_CONTEXT_LOAD r
+	lfd fr14, OFFSET_FR14(\r)
+	lfd fr15, OFFSET_FR15(\r)
+	lfd fr16, OFFSET_FR16(\r)
+	lfd fr17, OFFSET_FR17(\r)
+	lfd fr18, OFFSET_FR18(\r)
+	lfd fr19, OFFSET_FR19(\r)
+	lfd fr20, OFFSET_FR20(\r)
+	lfd fr21, OFFSET_FR21(\r)
+	lfd fr22, OFFSET_FR22(\r)
+	lfd fr23, OFFSET_FR23(\r)
+	lfd fr24, OFFSET_FR24(\r)
+	lfd fr25, OFFSET_FR25(\r)
+	lfd fr26, OFFSET_FR26(\r)
+	lfd fr27, OFFSET_FR27(\r)
+	lfd fr28, OFFSET_FR28(\r)
+	lfd fr29, OFFSET_FR29(\r)
+	lfd fr30, OFFSET_FR30(\r)
+	lfd fr31, OFFSET_FR31(\r)
+.endm
+
+fpu_context_save:
+//	FPU_CONTEXT_STORE r3
+//	
+//	mffs fr0
+//	stfd fr0, OFFSET_FPSCR(r3)
+	
+	blr
+	
+fpu_context_restore:
+//	FPU_CONTEXT_LOAD r3
+//	
+//	lfd fr0, OFFSET_FPSCR(r3)
+//	mtfsf 7, fr0
+	
+	blr
+
+fpu_init:
+	blr
+
+fpu_enable:
+	blr
+
+fpu_disable:
+	blr
Index: arch/ppc64/src/interrupt.c
===================================================================
--- arch/ppc64/src/interrupt.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/interrupt.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,57 @@
+/*
+ * 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>
+
+
+void start_decrementer(void)
+{
+	asm volatile (
+		"mtdec %0\n"
+		:: "r" (1000)
+	);
+}
+
+
+static void exception_decrementer(int n, istate_t *istate)
+{
+	clock();
+	start_decrementer();
+}
+
+
+/* Initialize basic tables for exception dispatching */
+void interrupt_init(void)
+{
+	exc_register(VECTOR_DECREMENTER, "timer", exception_decrementer);
+}
Index: arch/ppc64/src/mm/as.c
===================================================================
--- arch/ppc64/src/mm/as.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/mm/as.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#include <arch/mm/as.h>
+#include <genarch/mm/as_pt.h>
+
+/** Architecture dependent address space init. */
+void as_arch_init(void)
+{
+	as_operations = &as_pt_operations;
+}
Index: arch/ppc64/src/mm/frame.c
===================================================================
--- arch/ppc64/src/mm/frame.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/mm/frame.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2005 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 <arch/boot/boot.h>
+#include <arch/mm/frame.h>
+#include <arch/mm/memory_init.h>
+#include <mm/frame.h>
+#include <align.h>
+#include <macros.h>
+
+__address last_frame = 0;
+
+void frame_arch_init(void)
+{
+	pfn_t minconf = 2;
+	count_t i;
+	pfn_t start, conf;
+	size_t size;
+	
+	for (i = 0; i < bootinfo.memmap.count; i++) {
+		start = ADDR2PFN(ALIGN_UP(bootinfo.memmap.zones[i].start, FRAME_SIZE));
+		size = SIZE2FRAMES(ALIGN_DOWN(bootinfo.memmap.zones[i].size, FRAME_SIZE));
+		
+		if ((minconf < start) || (minconf >= start + size))
+			conf = start;
+		else
+			conf = minconf;
+		
+		zone_create(start, size, conf, 0);
+		if (last_frame < ALIGN_UP(bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE))
+			last_frame = ALIGN_UP(bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE);
+	}
+
+	/* First is exception vector, second is 'implementation specific', third and fourth is reserved */
+	frame_mark_unavailable(0, 4);
+	
+	/* Merge all zones to 1 big zone */
+	zone_merge_all();
+}
Index: arch/ppc64/src/mm/memory_init.c
===================================================================
--- arch/ppc64/src/mm/memory_init.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/mm/memory_init.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2005 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 <arch/boot/boot.h>
+#include <arch/mm/memory_init.h>
+#include <typedefs.h>
+#include <print.h>
+
+
+size_t get_memory_size(void) 
+{
+	return bootinfo.memmap.total;
+}
+
+
+void memory_print_map(void)
+{
+	count_t i;
+	
+	for (i = 0; i < bootinfo.memmap.count; i++)
+		printf("base: %L size: %L\n", bootinfo.memmap.zones[i].start, bootinfo.memmap.zones[i].size);
+}
Index: arch/ppc64/src/mm/page.c
===================================================================
--- arch/ppc64/src/mm/page.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/mm/page.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2005 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 <arch/mm/page.h>
+#include <genarch/mm/page_pt.h>
+#include <arch/mm/frame.h>
+#include <mm/frame.h>
+#include <mm/page.h>
+#include <arch/types.h>
+
+void page_arch_init(void)
+{
+	page_mapping_operations = &pt_mapping_operations;
+}
Index: arch/ppc64/src/ppc64.c
===================================================================
--- arch/ppc64/src/ppc64.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/ppc64.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,64 @@
+/*
+ * 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 <arch.h>
+#include <arch/boot/boot.h>
+#include <arch/console.h>
+#include <arch/mm/memory_init.h>
+#include <arch/interrupt.h>
+
+bootinfo_t bootinfo;
+
+void arch_pre_mm_init(void)
+{
+	/* Initialize dispatch table */
+	interrupt_init();
+	
+	/* Start decrementer */
+	start_decrementer();
+
+	ppc64_console_init();
+}
+
+void arch_post_mm_init(void)
+{
+}
+
+void arch_pre_smp_init(void)
+{
+	memory_print_map();
+}
+
+void arch_post_smp_init(void)
+{
+}
+
+void calibrate_delay_loop(void)
+{
+}
+
Index: arch/ppc64/src/proc/scheduler.c
===================================================================
--- arch/ppc64/src/proc/scheduler.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ arch/ppc64/src/proc/scheduler.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,45 @@
+/*
+ * 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 <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);
+}
+
+void after_thread_ran_arch(void)
+{
+}
Index: kernel.config
===================================================================
--- kernel.config	(revision 7f6e755b66aa78968eca1b1d352fb8316da04312)
+++ kernel.config	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -7,4 +7,5 @@
 @ "mips32" MIPS 32-bit
 @ "ppc32" PowerPC 32-bit
+@ "ppc64" PowerPC 64-bit
 @ "sparc64" Sun UltraSPARC
 ! ARCH (choice)
Index: tools/ppc64/gencontext.c
===================================================================
--- tools/ppc64/gencontext.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
+++ tools/ppc64/gencontext.c	(revision 602c9101593bede5e6931056ddd054069b20ff49)
@@ -0,0 +1,81 @@
+#include <stdio.h>
+#include <stdint.h>
+
+typedef uint32_t __u32;
+typedef uint64_t __u64;
+typedef __u64 ipl_t;
+typedef __u64 __address;
+
+#define __ppc64_TYPES_H__
+#include "../../arch/ppc64/include/context.h"
+#include "../../arch/ppc64/include/fpu_context.h"
+
+#define FILENAME "../../arch/ppc64/include/context_offset.h"
+
+int main(void)
+{
+	FILE *f;
+	struct context *pctx = NULL;
+	struct fpu_context *fpctx = NULL;
+	
+
+	f = fopen(FILENAME,"w");
+	if (!f) {
+		perror(FILENAME);
+		return 1;
+	}
+
+	fprintf(f, "/* This file is automatically generated by %s. */\n", __FILE__);	
+
+	fprintf(f,"/* struct context */\n");
+
+	fprintf(f,"#define OFFSET_SP    0x%x\n", ((int) &pctx->sp) - (int) pctx);
+	fprintf(f,"#define OFFSET_PC    0x%x\n", ((int) &pctx->pc) - (int) pctx);
+	fprintf(f,"#define OFFSET_R2    0x%x\n", ((int) &pctx->r2) - (int) pctx);
+	fprintf(f,"#define OFFSET_R13   0x%x\n", ((int) &pctx->r13) - (int) pctx);
+	fprintf(f,"#define OFFSET_R14   0x%x\n", ((int) &pctx->r14) - (int) pctx);
+	fprintf(f,"#define OFFSET_R15   0x%x\n", ((int) &pctx->r15) - (int) pctx);
+	fprintf(f,"#define OFFSET_R16   0x%x\n", ((int) &pctx->r16) - (int) pctx);
+	fprintf(f,"#define OFFSET_R17   0x%x\n", ((int) &pctx->r17) - (int) pctx);
+	fprintf(f,"#define OFFSET_R18   0x%x\n", ((int) &pctx->r18) - (int) pctx);
+	fprintf(f,"#define OFFSET_R19   0x%x\n", ((int) &pctx->r19) - (int) pctx);
+	fprintf(f,"#define OFFSET_R20   0x%x\n", ((int) &pctx->r20) - (int) pctx);
+	fprintf(f,"#define OFFSET_R21   0x%x\n", ((int) &pctx->r21) - (int) pctx);
+	fprintf(f,"#define OFFSET_R22   0x%x\n", ((int) &pctx->r22) - (int) pctx);
+	fprintf(f,"#define OFFSET_R23   0x%x\n", ((int) &pctx->r23) - (int) pctx);
+	fprintf(f,"#define OFFSET_R24   0x%x\n", ((int) &pctx->r24) - (int) pctx);
+	fprintf(f,"#define OFFSET_R25   0x%x\n", ((int) &pctx->r25) - (int) pctx);
+	fprintf(f,"#define OFFSET_R26   0x%x\n", ((int) &pctx->r26) - (int) pctx);
+	fprintf(f,"#define OFFSET_R27   0x%x\n", ((int) &pctx->r27) - (int) pctx);
+	fprintf(f,"#define OFFSET_R28   0x%x\n", ((int) &pctx->r28) - (int) pctx);
+	fprintf(f,"#define OFFSET_R29   0x%x\n", ((int) &pctx->r29) - (int) pctx);
+	fprintf(f,"#define OFFSET_R30   0x%x\n", ((int) &pctx->r30) - (int) pctx);
+	fprintf(f,"#define OFFSET_R31   0x%x\n", ((int) &pctx->r31) - (int) pctx);
+	fprintf(f,"#define OFFSET_CR    0x%x\n", ((int) &pctx->cr) - (int) pctx);
+	
+	fprintf(f,"\n");
+
+	fprintf(f,"#define OFFSET_FR14  0x%x\n", ((int) &fpctx->fr14) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR15  0x%x\n", ((int) &fpctx->fr15) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR16  0x%x\n", ((int) &fpctx->fr16) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR17  0x%x\n", ((int) &fpctx->fr17) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR18  0x%x\n", ((int) &fpctx->fr18) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR19  0x%x\n", ((int) &fpctx->fr19) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR20  0x%x\n", ((int) &fpctx->fr20) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR21  0x%x\n", ((int) &fpctx->fr21) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR22  0x%x\n", ((int) &fpctx->fr22) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR23  0x%x\n", ((int) &fpctx->fr23) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR24  0x%x\n", ((int) &fpctx->fr24) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR25  0x%x\n", ((int) &fpctx->fr25) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR26  0x%x\n", ((int) &fpctx->fr26) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR27  0x%x\n", ((int) &fpctx->fr27) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR28  0x%x\n", ((int) &fpctx->fr28) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR29  0x%x\n", ((int) &fpctx->fr29) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR30  0x%x\n", ((int) &fpctx->fr30) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FR31  0x%x\n", ((int) &fpctx->fr31) - (int) fpctx);
+	fprintf(f,"#define OFFSET_FPSCR 0x%x\n", ((int) &fpctx->fpscr) - (int) fpctx);
+	
+	fclose(f);
+
+	return 0;
+}
