## Automatically generated incremental diff
## From:   linux-2.4.23-bk4
## To:     linux-2.4.23-bk5
## Robot:  $Id: make-incremental-diff,v 1.11 2002/02/20 02:59:33 hpa Exp $

diff -urN linux-2.4.23-bk4/Makefile linux-2.4.23-bk5/Makefile
--- linux-2.4.23-bk4/Makefile	2003-12-07 02:49:56.000000000 -0800
+++ linux-2.4.23-bk5/Makefile	2003-12-07 02:49:59.000000000 -0800
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 23
-EXTRAVERSION = -bk4
+EXTRAVERSION = -bk5
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
diff -urN linux-2.4.23-bk4/arch/i386/kernel/edd.c linux-2.4.23-bk5/arch/i386/kernel/edd.c
--- linux-2.4.23-bk4/arch/i386/kernel/edd.c	2003-12-07 02:49:56.000000000 -0800
+++ linux-2.4.23-bk5/arch/i386/kernel/edd.c	2003-12-07 02:49:59.000000000 -0800
@@ -46,7 +46,7 @@
 MODULE_DESCRIPTION("proc interface to BIOS EDD information");
 MODULE_LICENSE("GPL");
 
-#define EDD_VERSION "0.09 2003-Jan-21"
+#define EDD_VERSION "0.10 2003-Dec-05"
 #define EDD_DEVICE_NAME_SIZE 16
 #define REPORT_URL "http://domsch.com/linux/edd30/results.html"
 
diff -urN linux-2.4.23-bk4/arch/i386/kernel/process.c linux-2.4.23-bk5/arch/i386/kernel/process.c
--- linux-2.4.23-bk4/arch/i386/kernel/process.c	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/i386/kernel/process.c	2003-12-07 02:49:59.000000000 -0800
@@ -153,7 +153,6 @@
 
 __setup("idle=", idle_setup);
 
-static long no_idt[2];
 static int reboot_mode;
 int reboot_thru_bios;
 
@@ -224,7 +223,8 @@
 	unsigned long long * base __attribute__ ((packed));
 }
 real_mode_gdt = { sizeof (real_mode_gdt_entries) - 1, real_mode_gdt_entries },
-real_mode_idt = { 0x3ff, 0 };
+real_mode_idt = { 0x3ff, 0 },
+no_idt = { 0, 0 };
 
 /* This is 16-bit protected mode code to disable paging and the cache,
    switch to real mode and jump to the BIOS reset code.
diff -urN linux-2.4.23-bk4/arch/i386/kernel/setup.c linux-2.4.23-bk5/arch/i386/kernel/setup.c
--- linux-2.4.23-bk4/arch/i386/kernel/setup.c	2003-12-07 02:49:56.000000000 -0800
+++ linux-2.4.23-bk5/arch/i386/kernel/setup.c	2003-12-07 02:49:59.000000000 -0800
@@ -211,7 +211,7 @@
 #define KERNEL_START (*(unsigned long *) (PARAM+0x214))
 #define INITRD_START (*(unsigned long *) (PARAM+0x218))
 #define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
-#define DISK80_SIGNATURE_BUFFER (*(unsigned int*) (PARAM+DISKSIG_BUFFER))
+#define DISK80_SIGNATURE_BUFFER (*(unsigned int*) (PARAM+DISK80_SIG_BUFFER))
 #define EDD_NR     (*(unsigned char *) (PARAM+EDDNR))
 #define EDD_BUF     ((struct edd_info *) (PARAM+EDDBUF))
 #define COMMAND_LINE ((char *) (PARAM+2048))
diff -urN linux-2.4.23-bk4/arch/i386/kernel/smpboot.c linux-2.4.23-bk5/arch/i386/kernel/smpboot.c
--- linux-2.4.23-bk4/arch/i386/kernel/smpboot.c	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/i386/kernel/smpboot.c	2003-12-07 02:49:59.000000000 -0800
@@ -1106,7 +1106,7 @@
 	 */
 	Dprintk("CPU present map: %lx\n", phys_cpu_present_map);
 
-	for (bit = 0; bit < NR_CPUS; bit++) {
+	for (bit = 0; bit < BITS_PER_LONG; bit++) {
 		apicid = cpu_present_to_apicid(bit);
 		
 		/* don't try to boot BAD_APICID */
diff -urN linux-2.4.23-bk4/arch/ppc/8260_io/fcc_enet.c linux-2.4.23-bk5/arch/ppc/8260_io/fcc_enet.c
--- linux-2.4.23-bk4/arch/ppc/8260_io/fcc_enet.c	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/8260_io/fcc_enet.c	2003-12-07 02:49:59.000000000 -0800
@@ -1327,6 +1327,12 @@
 	 */
 	eap = (unsigned char *)&(ep->fen_paddrh);
 	for (i=5; i>=0; i--) {
+
+/* 
+ * The EP8260 only uses FCC3, so we can safely give it the real
+ * MAC address.
+ */
+#ifndef CONFIG_RPX6
 		if (i == 3) {
 			dev->dev_addr[i] = bd->bi_enetaddr[i];
 			dev->dev_addr[i] |= (1 << (7 - fip->fc_fccnum));
@@ -1335,6 +1341,9 @@
 		else {
 			*eap++ = dev->dev_addr[i] = bd->bi_enetaddr[i];
 		}
+#else
+		*eap++ = dev->dev_addr[i] = bd->bi_enetaddr[i];
+#endif
 	}
 
 	ep->fen_taddrh = 0;
diff -urN linux-2.4.23-bk4/arch/ppc/boot/Makefile linux-2.4.23-bk5/arch/ppc/boot/Makefile
--- linux-2.4.23-bk4/arch/ppc/boot/Makefile	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/Makefile	2003-12-07 02:49:59.000000000 -0800
@@ -42,6 +42,9 @@
 # These are the subdirs we want to use
 BOOTDIRS			= $(filter-out $(NONBOOT), $(subdir-y))
 
+makeof1275:
+	$(MAKE) -C of1275
+
 # This will make the tools we need.  We do it like this to ensure that we use
 # HOSTCC. -- Tom
 maketools:
@@ -50,7 +53,7 @@
 # The targets all boards support for boot images.
 BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd
 
-$(BOOT_TARGETS): vmapus lib/zlib.a images/vmlinux.gz maketools
+$(BOOT_TARGETS): vmapus lib/zlib.a images/vmlinux.gz makeof1275 maketools
 ifneq ($(BOOTDIRS),)
 	for d in $(BOOTDIRS); do $(MAKE) -C $$d $@; done
 endif
diff -urN linux-2.4.23-bk4/arch/ppc/boot/chrp/Makefile linux-2.4.23-bk5/arch/ppc/boot/chrp/Makefile
--- linux-2.4.23-bk4/arch/ppc/boot/chrp/Makefile	2003-06-13 07:51:31.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/chrp/Makefile	2003-12-07 02:49:59.000000000 -0800
@@ -12,7 +12,7 @@
 
 OBJS = ../common/crt0.o start.o main.o misc.o ../common/string.o image.o \
 	../common/ofcommon.o
-LIBS = $(TOPDIR)/lib/lib.a ../lib/zlib.a
+LIBS = $(TOPDIR)/lib/lib.a ../lib/zlib.a ../of1275/of1275.a
 ADDNOTE = ../utils/addnote
 PIGGYBACK = ../utils/piggyback
 
diff -urN linux-2.4.23-bk4/arch/ppc/boot/chrp/main.c linux-2.4.23-bk5/arch/ppc/boot/chrp/main.c
--- linux-2.4.23-bk4/arch/ppc/boot/chrp/main.c	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/chrp/main.c	2003-12-07 02:49:59.000000000 -0800
@@ -7,6 +7,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include "nonstdio.h"
+#include "of1275.h"
 #include <asm/processor.h>
 #include <asm/page.h>
 
@@ -15,15 +16,11 @@
 extern char __ramdisk_begin[], __ramdisk_end;
 extern char _start, _end;
 
-extern int getprop(void *, const char *, void *, int);
 extern unsigned int heap_max;
-extern void claim(unsigned int virt, unsigned int size, unsigned int align);
-extern void *finddevice(const char *);
 extern void flush_cache(void *, unsigned long);
 extern void gunzip(void *, int, unsigned char *, int *);
 extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
 		unsigned int progend);
-extern void pause(void);
 
 char *avail_ram;
 char *begin_avail, *end_avail;
diff -urN linux-2.4.23-bk4/arch/ppc/boot/chrp/start.c linux-2.4.23-bk5/arch/ppc/boot/chrp/start.c
--- linux-2.4.23-bk4/arch/ppc/boot/chrp/start.c	2003-06-13 07:51:31.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/chrp/start.c	2003-12-07 02:49:59.000000000 -0800
@@ -7,17 +7,13 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include <stdarg.h>
+#include "of1275.h"
 
 int (*prom)(void *args);
 
-void *chosen_handle;
-void *stdin;
-void *stdout;
-void *stderr;
-
-void exit(void);
-void *finddevice(const char *name);
-int getprop(void *phandle, const char *name, void *buf, int buflen);
+phandle stdin;
+phandle stdout;
+phandle stderr;
 
 void printk(char *fmt, ...);
 
@@ -27,163 +23,15 @@
 void
 start(int a1, int a2, void *promptr)
 {
-    prom = promptr;
-    chosen_handle = finddevice("/chosen");
-    if (chosen_handle == (void *) -1)
+    ofinit(promptr);
+    if (ofstdio(&stdin, &stdout, &stderr))
 	exit();
-    if (getprop(chosen_handle, "stdout", &stdout, sizeof(stdout)) != 4)
-	exit();
-    stderr = stdout;
-    if (getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4)
-	exit();
-
     chrpboot(a1, a2, promptr);
     for (;;)
 	exit();
 }
 
 int
-write(void *handle, void *ptr, int nb)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	void *ihandle;
-	void *addr;
-	int len;
-	int actual;
-    } args;
-
-    args.service = "write";
-    args.nargs = 3;
-    args.nret = 1;
-    args.ihandle = handle;
-    args.addr = ptr;
-    args.len = nb;
-    args.actual = -1;
-    prom(&args);
-    return args.actual;
-}
-
-int
-read(void *handle, void *ptr, int nb)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	void *ihandle;
-	void *addr;
-	int len;
-	int actual;
-    } args;
-
-    args.service = "read";
-    args.nargs = 3;
-    args.nret = 1;
-    args.ihandle = handle;
-    args.addr = ptr;
-    args.len = nb;
-    args.actual = -1;
-    (*prom)(&args);
-    return args.actual;
-}
-
-void
-exit(void)
-{
-    struct prom_args {
-	char *service;
-    } args;
-
-    for (;;) {
-	args.service = "exit";
-	(*prom)(&args);
-    }
-}
-
-void
-pause(void)
-{
-    struct prom_args {
-	char *service;
-    } args;
-
-    args.service = "enter";
-    (*prom)(&args);
-}
-
-void *
-finddevice(const char *name)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	const char *devspec;
-	void *phandle;
-    } args;
-
-    args.service = "finddevice";
-    args.nargs = 1;
-    args.nret = 1;
-    args.devspec = name;
-    args.phandle = (void *) -1;
-    (*prom)(&args);
-    return args.phandle;
-}
-
-void *
-claim(unsigned int virt, unsigned int size, unsigned int align)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	unsigned int virt;
-	unsigned int size;
-	unsigned int align;
-	void *ret;
-    } args;
-
-    args.service = "claim";
-    args.nargs = 3;
-    args.nret = 1;
-    args.virt = virt;
-    args.size = size;
-    args.align = align;
-    (*prom)(&args);
-    return args.ret;
-}
-
-int
-getprop(void *phandle, const char *name, void *buf, int buflen)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	void *phandle;
-	const char *name;
-	void *buf;
-	int buflen;
-	int size;
-    } args;
-
-    args.service = "getprop";
-    args.nargs = 4;
-    args.nret = 1;
-    args.phandle = phandle;
-    args.name = name;
-    args.buf = buf;
-    args.buflen = buflen;
-    args.size = -1;
-    (*prom)(&args);
-    return args.size;
-}
-
-int
 putc(int c, void *f)
 {
     char ch = c;
diff -urN linux-2.4.23-bk4/arch/ppc/boot/common/ofcommon.c linux-2.4.23-bk5/arch/ppc/boot/common/ofcommon.c
--- linux-2.4.23-bk4/arch/ppc/boot/common/ofcommon.c	2003-06-13 07:51:31.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/common/ofcommon.c	2003-12-07 02:49:59.000000000 -0800
@@ -8,6 +8,7 @@
  */
 
 #include "zlib.h"
+#include "of1275.h"
 #include "nonstdio.h"
 #include <asm/bootinfo.h>
 #include <asm/page.h>
@@ -18,8 +19,6 @@
 extern int strcmp(const char *s1, const char *s2);
 extern char *avail_ram, *avail_high;
 extern char *end_avail;
-extern void claim(unsigned int virt, unsigned int size, unsigned int align);
-extern void pause(void);
 
 unsigned int heap_use, heap_max;
 
diff -urN linux-2.4.23-bk4/arch/ppc/boot/common/util.S linux-2.4.23-bk5/arch/ppc/boot/common/util.S
--- linux-2.4.23-bk4/arch/ppc/boot/common/util.S	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/common/util.S	2003-12-07 02:49:59.000000000 -0800
@@ -217,11 +217,6 @@
 	blt	2b
 3:	blr
 
-.globl _put_MSR
-_put_MSR:
-	mtmsr	r3
-	blr
-
 	.section ".relocate_code","xa"
 /*
  * Flush and enable instruction cache
diff -urN linux-2.4.23-bk4/arch/ppc/boot/include/of1275.h linux-2.4.23-bk5/arch/ppc/boot/include/of1275.h
--- linux-2.4.23-bk4/arch/ppc/boot/include/of1275.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/include/of1275.h	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+typedef void *prom_handle;
+typedef void *ihandle;
+typedef void *phandle;
+typedef int (*prom_entry)(void *);
+
+#define OF_INVALID_HANDLE	((prom_handle)-1UL)
+
+extern prom_entry of_prom_entry;
+
+/* function declarations */
+
+void *	claim(unsigned int virt, unsigned int size, unsigned int align);
+void	enter(void);
+void	exit(void);
+phandle	finddevice(const char *name);
+int	getprop(phandle node, const char *name, void *buf, int buflen);
+void	ofinit(prom_entry entry);
+int	ofstdio(ihandle *stdin, ihandle *stdout, ihandle *stderr);
+int	read(ihandle instance, void *buf, int buflen);
+void	release(void *virt, unsigned int size);
+int	write(ihandle instance, void *buf, int buflen);
+ihandle	open(const char *name);
+void	close(ihandle instance);
+int	setcolor(ihandle instance, int color, int red, int green, int blue);
+phandle	instancetopackage(const ihandle instance);
+
+/* inlines */
+
+extern inline void pause(void)
+{
+	enter();
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/Makefile linux-2.4.23-bk5/arch/ppc/boot/of1275/Makefile
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/Makefile	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/Makefile	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,11 @@
+#
+# Makefile of1275 stuff
+#
+
+L_TARGET := of1275.a
+
+obj-y := claim.o enter.o exit.o finddevice.o getprop.o ofinit.o	\
+	 ofstdio.o read.o release.o write.o open.o close.o setcolor.o \
+	 instancetopackage.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/claim.c linux-2.4.23-bk5/arch/ppc/boot/of1275/claim.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/claim.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/claim.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+void *
+claim(unsigned int virt, unsigned int size, unsigned int align)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	unsigned int virt;
+	unsigned int size;
+	unsigned int align;
+	void *ret;
+    } args;
+
+    args.service = "claim";
+    args.nargs = 3;
+    args.nret = 1;
+    args.virt = virt;
+    args.size = size;
+    args.align = align;
+    (*of_prom_entry)(&args);
+    return args.ret;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/close.c linux-2.4.23-bk5/arch/ppc/boot/of1275/close.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/close.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/close.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+void
+close(ihandle instance)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	ihandle instance;
+    } args;
+
+    args.service = "close";
+    args.nargs = 1;
+    args.nret = 0;
+    args.instance = instance;
+    (*of_prom_entry)(&args);
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/enter.c linux-2.4.23-bk5/arch/ppc/boot/of1275/enter.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/enter.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/enter.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+void
+enter(void)
+{
+    struct prom_args {
+	char *service;
+    } args;
+
+    args.service = "enter";
+    (*of_prom_entry)(&args);
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/exit.c linux-2.4.23-bk5/arch/ppc/boot/of1275/exit.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/exit.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/exit.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+void
+exit(void)
+{
+    struct prom_args {
+	char *service;
+    } args;
+
+    for (;;) {
+	args.service = "exit";
+	(*of_prom_entry)(&args);
+    }
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/finddevice.c linux-2.4.23-bk5/arch/ppc/boot/of1275/finddevice.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/finddevice.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/finddevice.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+phandle
+finddevice(const char *name)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	const char *devspec;
+	phandle device;
+    } args;
+
+    args.service = "finddevice";
+    args.nargs = 1;
+    args.nret = 1;
+    args.devspec = name;
+    args.device = OF_INVALID_HANDLE;
+    (*of_prom_entry)(&args);
+    return args.device;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/getprop.c linux-2.4.23-bk5/arch/ppc/boot/of1275/getprop.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/getprop.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/getprop.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+int
+getprop(phandle node, const char *name, void *buf, int buflen)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	phandle node;
+	const char *name;
+	void *buf;
+	int buflen;
+	int size;
+    } args;
+
+    args.service = "getprop";
+    args.nargs = 4;
+    args.nret = 1;
+    args.node = node;
+    args.name = name;
+    args.buf = buf;
+    args.buflen = buflen;
+    args.size = -1;
+    (*of_prom_entry)(&args);
+    return args.size;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/instancetopackage.c linux-2.4.23-bk5/arch/ppc/boot/of1275/instancetopackage.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/instancetopackage.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/instancetopackage.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+phandle
+instancetopackage(const ihandle instance)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	ihandle instance;
+	phandle package;
+    } args;
+
+    args.service = "instance-to-package";
+    args.nargs = 1;
+    args.nret = 1;
+    args.instance = instance;
+    (*of_prom_entry)(&args);
+    return args.package;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/ofinit.c linux-2.4.23-bk5/arch/ppc/boot/of1275/ofinit.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/ofinit.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/ofinit.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+prom_entry of_prom_entry;
+ihandle of_prom_mmu;
+
+void
+ofinit(prom_entry prom_ptr)
+{
+    phandle chosen;
+
+    of_prom_entry = prom_ptr;
+
+    if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE)
+	return;
+    if (getprop(chosen, "mmu", &of_prom_mmu, sizeof(ihandle)) != 4)
+	return;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/ofstdio.c linux-2.4.23-bk5/arch/ppc/boot/of1275/ofstdio.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/ofstdio.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/ofstdio.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+int
+ofstdio(ihandle *stdin, ihandle *stdout, ihandle *stderr)
+{
+    ihandle in, out;
+    phandle chosen;
+
+    if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE)
+	goto err;
+    if (getprop(chosen, "stdout", &out, sizeof(out)) != 4)
+	goto err;
+    if (getprop(chosen, "stdin", &in, sizeof(in)) != 4)
+	goto err;
+
+    *stdin  = in;
+    *stdout = out;
+    *stderr = out;
+    return 0;
+err:
+    return -1;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/open.c linux-2.4.23-bk5/arch/ppc/boot/of1275/open.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/open.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/open.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+ihandle
+open(const char *name)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	const char *name;
+	ihandle instance;
+    } args;
+
+    args.service = "open";
+    args.nargs = 1;
+    args.nret = 1;
+    args.name = name;
+    args.instance = OF_INVALID_HANDLE;
+    (*of_prom_entry)(&args);
+    return args.instance;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/read.c linux-2.4.23-bk5/arch/ppc/boot/of1275/read.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/read.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/read.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+int
+read(ihandle instance, void *buf, int buflen)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	ihandle instance;
+	void *buf;
+	int buflen;
+	int actual;
+    } args;
+
+    args.service = "read";
+    args.nargs = 3;
+    args.nret = 1;
+    args.instance = instance;
+    args.buf = buf;
+    args.buflen = buflen;
+    args.actual = -1;
+    (*of_prom_entry)(&args);
+    return args.actual;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/release.c linux-2.4.23-bk5/arch/ppc/boot/of1275/release.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/release.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/release.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+void
+release(void *virt, unsigned int size)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	void *virt;
+	unsigned int size;
+    } args;
+
+    args.service = "release";
+    args.nargs = 2;
+    args.nret = 0;
+    args.virt = virt;
+    args.size = size;
+    (*of_prom_entry)(&args);
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/setcolor.c linux-2.4.23-bk5/arch/ppc/boot/of1275/setcolor.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/setcolor.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/setcolor.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,42 @@
+/*
+ * arch/ppc/boot/of1275/setcolor.c
+ *
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+int
+setcolor(ihandle instance, int color, int red, int green, int blue)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	char *method;
+	ihandle instance;
+	int color;
+	int blue;
+	int green;
+	int red;
+	int result;
+    } args;
+
+    args.service = "call-method";
+    args.nargs = 6;
+    args.nret = 1;
+    args.method = "color!";
+    args.instance = instance;
+    args.color = color;
+    args.blue = blue;
+    args.green = green;
+    args.red = red;
+    args.result = 0;
+    (*of_prom_entry)(&args);
+    return args.result;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/of1275/write.c linux-2.4.23-bk5/arch/ppc/boot/of1275/write.c
--- linux-2.4.23-bk4/arch/ppc/boot/of1275/write.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/boot/of1275/write.c	2003-12-07 02:49:59.000000000 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ * Copyright (C) Leigh Brown 2002.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "of1275.h"
+
+int
+write(ihandle instance, void *buf, int buflen)
+{
+    struct prom_args {
+	char *service;
+	int nargs;
+	int nret;
+	ihandle instance;
+	void *buf;
+	int buflen;
+	int actual;
+    } args;
+
+    args.service = "write";
+    args.nargs = 3;
+    args.nret = 1;
+    args.instance = instance;
+    args.buf = buf;
+    args.buflen = buflen;
+    args.actual = -1;
+    (*of_prom_entry)(&args);
+    return args.actual;
+}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/pmac/Makefile linux-2.4.23-bk5/arch/ppc/boot/pmac/Makefile
--- linux-2.4.23-bk4/arch/ppc/boot/pmac/Makefile	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/pmac/Makefile	2003-12-07 02:49:59.000000000 -0800
@@ -14,7 +14,7 @@
 COMMONOBJS = start.o misc.o ../common/string.o ../common/ofcommon.o
 COFFOBJS = ../common/coffcrt0.o $(COMMONOBJS) coffmain.o
 CHRPOBJS = ../common/crt0.o $(COMMONOBJS) chrpmain.o
-LIBS = $(TOPDIR)/lib/lib.a ../lib/zlib.a
+LIBS = $(TOPDIR)/lib/lib.a ../lib/zlib.a ../of1275/of1275.a
 
 MKNOTE := ../utils/mknote
 SIZE := ../utils/size
diff -urN linux-2.4.23-bk4/arch/ppc/boot/pmac/chrpmain.c linux-2.4.23-bk5/arch/ppc/boot/pmac/chrpmain.c
--- linux-2.4.23-bk4/arch/ppc/boot/pmac/chrpmain.c	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/pmac/chrpmain.c	2003-12-07 02:49:59.000000000 -0800
@@ -7,6 +7,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include "nonstdio.h"
+#include "of1275.h"
 #include <asm/processor.h>
 #include <asm/page.h>
 
@@ -15,16 +16,11 @@
 extern char __ramdisk_begin[], __ramdisk_end;
 extern char _start, _end;
 
-extern int getprop(void *, const char *, void *, int);
 extern unsigned int heap_max;
-extern void *claim(unsigned int virt, unsigned int size, unsigned int align);
-extern void *finddevice(const char *);
 extern void flush_cache(void *start, unsigned int len);
 extern void gunzip(void *, int, unsigned char *, int *);
 extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
 		unsigned int progend);
-extern void pause(void);
-extern void release(void *ptr, unsigned int len);
 
 char *avail_ram;
 char *begin_avail, *end_avail;
diff -urN linux-2.4.23-bk4/arch/ppc/boot/pmac/coffmain.c linux-2.4.23-bk5/arch/ppc/boot/pmac/coffmain.c
--- linux-2.4.23-bk4/arch/ppc/boot/pmac/coffmain.c	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/pmac/coffmain.c	2003-12-07 02:49:59.000000000 -0800
@@ -10,6 +10,7 @@
 #include <asm/page.h>
 
 #include "nonstdio.h"
+#include "of1275.h"
 #include "zlib.h"
 
 /* Passed from the linker */
@@ -17,17 +18,13 @@
 extern char __ramdisk_begin[], __ramdisk_end;
 extern char _start, _end;
 
-extern char *claim(unsigned, unsigned, unsigned);
 extern char image_data[], initrd_data[];
 extern int initrd_len, image_len;
-extern int getprop(void *, const char *, void *, int);
 extern unsigned int heap_max;
-extern void *finddevice(const char *);
 extern void flush_cache(void *start, unsigned int len);
 extern void gunzip(void *, int, unsigned char *, int *);
 extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
 		unsigned int progend);
-extern void pause(void);
 extern void setup_bats(unsigned long start);
 
 char *avail_ram;
diff -urN linux-2.4.23-bk4/arch/ppc/boot/pmac/start.c linux-2.4.23-bk5/arch/ppc/boot/pmac/start.c
--- linux-2.4.23-bk4/arch/ppc/boot/pmac/start.c	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/pmac/start.c	2003-12-07 02:49:59.000000000 -0800
@@ -7,33 +7,22 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include <stdarg.h>
+#include "of1275.h"
 
 extern int strlen(const char *s);
 extern void boot(int a1, int a2, void *prom);
 
-int (*prom)(void *args);
+phandle stdin;
+phandle stdout;
+phandle stderr;
 
-void *chosen_handle;
-void *stdin;
-void *stdout;
-void *stderr;
-
-void exit(void);
-void *finddevice(const char *name);
-int getprop(void *phandle, const char *name, void *buf, int buflen);
 void printk(char *fmt, ...);
 
 void
 start(int a1, int a2, void *promptr)
 {
-    prom = (int (*)(void *)) promptr;
-    chosen_handle = finddevice("/chosen");
-    if (chosen_handle == (void *) -1)
-	exit();
-    if (getprop(chosen_handle, "stdout", &stdout, sizeof(stdout)) != 4)
-	exit();
-    stderr = stdout;
-    if (getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4)
+    ofinit(promptr);
+    if (ofstdio(&stdin, &stdout, &stderr))
 	exit();
 
     boot(a1, a2, promptr);
@@ -41,30 +30,6 @@
 	exit();
 }
 
-int
-write(void *handle, void *ptr, int nb)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	void *ihandle;
-	void *addr;
-	int len;
-	int actual;
-    } args;
-
-    args.service = "write";
-    args.nargs = 3;
-    args.nret = 1;
-    args.ihandle = handle;
-    args.addr = ptr;
-    args.len = nb;
-    args.actual = -1;
-    (*prom)(&args);
-    return args.actual;
-}
-
 int writestring(void *f, char *ptr, int nb)
 {
 	int w = 0, i;
@@ -85,142 +50,6 @@
 }
 
 int
-read(void *handle, void *ptr, int nb)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	void *ihandle;
-	void *addr;
-	int len;
-	int actual;
-    } args;
-
-    args.service = "read";
-    args.nargs = 3;
-    args.nret = 1;
-    args.ihandle = handle;
-    args.addr = ptr;
-    args.len = nb;
-    args.actual = -1;
-    (*prom)(&args);
-    return args.actual;
-}
-
-void
-exit(void)
-{
-    struct prom_args {
-	char *service;
-    } args;
-
-    for (;;) {
-	args.service = "exit";
-	(*prom)(&args);
-    }
-}
-
-void
-pause(void)
-{
-    struct prom_args {
-	char *service;
-    } args;
-
-    args.service = "enter";
-    (*prom)(&args);
-}
-
-void *
-finddevice(const char *name)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	const char *devspec;
-	void *phandle;
-    } args;
-
-    args.service = "finddevice";
-    args.nargs = 1;
-    args.nret = 1;
-    args.devspec = name;
-    args.phandle = (void *) -1;
-    (*prom)(&args);
-    return args.phandle;
-}
-
-void *
-claim(unsigned int virt, unsigned int size, unsigned int align)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	unsigned int virt;
-	unsigned int size;
-	unsigned int align;
-	void *ret;
-    } args;
-
-    args.service = "claim";
-    args.nargs = 3;
-    args.nret = 1;
-    args.virt = virt;
-    args.size = size;
-    args.align = align;
-    (*prom)(&args);
-    return args.ret;
-}
-
-void
-release(void *virt, unsigned int size)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	void *virt;
-	unsigned int size;
-    } args;
-
-    args.service = "release";
-    args.nargs = 2;
-    args.nret = 0;
-    args.virt = virt;
-    args.size = size;
-    (*prom)(&args);
-}
-
-int
-getprop(void *phandle, const char *name, void *buf, int buflen)
-{
-    struct prom_args {
-	char *service;
-	int nargs;
-	int nret;
-	void *phandle;
-	const char *name;
-	void *buf;
-	int buflen;
-	int size;
-    } args;
-
-    args.service = "getprop";
-    args.nargs = 4;
-    args.nret = 1;
-    args.phandle = phandle;
-    args.name = name;
-    args.buf = buf;
-    args.buflen = buflen;
-    args.size = -1;
-    (*prom)(&args);
-    return args.size;
-}
-
-int
 putc(int c, void *f)
 {
     char ch = c;
diff -urN linux-2.4.23-bk4/arch/ppc/boot/prep/Makefile linux-2.4.23-bk5/arch/ppc/boot/prep/Makefile
--- linux-2.4.23-bk4/arch/ppc/boot/prep/Makefile	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/prep/Makefile	2003-12-07 02:49:59.000000000 -0800
@@ -22,12 +22,12 @@
 endif
 
 LD_ARGS				= -T ../ld.script -Ttext 0x00800000 -Bstatic
-obj-y				:= head.o ../simple/legacy.o misc.o of1275.o \
+obj-y				:= head.o ../simple/legacy.o misc.o \
 					../common/util.o ../common/string.o \
 					../common/misc-common.o \
 					../common/serial_stub.o
 OBJCOPY_ARGS			= -O elf32-powerpc
-LIBS 				= ../lib/zlib.a
+LIBS 				= ../lib/zlib.a ../of1275/of1275.a
 
 obj-$(CONFIG_SERIAL_CONSOLE)	+= ../common/ns16550.o
 obj-$(CONFIG_VGA_CONSOLE)	+= vreset.o kbd.o
diff -urN linux-2.4.23-bk4/arch/ppc/boot/prep/head.S linux-2.4.23-bk5/arch/ppc/boot/prep/head.S
--- linux-2.4.23-bk4/arch/ppc/boot/prep/head.S	2003-06-13 07:51:31.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/prep/head.S	2003-12-07 02:49:59.000000000 -0800
@@ -34,14 +34,29 @@
 	isync
 
 	mr	r11,r3		/* Save pointer to residual/board data */
-	mr      r25,r5		/* Save OFW pointer */
 
-	/* Save the original MSR value */
-	mfmsr	r26
+/*
+ * Save the OF pointer to r25, but only if the entry point is in a sane
+ * location; if not we store 0.  If there is no entry point, or it is
+ * invalid, we establish the default MSR value immediately.  Otherwise,
+ * we defer doing that, to allow OF functions to be called, until we
+ * begin uncompressing the kernel.
+ */
+	lis	r3,0x0fff		/* r3 = 0x0fffffff */
+	ori	r3,r3,0xffff
 
-	/* Establish default MSR value */
-	li	r3,MSR_IP|MSR_FP
-	mtmsr	r3
+	subc	r3,r3,r5		/* r3 = (r5 <= r3) ? ~0 : 0 */
+	subfe	r3,r3,r3
+	nand	r3,r3,r3
+  
+	and.	r5,r5,r3		/* r5 will be cleared if (r5 > r3) */
+	bne+	haveOF
+
+	li	r3,MSR_IP|MSR_FP	/* Not OF: set MSR immediately */
+  	mtmsr	r3
+	isync
+haveOF:
+	mr	r25,r5
 
 	/* compute the size of the whole image in words. */
 	lis	r4,start@h
@@ -110,17 +125,12 @@
 	li	r2,0x000F		/* Mask pointer to 16-byte boundary */
 	andc	r1,r1,r2
 
-	/* Store the original MSR into 'orig_MSR' */
-	lis	r3,orig_MSR@h
-	ori	r3,r3,orig_MSR@l
-	stw	r26,0(r3)
-
 /* Run loader */
 	mr	r3,r8			/* Load point */
 	mr	r4,r7			/* Program length */
 	mr	r5,r6			/* Checksum */
 	mr	r6,r11			/* Residual data */
-	mr      r7,r25                  /* OFW interfaces */
+	mr      r7,r25                  /* Validated OFW interface */
 	bl	decompress_kernel
 
 	/*
diff -urN linux-2.4.23-bk4/arch/ppc/boot/prep/misc.c linux-2.4.23-bk5/arch/ppc/boot/prep/misc.c
--- linux-2.4.23-bk4/arch/ppc/boot/prep/misc.c	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/prep/misc.c	2003-12-07 02:49:59.000000000 -0800
@@ -18,6 +18,7 @@
 #include <asm/bootinfo.h>
 #include <asm/mmu.h>
 #include <asm/byteorder.h>
+#include "of1275.h"
 #include "nonstdio.h"
 #include "zlib.h"
 
@@ -54,7 +55,6 @@
 RESIDUAL hold_resid_buf;
 RESIDUAL *hold_residual = &hold_resid_buf;
 unsigned long initrd_size = 0;
-unsigned long orig_MSR;
 
 char *zimage_start;
 int zimage_size;
@@ -67,14 +67,9 @@
 #endif /* CONFIG_VGA_CONSOLE */
 
 extern int CRT_tstc(void);
-extern void of_init(void *handler);
-extern int of_finddevice(const char *device_specifier, int *phandle);
-extern int of_getprop(int phandle, const char *name, void *buf, int buflen,
-		int *size);
 extern int vga_init(unsigned char *ISA_mem);
 extern void gunzip(void *, int, unsigned char *, int *);
 
-extern void _put_MSR(unsigned int val);
 extern unsigned long serial_init(int chan, void *ignored);
 extern void serial_fixups(void);
 
@@ -119,6 +114,27 @@
 }
 #endif /* CONFIG_VGA_CONSOLE */
 
+static void
+get_of_args(void)
+{
+	int size;
+	phandle chosen;
+	char buf[256];
+
+	/* Get bootargs property of /chosen node */
+	if (!(chosen = finddevice("/chosen")))
+		return;
+
+	if (getprop(chosen, "bootargs", buf, sizeof(buf)) != 4)
+		return;
+
+	if (size > sizeof(cmd_buf))
+		size = sizeof(cmd_buf);
+
+	if (size > 1) /* includes null-terminator */
+		memcpy(cmd_buf, buf, size);
+}
+
 unsigned long
 decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
 		  RESIDUAL *residual, void *OFW_interface)
@@ -131,14 +147,13 @@
 	char *cp;
 	/* Default to 32MiB memory. */
 	unsigned long TotalMemory = 0x02000000;
-	int dev_handle;
-	int mem_info[2];
-	int res, size;
-	unsigned char board_type;
-	unsigned char base_mod;
 	int start_multi = 0;
 	unsigned int pci_viddid, pci_did, tulip_pci_base, tulip_base;
 
+	/* If we have Open Firmware, initialise it immediately */
+	if (OFW_interface)
+		ofinit(OFW_interface);
+
 	serial_fixups();
 	com_port = serial_init(0, NULL);
 #if defined(CONFIG_VGA_CONSOLE)
@@ -175,7 +190,8 @@
 		/* Is this Motorola PPCBug? */
 		if ((1 & residual->VitalProductData.FirmwareSupports) &&
 		    (1 == residual->VitalProductData.FirmwareSupplier)) {
-			board_type = inb(0x800) & 0xF0;
+			unsigned char base_mod;
+			unsigned char board_type = inb(0x800) & 0xF0;
 
 			/*
 			 * Reset the onboard 21x4x Ethernet
@@ -231,35 +247,23 @@
 		 * we don't try this on a PReP box without OF
 		 *     -- Cort
 		 */
-		while (OFW_interface && ((unsigned long)OFW_interface < 0x10000000) )
+		while (OFW_interface)
 		{
-			/* We need to restore the slightly inaccurate
-			 * MSR so that OpenFirmware will behave. -- Tom
-			 */
-			_put_MSR(orig_MSR);
-			of_init(OFW_interface);
+			phandle dev_handle;
+			int mem_info[2];
 
 			/* get handle to memory description */
-			res = of_finddevice("/memory@0",
-					    &dev_handle);
-			if (res)
+			if (!(dev_handle = finddevice("/memory@0")))
 				break;
 
 			/* get the info */
-			res = of_getprop(dev_handle,
-					 "reg",
-					 mem_info,
-					 sizeof(mem_info),
-					 &size);
-			if (res)
+			if (getprop(dev_handle, "reg", mem_info,
+						sizeof(mem_info) != 8))
 				break;
 
 			TotalMemory = mem_info[1];
 			break;
 		}
-
-		/* Enforce a sane MSR for booting. */
-		_put_MSR(MSR_IP);
         }
 
 	/* assume the chunk below 8M is free */
@@ -300,6 +304,10 @@
 	if (keyb_present)
 		CRT_tstc();  /* Forces keyboard to be initialized */
 
+	/* If we have OF then try to get args from there */
+	if (OFW_interface)
+		get_of_args();
+
 	puts("\nLinux/PPC load: ");
 	cp = cmd_line;
 	memcpy (cmd_line, cmd_preset, sizeof(cmd_preset));
@@ -338,6 +346,18 @@
 	*cp = 0;
 	puts("\nUncompressing Linux...");
 
+	/*
+	 * If we have OF, then we have deferred setting the MSR.
+	 * We must set it now because we are about to overwrite
+	 * the exception table.  The new MSR value will disable
+	 * machine check exceptions and point the exception table
+	 * to the ROM.
+	 */
+	if (OFW_interface) {
+		mtmsr(MSR_IP | MSR_FP);
+		asm volatile("isync");
+	}
+
 	gunzip(0, 0x400000, zimage_start, &zimage_size);
 	puts("done.\n");
 
diff -urN linux-2.4.23-bk4/arch/ppc/boot/prep/of1275.c linux-2.4.23-bk5/arch/ppc/boot/prep/of1275.c
--- linux-2.4.23-bk4/arch/ppc/boot/prep/of1275.c	2003-06-13 07:51:31.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/prep/of1275.c	1969-12-31 16:00:00.000000000 -0800
@@ -1,427 +0,0 @@
-/* Open Firmware Client Interface */
-
-
-#include "of1275.h"
-
-
-static int (*of_server)(void *) = (int(*)(void*))-1;
-
-void
-of_init(void *handler)
-{
-	of_server = (int(*)(void*))handler;
-}
-
-
-/* 6.3.2.1 Client interface */
-
-
-int
-of_test(const char *name, int *missing)
-{
-	int result;
-	static of_test_service s;
-	s.service = "test";
-	s.n_args = 1;
-	s.n_returns = 1;
-	s.name = name;
-	result = of_server(&s);
-	*missing = s.missing;
-	return result;
-}
-
-
-/* 6.3.2.2 Device tree */
-
-
-int
-of_peer(int phandle, int *sibling_phandle)
-{
-	int result;
-	static of_peer_service s;
-	s.service = "peer";
-	s.n_args = 1;
-	s.n_returns = 1;
-	s.phandle = phandle;
-	result = of_server(&s);
-	*sibling_phandle = s.sibling_phandle;
-	return result;
-}
-
-int
-of_child(int phandle, int *child_phandle)
-{
-	int result;
-	static of_child_service s;
-	s.service = "child";
-	s.n_args = 1;
-	s.n_returns = 1;
-	s.phandle = phandle;
-	result = of_server(&s);
-	*child_phandle = s.child_phandle;
-	return result;
-}
-
-int
-of_parent(int phandle, int *parent_phandle)
-{
-	int result;
-	static of_parent_service s;
-	s.service = "parent";
-	s.n_args = 1;
-	s.n_returns = 1;
-	s.phandle = phandle;
-	result = of_server(&s);
-	*parent_phandle = s.parent_phandle;
-	return result;
-}
-
-int
-of_instance_to_package(int ihandle, int *phandle)
-{
-	int result;
-	static of_instance_to_package_service s;
-	s.service = "instance-to-package";
-	s.n_args = 1;
-	s.n_returns = 1;
-	s.ihandle = ihandle;
-	result = of_server(&s);
-	*phandle = s.phandle;
-	return result;
-}
-
-int
-of_getproplen(int phandle, const char *name, int *proplen)
-{
-	int result;
-	static of_getproplen_service s;
-	s.service = "getproplen";
-	s.n_args = 2;
-	s.n_returns = 1;
-	s.phandle = phandle;
-	s.name = name;
-	result = of_server(&s);
-	*proplen = s.proplen;
-	return result;
-}
-
-int
-of_getprop(int phandle, const char *name, void *buf, int buflen, int *size)
-{
-	int result;
-	static of_getprop_service s;
-	s.service = "getprop";
-	s.n_args = 4;
-	s.n_returns = 1;
-	s.phandle = phandle;
-	s.name = name;
-	s.buf = buf;
-	s.buflen = buflen;
-	result = of_server(&s);
-	*size = s.size;
-	return result;
-}
-
-int
-of_nextprop(int phandle, const char *previous, void *buf, int *flag)
-{
-	int result;
-	static of_nextprop_service s;
-	s.service = "nextprop";
-	s.n_args = 3;
-	s.n_returns = 1;
-	s.phandle = phandle;
-	s.previous = previous;
-	s.buf = buf;
-	result = of_server(&s);
-	*flag = s.flag;
-	return result;
-}
-
-int
-of_setprop(int phandle, const char *name, void *buf, int len, int *size)
-{
-	int result;
-	static of_setprop_service s;
-	s.service = "setprop";
-	s.n_args = 4;
-	s.n_returns = 1;
-	s.phandle = phandle;
-	s.name = name;
-	s.buf = buf;
-	s.len = len;
-	result = of_server(&s);
-	*size = s.size;
-	return result;
-}
-
-int
-of_canon(const char *device_specifier, void *buf, int buflen, int *length)
-{
-	int result;
-	static of_canon_service s;
-	s.service = "canon";
-	s.n_args = 3;
-	s.n_returns = 1;
-	s.device_specifier = device_specifier;
-	s.buf = buf;
-	s.buflen = buflen;
-	result = of_server(&s);
-	*length = s.length;
-	return result;
-}
-
-int
-of_finddevice(const char *device_specifier, int *phandle)
-{
-	int result;
-	static of_finddevice_service s;
-	s.service = "finddevice";
-	s.n_args = 1;
-	s.n_returns = 1;
-	s.device_specifier = device_specifier;
-	result = of_server(&s);
-	*phandle = s.phandle;
-	return result;
-}
-
-int
-of_instance_to_path(int ihandle, void *buf, int buflen, int *length)
-{
-	int result;
-	static of_instance_to_path_service s;
-	s.service = "instance-to-path";
-	s.n_args = 3;
-	s.n_returns = 1;
-	s.ihandle = ihandle;
-	s.buf = buf;
-	s.buflen = buflen;
-	result = of_server(&s);
-	*length = s.length;
-	return result;
-}
-
-int
-of_package_to_path(int phandle, void *buf, int buflen, int *length)
-{
-	int result;
-	static of_package_to_path_service s;
-	s.service = "package-to-path";
-	s.n_args = 3;
-	s.n_returns = 1;
-	s.phandle = phandle;
-	s.buf = buf;
-	s.buflen = buflen;
-	result = of_server(&s);
-	*length = s.length;
-	return result;
-}
-
-/* int of_call_method(const char *method, int ihandle, ...); */
-
-
-/* 6.3.2.3 Device I/O */
-
-
-int
-of_open(const char *device_specifier, int *ihandle)
-{
-	int result;
-	static of_open_service s;
-	s.service = "open";
-	s.n_args = 1;
-	s.n_returns = 1;
-	s.device_specifier = device_specifier;
-	result = of_server(&s);
-	*ihandle = s.ihandle;
-	return result;
-}
-
-int
-of_close(int ihandle)
-{
-	int result;
-	static of_close_service s;
-	s.service = "close";
-	s.n_args = 1;
-	s.n_returns = 0;
-	s.ihandle = ihandle;
-	result = of_server(&s);
-	return result;
-}
-
-int
-of_read(int ihandle, void *addr, int len, int *actual)
-{
-	int result;
-	static of_read_service s;
-	s.service = "read";
-	s.n_args = 3;
-	s.n_returns = 1;
-	s.ihandle = ihandle;
-	s.addr = addr;
-	s.len = len;
-	result = of_server(&s);
-	*actual = s.actual;
-	return result;
-}
-
-int
-of_write(int ihandle, void *addr, int len, int *actual)
-{
-	int result;
-	static of_write_service s;
-	s.service = "write";
-	s.n_args = 3;
-	s.n_returns = 1;
-	s.ihandle = ihandle;
-	s.addr = addr;
-	s.len = len;
-	result = of_server(&s);
-	*actual = s.actual;
-	return result;
-}
-
-int
-of_seek(int ihandle, int pos_hi, int pos_lo, int *status)
-{
-	int result;
-	static of_seek_service s;
-	s.service = "seek";
-	s.n_args = 3;
-	s.n_returns = 1;
-	s.ihandle = ihandle;
-	s.pos_hi = pos_hi;
-	s.pos_lo = pos_lo;
-	result = of_server(&s);
-	*status = s.status;
-	return result;
-}
-
-
-/* 6.3.2.4 Memory */
-
-
-int
-of_claim(void *virt, int size, int align, void **baseaddr)
-{
-	int result;
-	static of_claim_service s;
-	s.service = "claim";
-	s.n_args = 3;
-	s.n_returns = 1;
-	s.virt = virt;
-	s.size = size;
-	s.align = align;
-	result = of_server(&s);
-	*baseaddr = s.baseaddr;
-	return result;
-}
-
-int
-of_release(void *virt, int size)
-{
-	int result;
-	static of_release_service s;
-	s.service = "release";
-	s.n_args = 2;
-	s.n_returns = 0;
-	s.virt = virt;
-	s.size = size;
-	result = of_server(&s);
-	return result;
-}
-
-
-/* 6.3.2.5 Control transfer */
-
-
-int
-of_boot(const char *bootspec)
-{
-	int result;
-	static of_boot_service s;
-	s.service = "boot";
-	s.n_args = 1;
-	s.n_returns = 0;
-	s.bootspec = bootspec;
-	result = of_server(&s);
-	return result;
-}
-
-int
-of_enter(void)
-{
-	int result;
-	static of_enter_service s;
-	s.service = "enter";
-	s.n_args = 0;
-	s.n_returns = 0;
-	result = of_server(&s);
-	return result;
-}
-
-int
-of_exit(void)
-{
-	int result;
-	static of_exit_service s;
-	s.service = "exit";
-	s.n_args = 0;
-	s.n_returns = 0;
-	result = of_server(&s);
-	return result;
-}
-
-/* int of_chain(void *virt, int size, void *entry, void *args, int len); */
-
-
-/* 6.3.2.6 User interface */
-
-
-/* int of_interpret(const char *arg, ...); */
-
-int
-of_set_callback(void *newfunc, void **oldfunc)
-{
-	int result;
-	static of_set_callback_service s;
-	s.service = "set-callback";
-	s.n_args = 1;
-	s.n_returns = 1;
-	s.newfunc = newfunc;
-	result = of_server(&s);
-	*oldfunc = s.oldfunc;
-	return result;
-}
-
-int
-of_set_symbol_lookup(void *sym_to_value, void *value_to_sym)
-{
-	int result;
-	static of_set_symbol_lookup_service s;
-	s.service = "set-symbol-lookup";
-	s.n_args = 2;
-	s.n_returns = 0;
-	s.sym_to_value = sym_to_value;
-	s.value_to_sym = s.value_to_sym;
-	result = of_server(&s);
-	return result;
-}
-
-
-/* 6.3.2.7 Time */
-
-
-int
-of_milliseconds(int *ms)
-{
-	int result;
-	static of_milliseconds_service s;
-	s.service = "milliseconds";
-	s.n_args = 0;
-	s.n_returns = 1;
-	result = of_server(&s);
-	*ms = s.ms;
-	return result;
-}
diff -urN linux-2.4.23-bk4/arch/ppc/boot/prep/of1275.h linux-2.4.23-bk5/arch/ppc/boot/prep/of1275.h
--- linux-2.4.23-bk4/arch/ppc/boot/prep/of1275.h	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/prep/of1275.h	1969-12-31 16:00:00.000000000 -0800
@@ -1,421 +0,0 @@
-/* 6.3.2.1 Client interface */
-
-
-typedef struct _of_test_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	const char *name;
-	/*out*/
-	int missing;
-} of_test_service;
-
-int of_test(const char *name, int *missing);
-
-
-/* 6.3.2.2 Device tree */
-
-
-typedef struct _of_peer_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int phandle;
-	/*out*/
-	int sibling_phandle;
-} of_peer_service;
-
-int of_peer(int phandle, int *sibling_phandle);
-
-
-typedef struct _of_child_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int phandle;
-	/*out*/
-	int child_phandle;
-} of_child_service;
-
-int of_child(int phandle, int *child_phandle);
-
-
-typedef struct _of_parent_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int phandle;
-	/*out*/
-	int parent_phandle;
-} of_parent_service;
-
-int of_child(int phandle, int *parent_phandle);
-
-
-typedef struct _of_instance_to_package_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int ihandle;
-	/*out*/
-	int phandle;
-} of_instance_to_package_service;
-
-int of_instance_to_package(int ihandle, int *phandle);
-
-
-typedef struct _of_getproplen_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int phandle;
-	const char *name;
-	/*out*/
-	int proplen;
-} of_getproplen_service;
-
-int of_getproplen(int phandle, const char *name, int *proplen);
-
-
-typedef struct _of_getprop_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int phandle;
-	const char *name;
-	void *buf;
-	int buflen;
-	/*out*/
-	int size;
-} of_getprop_service;
-
-int of_getprop(int phandle, const char *name, void *buf, int buflen,
-	       int *size);
-
-
-typedef struct _of_nextprop_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int phandle;
-	const char *previous;
-	void *buf;
-	/*out*/
-	int flag;
-} of_nextprop_service;
-
-int of_nextprop(int phandle, const char *previous, void *buf, int *flag);
-
-
-typedef struct _of_setprop_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int phandle;
-	const char *name;
-	void *buf;
-	int len;
-	/*out*/
-	int size;
-} of_setprop_service;
-
-int of_setprop(int phandle, const char *name, void *buf, int len, int *size);
-
-
-typedef struct _of_canon_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	const char *device_specifier;
-	void *buf;
-	int buflen;
-	/*out*/
-	int length;
-} of_canon_service;
-
-int of_canon(const char *device_specifier, void *buf, int buflen, int *length);
-
-
-typedef struct _of_finddevice_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	const char *device_specifier;
-	/*out*/
-	int phandle;
-} of_finddevice_service;
-
-int of_finddevice(const char *device_specifier, int *phandle);
-
-
-typedef struct _of_instance_to_path_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int ihandle;
-	void *buf;
-	int buflen;
-	/*out*/
-	int length;
-} of_instance_to_path_service;
-
-int of_instance_to_path(int ihandle, void *buf, int buflen, int *length);
-
-
-typedef struct _of_package_to_path_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int phandle;
-	void *buf;
-	int buflen;
-	/*out*/
-	int length;
-} of_package_to_path_service;
-
-int of_package_to_path(int phandle, void *buf, int buflen, int *length);
-
-
-typedef struct _of_call_method_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	const char *method;
-	int ihandle;
-	/*...*/
-	int args[0];
-} of_call_method_service;
-
-int of_call_method(const char *method, int ihandle, ...);
-
-
-/* 6.3.2.3 Device I/O */
-
-
-typedef struct _of_open_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	const char *device_specifier;
-	/*out*/
-	int ihandle;
-} of_open_service;
-
-int of_open(const char *device_specifier,
-	    int *ihandle);
-
-
-typedef struct _of_close_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int ihandle;
-	/*out*/
-} of_close_service;
-
-int of_close(int ihandle);
-
-
-typedef struct _of_read_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int ihandle;
-	void *addr;
-	int len;
-	/*out*/
-	int actual;
-} of_read_service;
-
-int of_read(int ihandle, void *addr, int len, int *actual);
-
-
-typedef struct _of_write_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int ihandle;
-	void *addr;
-	int len;
-	/*out*/
-	int actual;
-} of_write_service;
-
-int of_write(int ihandle, void *addr, int len, int *actual);
-
-
-typedef struct _of_seek_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	int ihandle;
-	int pos_hi;
-	int pos_lo;
-	/*out*/
-	int status;
-} of_seek_service;
-
-int of_seek(int ihandle, int pos_hi, int pos_lo, int *status);
-
-
-/* 6.3.2.4 Memory */
-
-
-typedef struct _of_claim_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	void *virt;
-	int size;
-	int align;
-	/*out*/
-	void *baseaddr;
-} of_claim_service;
-
-int of_claim(void *virt, int size, int align, void **baseaddr);
-
-
-typedef struct _of_release_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	void *virt;
-	int size;
-	int align;
-	/*out*/
-} of_release_service;
-
-int of_release(void *virt, int size);
-
-
-/* 6.3.2.5 Control transfer */
-
-
-typedef struct _of_boot_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	const char *bootspec;
-	/*out*/
-} of_boot_service;
-
-int of_boot(const char *bootspec);
-
-
-typedef struct _of_enter_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	/*out*/
-} of_enter_service;
-
-int of_enter(void);
-
-
-typedef struct _of_exit_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	/*out*/
-} of_exit_service;
-
-int of_exit(void);
-
-
-typedef struct _of_chain_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	void *virt;
-	int size;
-	void *entry;
-	void *args;
-	int len;
-	/*out*/
-} of_chain_service;
-
-int of_chain(void *virt, int size, void *entry, void *args, int len);
-
-
-/* 6.3.2.6 User interface */
-
-
-typedef struct _of_interpret_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	const char *cmd;
-	int args[0];
-	/*...*/
-	/*out*/
-	/*...*/
-} of_interpret_service;
-
-int of_interpret(const char *arg, ...);
-
-
-typedef struct _of_set_callback_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	void *newfunc;
-	/*out*/
-	void *oldfunc;
-} of_set_callback_service;
-
-int of_set_callback(void *newfunc, void **oldfunc);
-
-
-typedef struct _of_set_symbol_lookup_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	void *sym_to_value;
-	void *value_to_sym;
-	/*out*/
-} of_set_symbol_lookup_service;
-
-int of_set_symbol_lookup(void *sym_to_value, void *value_to_sym);
-
-
-/* 6.3.2.7 Time */
-
-
-typedef struct _of_milliseconds_service {
-	const char *service;
-	int n_args;
-	int n_returns;
-	/*in*/
-	/*out*/
-	int ms;
-} of_milliseconds_service;
-
-int of_milliseconds(int *ms);
diff -urN linux-2.4.23-bk4/arch/ppc/boot/prep/vreset.c linux-2.4.23-bk5/arch/ppc/boot/prep/vreset.c
--- linux-2.4.23-bk4/arch/ppc/boot/prep/vreset.c	2003-06-13 07:51:31.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/boot/prep/vreset.c	2003-12-07 02:49:59.000000000 -0800
@@ -389,7 +389,7 @@
 extern void puts(const char *);
 static void unlockS3(void);
 
-static void inline
+static inline void
 outw(int port, unsigned short val)
 {
 	outb(port, val >> 8);
@@ -691,14 +691,14 @@
   unsigned long regs[NPCIREGS];
 } PCI_slots [NSLOTS] = {
 
-    { (unsigned long *)0x80808000, 0xDEADBEEF },   /* onboard */
-    { (unsigned long *)0x80800800, 0xDEADBEEF },   /* onboard */
-    { (unsigned long *)0x80801000, 0xDEADBEEF },   /* onboard */
-    { (unsigned long *)0x80802000, 0xDEADBEEF },   /* onboard */
-    { (unsigned long *)0x80804000, 0xDEADBEEF },   /* onboard */
-    { (unsigned long *)0x80810000, 0xDEADBEEF },   /* slot A/1 */
-    { (unsigned long *)0x80820000, 0xDEADBEEF },   /* slot B/2 */
-    { (unsigned long *)0x80840000, 0xDEADBEEF }    /* slot C/3 */
+    { (unsigned long *)0x80808000, {0xDEADBEEF,} },   /* onboard */
+    { (unsigned long *)0x80800800, {0xDEADBEEF,} },   /* onboard */
+    { (unsigned long *)0x80801000, {0xDEADBEEF,} },   /* onboard */
+    { (unsigned long *)0x80802000, {0xDEADBEEF,} },   /* onboard */
+    { (unsigned long *)0x80804000, {0xDEADBEEF,} },   /* onboard */
+    { (unsigned long *)0x80810000, {0xDEADBEEF,} },   /* slot A/1 */
+    { (unsigned long *)0x80820000, {0xDEADBEEF,} },   /* slot B/2 */
+    { (unsigned long *)0x80840000, {0xDEADBEEF,} }    /* slot C/3 */
 };
 
 
diff -urN linux-2.4.23-bk4/arch/ppc/config.in linux-2.4.23-bk5/arch/ppc/config.in
--- linux-2.4.23-bk4/arch/ppc/config.in	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/config.in	2003-12-07 02:49:59.000000000 -0800
@@ -270,6 +270,9 @@
   if [ "$CONFIG_TASK_SIZE_BOOL" = "y" ]; then
     hex "  Size of user task space" CONFIG_TASK_SIZE 0x80000000
   fi
+  if [ "$CONFIG_8xx" = "y" ]; then
+    bool "Pinned Kernel TLBs (86x ONLY)" CONFIG_PIN_TLB
+  fi
 fi
 
 if [ "$CONFIG_HIGHMEM_START_BOOL" != "y" ]; then
diff -urN linux-2.4.23-bk4/arch/ppc/kernel/cpu_setup_6xx.S linux-2.4.23-bk5/arch/ppc/kernel/cpu_setup_6xx.S
--- linux-2.4.23-bk4/arch/ppc/kernel/cpu_setup_6xx.S	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/kernel/cpu_setup_6xx.S	2003-12-07 02:49:59.000000000 -0800
@@ -104,8 +104,8 @@
 
 /* 7400 <= rev 2.7 and 7410 rev = 1.0 suffer from some
  * erratas we work around here.
- * Moto MPC710CE.pdf describes them, those are errata
- * #3, #4 and #5
+ * Moto MPC7410CE.pdf describes them, those are errata
+ * #3, #4 and #5 (7400 erratas #13, #14 and #15).
  * Note that we assume the firmware didn't choose to
  * apply other workarounds (there are other ones documented
  * in the .pdf). It appear that Apple firmware only works
@@ -155,7 +155,20 @@
 BEGIN_FTR_SECTION
 	oris	r11,r11,HID0_DPM@h	/* enable dynamic power mgmt */
 END_FTR_SECTION_IFCLR(CPU_FTR_NO_DPM)
-	li	r3,HID0_SPD
+
+	/* 7400 Errata #7, don't enable SGE on < Rev 2.1 */
+	mfpvr	r10
+	rlwinm	r3,r10,16,16,31
+	cmplwi	r3,0x000c
+	bne	1f			/* Not a 7400. */
+	andi	r3,r10,0x0f0f
+	cmpwi	0,r3,0x0200
+	bgt	1f			/* Rev >= 2.1 */
+	li	r3,HID0_SGE		/* 7400 rev < 2.1, clear SGE. */
+	b	2f
+
+1:	li	r3,0			/* Don't clear SGE. */
+2:	ori	r3,r3,HID0_SPD
 	andc	r11,r11,r3		/* clear SPD: enable speculative */
  	li	r3,0
  	mtspr	ICTC,r3			/* Instruction Cache Throttling off */
@@ -223,9 +236,17 @@
 	oris	r11,r11,HID0_DPM@h	/* enable dynamic power mgmt */
 END_FTR_SECTION_IFCLR(CPU_FTR_NO_DPM)
 
+	/* We only want to disable BTIC on 7457's */
+	mfpvr	r3
+	rlwinm	r3,r3,16,16,31
+	cmplwi	r3,0x8002
+	li	r3,0			/* Assume we don't want to clear BTIC. */
+	bne	2f			/* Not a 7457. */
+	li	r3,HID0_BTIC		/* 7457, clear BTIC. */
+
 	/* All of the bits we have to clear....
 	 */
-	li	r3,HID0_SPD | HID0_NOPDST | HID0_NOPTI
+2:	ori	r3,r3,HID0_SPD | HID0_NOPDST | HID0_NOPTI
 	andc	r11,r11,r3		/* clear SPD: enable speculative */
  	li	r3,0
 
diff -urN linux-2.4.23-bk4/arch/ppc/kernel/cputable.c linux-2.4.23-bk5/arch/ppc/kernel/cputable.c
--- linux-2.4.23-bk4/arch/ppc/kernel/cputable.c	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/kernel/cputable.c	2003-12-07 02:49:59.000000000 -0800
@@ -144,7 +144,7 @@
     	0xffffff00, 0x70000100, "750FX",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
 	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_CAN_NAP |
-	CPU_FTR_DUAL_PLL_750FX | CPU_FTR_NO_DPM,
+	CPU_FTR_750FX | CPU_FTR_NO_DPM,
 	COMMON_PPC,
 	32, 32,
 	__setup_cpu_750
@@ -153,7 +153,7 @@
     	0xffffffff, 0x70000200, "750FX",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
 	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_CAN_NAP |
-	CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NO_DPM,
+	CPU_FTR_750FX | CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NO_DPM,
 	COMMON_PPC,
 	32, 32,
 	__setup_cpu_750
@@ -162,7 +162,7 @@
     	0xffff0000, 0x70000000, "750FX",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
 	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_CAN_NAP |
-	CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS,
+	CPU_FTR_750FX | CPU_FTR_HAS_HIGH_BATS,
 	COMMON_PPC,
 	32, 32,
 	__setup_cpu_750fx
@@ -202,6 +202,15 @@
 	32, 32,
 	__setup_cpu_7410
     },
+    {	/* 7450 1.x - no doze/nap */
+    	0xffffff00, 0x80000100, "7450",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450,
+	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
+	32, 32,
+	__setup_cpu_745x
+    },
     {	/* 7450 2.0 - no doze/nap */
     	0xffffffff, 0x80000200, "7450",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
@@ -276,6 +285,14 @@
 	32, 32,
 	__setup_cpu_603
     },
+    {	/* 8280 is a G2_LE (603e core, plus some) */
+	0x7fff0000, 0x00820000, "8280",
+	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
+	CPU_FTR_CAN_NAP | CPU_FTR_HAS_HIGH_BATS,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_603
+    },
     {	/* default match, we assume split I/D cache & TB (non-601)... */
     	0x00000000, 0x00000000, "(generic PPC)",
     	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
diff -urN linux-2.4.23-bk4/arch/ppc/kernel/head_8xx.S linux-2.4.23-bk5/arch/ppc/kernel/head_8xx.S
--- linux-2.4.23-bk4/arch/ppc/kernel/head_8xx.S	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/kernel/head_8xx.S	2003-12-07 02:49:59.000000000 -0800
@@ -341,7 +341,7 @@
 	beq	2f		/* If zero, don't try to find a pte */
 
 	/* We have a pte table, so load the MI_TWC with the attributes
-	 * for this page, which has only bit 31 set.
+	 * for this "segment."
 	 */
 	tophys(r21,r21)
 	ori	r21,r21,1		/* Set valid bit */
@@ -350,7 +350,7 @@
 	stw	r3, 12(r0)
 	lwz	r3, 12(r0)
 #endif
-	mtspr	MI_TWC, r21	/* Set page attributes */
+	mtspr	MI_TWC, r21	/* Set segment attributes */
 #ifdef CONFIG_8xx_CPU6
 	li	r3, 0x3b80
 	stw	r3, 12(r0)
@@ -369,8 +369,6 @@
 	 * set.  All other Linux PTE bits control the behavior
 	 * of the MMU.
 	 */
-	li	r21, 0x0600
-	andc	r20, r20, r21		/* Clear 21, 22 */
 	li	r21, 0x00f0
 	rlwimi	r20, r21, 0, 24, 28	/* Set 24-27, clear 28 */
 
@@ -463,8 +461,6 @@
 	 * set.  All other Linux PTE bits control the behavior
 	 * of the MMU.
 	 */
-	li	r21, 0x0600
-	andc	r20, r20, r21		/* Clear 21, 22 */
 	li	r21, 0x00f0
 	rlwimi	r20, r21, 0, 24, 28	/* Set 24-27, clear 28 */
 
@@ -608,8 +604,6 @@
 	 * set.  All other Linux PTE bits control the behavior
 	 * of the MMU.
 	 */
-	li	r21, 0x0600
-	andc	r20, r20, r21		/* Clear 21, 22 */
 	li	r21, 0x00f0
 	rlwimi	r20, r21, 0, 24, 28	/* Set 24-27, clear 28 */
 
diff -urN linux-2.4.23-bk4/arch/ppc/kernel/idle_6xx.S linux-2.4.23-bk5/arch/ppc/kernel/idle_6xx.S
--- linux-2.4.23-bk4/arch/ppc/kernel/idle_6xx.S	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/kernel/idle_6xx.S	2003-12-07 02:49:59.000000000 -0800
@@ -52,7 +52,7 @@
 	mfspr	r4,SPRN_HID1
 	addis	r6,r5,nap_save_hid1@ha
 	stw	r4,nap_save_hid1@l(r6)
-END_FTR_SECTION_IFSET(CPU_FTR_DUAL_PLL_750FX)
+END_FTR_SECTION_IFSET(CPU_FTR_750FX)
 	blr
 
 /*
@@ -139,7 +139,7 @@
 	oris	r4,r4,0x0001
 	mtspr	SPRN_HID1,r4
 1:
-END_FTR_SECTION_IFSET(CPU_FTR_DUAL_PLL_750FX)
+END_FTR_SECTION_IFSET(CPU_FTR_750FX)
 
 	/* Go to NAP or DOZE now */
 	mfspr	r4,SPRN_HID0
@@ -210,7 +210,7 @@
 	addis	r22,r24,(nap_save_hid1-KERNELBASE)@ha
 	lwz	r22,nap_save_hid1@l(r22)
 	mtspr	SPRN_HID1, r22
-END_FTR_SECTION_IFSET(CPU_FTR_DUAL_PLL_750FX)
+END_FTR_SECTION_IFSET(CPU_FTR_750FX)
 	b	transfer_to_handler_cont
 
 	.data
diff -urN linux-2.4.23-bk4/arch/ppc/kernel/ppc_htab.c linux-2.4.23-bk5/arch/ppc/kernel/ppc_htab.c
--- linux-2.4.23-bk4/arch/ppc/kernel/ppc_htab.c	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/kernel/ppc_htab.c	2003-12-07 02:49:59.000000000 -0800
@@ -509,40 +509,59 @@
 			left -= len;
 			_set_L2CR(val);
 		} else {
+			int is750fx = cur_cpu_spec[0]->cpu_features & CPU_FTR_750FX;
 			p = buf;
 			if (!first)
 				*p++ = '\t';
 			val = _get_L2CR();
 			p += sprintf(p, "0x%08x: ", val);
-			p += sprintf(p, " L2 %s", (val >> 31) & 1 ? "enabled" :
+			p += sprintf(p, " L2 %s, ", (val >> 31) & 1 ? "enabled" :
 				     	"disabled");
-			p += sprintf(p, ", %sparity", (val>>30)&1 ? "" : "no ");
+			if (!(val>>30&1))
+				p += sprintf(p, "no ");
+			if (is750fx)
+				p += sprintf(p, "ECC checkstop");
+			else
+				p += sprintf(p, "parity");
 
 			/* 75x & 74x0 have different L2CR than 745x */
 			if (!(cur_cpu_spec[0]->cpu_features &
 						CPU_FTR_SPEC7450)) {
-				p += sprintf(p, ", %s",
-					sizestrings[(val >> 28) & 3]);
-				p += sprintf(p, ", %s",
-					clockstrings[(val >> 25) & 7]);
-				p += sprintf(p, ", %s",
-					typestrings[(val >> 23) & 3]);
+				if (!is750fx) {
+					p += sprintf(p, ", %s",
+						     sizestrings[(val >> 28) & 3]);
+					p += sprintf(p, ", %s",
+						     clockstrings[(val >> 25) & 7]);
+					p += sprintf(p, ", %s",
+						     typestrings[(val >> 23) & 3]);
+				}
 				p += sprintf(p, "%s", (val>>22)&1 ?
-					", data only" : "");
-				p += sprintf(p, "%s", (val>>20)&1 ?
-					", ZZ enabled": "");
+					     ", data only" : "");
+				if (!is750fx) {
+					p += sprintf(p, "%s", (val>>20)&1 ?
+						     ", ZZ enabled": "");
+				}
 				p += sprintf(p, ", %s", (val>>19)&1 ?
 					"write-through" : "copy-back");
 				p += sprintf(p, "%s", (val>>18)&1 ?
 					", testing" : "");
-				p += sprintf(p, ", %sns hold",
-					holdstrings[(val>>16)&3]);
-				p += sprintf(p, "%s", (val>>15)&1 ?
-					", DLL slow" : "");
-				p += sprintf(p, "%s", (val>>14)&1 ?
-					", diff clock" :"");
-				p += sprintf(p, "%s", (val>>13)&1 ?
-					", DLL bypass" :"");
+				if (!is750fx) {
+					p += sprintf(p, ", %sns hold",
+						     holdstrings[(val>>16)&3]);
+					p += sprintf(p, "%s", (val>>15)&1 ?
+						     ", DLL slow" : "");
+					p += sprintf(p, "%s", (val>>14)&1 ?
+						     ", diff clock" :"");
+					p += sprintf(p, "%s", (val>>13)&1 ?
+						     ", DLL bypass" :"");
+				} else {
+					if ((val>>11)&1)
+						p += sprintf(p, ", lock way 0");
+					if ((val>>10)&1)
+						p += sprintf(p, ", lock way 1");
+					if ((val>>9)&1)
+						p += sprintf(p, ", Snoop Hit in Locked Line Error Enabled");
+				}
 			} else { /* 745x */
 				p += sprintf(p, ", %sinstn only", (val>>20)&1 ?
 					"" : "no ");
diff -urN linux-2.4.23-bk4/arch/ppc/kernel/setup.c linux-2.4.23-bk5/arch/ppc/kernel/setup.c
--- linux-2.4.23-bk4/arch/ppc/kernel/setup.c	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/kernel/setup.c	2003-12-07 02:49:59.000000000 -0800
@@ -258,7 +258,7 @@
 unsigned long
 early_init(int r3, int r4, int r5)
 {
-	extern char __bss_start, _end;
+	extern char __bss_start[], _end[];
  	unsigned long phys;
 	unsigned long offset = reloc_offset();
 
@@ -267,7 +267,7 @@
 
 	/* First zero the BSS -- use memset, some arches don't have
 	 * caches on yet */
-	memset_io(PTRRELOC(&__bss_start), 0, &_end - &__bss_start);
+	memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start);
 
 	/*
 	 * Identify the CPU type and fix up code sections
diff -urN linux-2.4.23-bk4/arch/ppc/mm/pgtable.c linux-2.4.23-bk5/arch/ppc/mm/pgtable.c
--- linux-2.4.23-bk4/arch/ppc/mm/pgtable.c	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-bk5/arch/ppc/mm/pgtable.c	2003-12-07 02:49:59.000000000 -0800
@@ -258,7 +258,7 @@
 
 	printk(KERN_INFO "Memory BAT mapping: BAT2=%ldMb, BAT3=%ldMb,"
 			" residual: %ldMb\n", __bat2 >> 20, __bat3 >> 20,
-			(total_lowmem - (__bat2 - __bat3)) >> 20);
+			(total_lowmem - (__bat2 + __bat3)) >> 20);
 
 	/* On SMP, we limit the lowmem to the area mapped with BATs.
 	 * We also assume nobody will do SMP with 601s
diff -urN linux-2.4.23-bk4/arch/ppc/platforms/prep_pci.c linux-2.4.23-bk5/arch/ppc/platforms/prep_pci.c
--- linux-2.4.23-bk4/arch/ppc/platforms/prep_pci.c	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.23-bk5/arch/ppc/platforms/prep_pci.c	2003-12-07 02:49:59.000000000 -0800
@@ -1141,8 +1141,6 @@
 prep_pcibios_fixup(void)
 {
         struct pci_dev *dev;
-        extern unsigned char *Motherboard_map;
-        extern unsigned char *Motherboard_routes;
 
 	prep_route_pci_interrupts();
 
diff -urN linux-2.4.23-bk4/drivers/char/serial.c linux-2.4.23-bk5/drivers/char/serial.c
--- linux-2.4.23-bk4/drivers/char/serial.c	2003-11-28 10:26:20.000000000 -0800
+++ linux-2.4.23-bk5/drivers/char/serial.c	2003-12-07 02:50:00.000000000 -0800
@@ -3746,7 +3746,14 @@
 		/* Check for Startech UART's */
 		serial_outp(info, UART_LCR, UART_LCR_DLAB);
 		if (serial_in(info, UART_EFR) == 0) {
+			serial_outp(info, UART_EFR, 0xA8);
+			if (serial_in(info, UART_EFR) == 0) {
+				/* We are a NS16552D/Motorola
+				 * 8xxx DUART, stop. */
+				goto out;
+			}
 			state->type = PORT_16650;
+			serial_outp(info, UART_EFR, 0);
 		} else {
 			serial_outp(info, UART_LCR, 0xBF);
 			if (serial_in(info, UART_EFR) == 0)
@@ -3795,6 +3802,7 @@
 		}
 	}
 #endif
+out:
 	serial_outp(info, UART_LCR, save_lcr);
 	if (state->type == PORT_16450) {
 		scratch = serial_in(info, UART_SCR);
diff -urN linux-2.4.23-bk4/include/asm-i386/timex.h linux-2.4.23-bk5/include/asm-i386/timex.h
--- linux-2.4.23-bk4/include/asm-i386/timex.h	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.23-bk5/include/asm-i386/timex.h	2003-12-07 02:50:06.000000000 -0800
@@ -40,14 +40,10 @@
 
 static inline cycles_t get_cycles (void)
 {
-#ifndef CONFIG_X86_TSC
-	return 0;
-#else
-	unsigned long long ret;
-
-	rdtscll(ret);
+	unsigned long long ret = 0;
+	if(cpu_has_tsc)
+		rdtscll(ret);
 	return ret;
-#endif
 }
 
 extern unsigned long cpu_khz;
diff -urN linux-2.4.23-bk4/include/asm-ppc/cputable.h linux-2.4.23-bk5/include/asm-ppc/cputable.h
--- linux-2.4.23-bk4/include/asm-ppc/cputable.h	2003-06-13 07:51:38.000000000 -0700
+++ linux-2.4.23-bk5/include/asm-ppc/cputable.h	2003-12-07 02:50:07.000000000 -0800
@@ -72,7 +72,7 @@
 #define CPU_FTR_L3CR			0x00000800
 #define CPU_FTR_L3_DISABLE_NAP		0x00001000
 #define CPU_FTR_NAP_DISABLE_L2_PR	0x00002000
-#define CPU_FTR_DUAL_PLL_750FX		0x00004000
+#define CPU_FTR_750FX			0x00004000
 #define CPU_FTR_NO_DPM			0x00008000
 #define CPU_FTR_HAS_HIGH_BATS		0x00010000
 
diff -urN linux-2.4.23-bk4/include/asm-ppc/pgtable.h linux-2.4.23-bk5/include/asm-ppc/pgtable.h
--- linux-2.4.23-bk4/include/asm-ppc/pgtable.h	2003-11-28 10:26:21.000000000 -0800
+++ linux-2.4.23-bk5/include/asm-ppc/pgtable.h	2003-12-07 02:50:07.000000000 -0800
@@ -149,6 +149,12 @@
  * that is where it exists in the MD_TWC, and bit 26 for writethrough.
  * These will get masked from the level 2 descriptor at TLB load time, and
  * copied to the MD_TWC before it gets loaded.
+ * Large page sizes added.  We currently support two sizes, 4K and 8M.
+ * This also allows a TLB hander optimization because we can directly
+ * load the PMD into MD_TWC.  The 8M pages are only used for kernel
+ * mapping of well known areas.  The PMD (PGD) entries contain control
+ * flags in addition to the address, so care must be taken that the
+ * software no longer assumes these are only pointers.
  */
 
 /*
@@ -297,14 +303,21 @@
  */
 #define _PAGE_EXEC	0x0008	/* software: i-cache coherency required */
 #define _PAGE_GUARDED	0x0010	/* software: guarded access */
-#define _PAGE_WRITETHRU 0x0020	/* software: use writethrough cache */
+#define _PAGE_DIRTY	0x0020	/* software: page changed */
 #define _PAGE_RW	0x0040	/* software: user write access allowed */
 #define _PAGE_ACCESSED	0x0080	/* software: page referenced */
 
+/* Setting any bits in the nibble with the follow two controls will
+ * require a TLB exception handler change.  It is assumed unused bits
+ * are always zero.
+ */
 #define _PAGE_HWWRITE	0x0100	/* h/w write enable: never set in Linux PTE */
-#define _PAGE_DIRTY	0x0200	/* software: page changed */
 #define _PAGE_USER	0x0800	/* One of the PP bits, the other is USER&~RW */
 
+#define _PMD_PRESENT	PAGE_MASK
+#define _PMD_PAGE_MASK	0x000c
+#define _PMD_PAGE_8M	0x000c
+
 /*
  * The 8xx TLB miss handler allegedly sets _PAGE_ACCESSED in the PTE
  * for an address even if _PAGE_PRESENT is not set, as a performance
@@ -328,6 +341,7 @@
 #define _PAGE_ACCESSED	0x100	/* R: page referenced */
 #define _PAGE_EXEC	0x200	/* software: i-cache coherency required */
 #define _PAGE_RW	0x400	/* software: user write access allowed */
+#define _PMD_PRESENT	PAGE_MASK
 
 #define _PTE_NONE_MASK	_PAGE_HASHPTE
 
@@ -429,8 +443,8 @@
 #define pte_clear(ptep)		do { set_pte((ptep), __pte(0)); } while (0)
 
 #define pmd_none(pmd)		(!pmd_val(pmd))
-#define	pmd_bad(pmd)		((pmd_val(pmd) & ~PAGE_MASK) != 0)
-#define	pmd_present(pmd)	((pmd_val(pmd) & PAGE_MASK) != 0)
+#define	pmd_bad(pmd)		((pmd_val(pmd) & _PMD_PRESENT) == 0)
+#define	pmd_present(pmd)	((pmd_val(pmd) & _PMD_PRESENT) != 0)
 #define	pmd_clear(pmdp)		do { pmd_val(*(pmdp)) = 0; } while (0)
 
 #define pte_page(x)		(mem_map+(unsigned long)((pte_val(x)-PPC_MEMSTART) >> PAGE_SHIFT))
@@ -445,7 +459,6 @@
 static inline int pgd_bad(pgd_t pgd)		{ return 0; }
 static inline int pgd_present(pgd_t pgd)	{ return 1; }
 #define pgd_clear(xp)				do { } while (0)
-
 #define pgd_page(pgd) \
 	((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
 
@@ -576,7 +589,7 @@
 
 #define pte_same(A,B)	(((pte_val(A) ^ pte_val(B)) & ~_PAGE_HASHPTE) == 0)
 
-#define pmd_page(pmd)	(pmd_val(pmd))
+#define pmd_page(pmd)	(pmd_val(pmd) & PAGE_MASK)
 
 /* to find an entry in a kernel page-table-directory */
 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
