[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

kernel patch for PReP users



Can anyone with access to an IBM PReP box (who compiles their own
kernels as well preferably) give the following patches (one vs
linuxppc_2_4, one vs linuxppc_2_4_devel) a shot, and let me know if the
correct ammount of memory is reported still?  This has also been tested
on my Motorola PowerStack, but tests on other PRePs would be good too.
The main point of this patch is that we don't rely on residual data to
find out how much memory we have, and thus all memory is reported
correctly when netbooted.

-- 
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
===== arch/ppc/boot/prep/Makefile 1.31 vs edited =====
--- 1.31/arch/ppc/boot/prep/Makefile	Thu Mar  7 13:42:37 2002
+++ edited/arch/ppc/boot/prep/Makefile	Wed Jul  3 09:20:04 2002
@@ -23,9 +23,10 @@
 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/misc-common.o \
+					../common/mpc10x_memory.o
 OBJCOPY_ARGS			= -O elf32-powerpc
 LIBS 				= ../lib/zlib.a
 
@@ -55,7 +56,7 @@
 	$(LD) $(LD_ARGS) -o $@ $(obj-y) image.o $(LIBS)
 	$(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab -R .stabstr
 	$(MKPREP) -pbp $@ ../images/$@.prep
-	rm -f $@
+	#rm -f $@
 
 zImage.initrd: $(obj-y) $(LIBS) ../ld.script ../images/vmlinux.gz $(MKPREP) \
 		../common/dummy.o
===== arch/ppc/boot/prep/head.S 1.14 vs edited =====
--- 1.14/arch/ppc/boot/prep/head.S	Thu Mar  7 13:42:37 2002
+++ edited/arch/ppc/boot/prep/head.S	Wed Jul  3 09:20:04 2002
@@ -38,10 +38,6 @@
 	isync
 
 	mr	r11,r3		/* Save pointer to residual/board data */
-	mr      r25,r5		/* Save OFW pointer */
-
-	/* Save the original MSR value */
-	mfmsr	r26
 
 	/* Establish default MSR value */
 	li	r3,MSR_IP|MSR_FP
@@ -114,17 +110,11 @@
 	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 */
 	bl	decompress_kernel
 
 	/*
===== arch/ppc/boot/prep/misc.c 1.27 vs edited =====
--- 1.27/arch/ppc/boot/prep/misc.c	Thu Mar  7 13:42:37 2002
+++ edited/arch/ppc/boot/prep/misc.c	Wed Jul  3 09:20:05 2002
@@ -20,6 +20,8 @@
 #include <asm/bootinfo.h>
 #include <asm/mmu.h>
 #include <asm/byteorder.h>
+
+#include "mpc10x.h"
 #include "nonstdio.h"
 #include "zlib.h"
 
@@ -51,7 +53,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;
@@ -66,16 +67,11 @@
 #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);
+extern unsigned long mpc10x_get_mem_size(int mem_map);
 
 void
 writel(unsigned int val, unsigned int address)
@@ -120,15 +116,12 @@
 
 unsigned long
 decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
-		  RESIDUAL *residual, void *OFW_interface)
+		  RESIDUAL *residual)
 {
 	int timer = 0;
 	extern unsigned long start;
 	char *cp, ch;
 	unsigned long TotalMemory;
-	int dev_handle;
-	int mem_info[2];
-	int res, size;
 	unsigned char board_type;
 	unsigned char base_mod;
 	int start_multi = 0;
@@ -142,6 +135,11 @@
 	vga_init((unsigned char *)0xC0000000);
 #endif /* CONFIG_VGA_CONSOLE */
 
+	/* 
+	 * Find out how much memory we have.
+	 */
+	TotalMemory = mpc10x_get_mem_size(MPC10X_MEM_MAP_A);
+
 	/*
 	 * Tell the user where we were loaded at and where we were relocated
 	 * to for debugging this process.
@@ -218,47 +215,6 @@
 	} else {
 		/* Tell the user we didn't find anything. */
 		puts("No residual data found.\n");
-
-		/* Assume 32M in the absence of more info... */
-		TotalMemory = 0x02000000;
-
-		/*
-		 * This is a 'best guess' check.  We want to make sure
-		 * we don't try this on a PReP box without OF
-		 *     -- Cort
-		 */
-		while (OFW_interface && ((unsigned long)OFW_interface < 0x10000000) )
-		{
-			/* We need to restore the slightly inaccurate
-			 * MSR so that OpenFirmware will behave. -- Tom
-			 */
-			_put_MSR(orig_MSR);
-			of_init(OFW_interface);
-
-			/* get handle to memory description */
-			res = of_finddevice("/memory@0",
-					    &dev_handle);
-			if (res)
-				break;
-
-			/* get the info */
-			res = of_getprop(dev_handle,
-					 "reg",
-					 mem_info,
-					 sizeof(mem_info),
-					 &size);
-			if (res)
-				break;
-
-			TotalMemory = mem_info[1];
-			break;
-		}
-
-		hold_residual->TotalMemory = TotalMemory;
-		residual = hold_residual;
-
-		/* Enforce a sane MSR for booting. */
-		_put_MSR(MSR_IP);
         }
 
 	/* assume the chunk below 8M is free */
@@ -361,6 +317,11 @@
 		rec->data[1] = 0;
 		rec->size = sizeof(struct bi_record) + 2 *
 			sizeof(unsigned long);
+		rec = (struct bi_record *)((unsigned long)rec + rec->size);
+
+		rec->tag = BI_MEMSIZE;
+		rec->data[0] = TotalMemory;
+		rec->size = sizeof(struct bi_record) + sizeof(unsigned long);
 		rec = (struct bi_record *)((unsigned long)rec + rec->size);
 
 		rec->tag = BI_CMD_LINE;
===== arch/ppc/kernel/prep_setup.c 1.55 vs edited =====
--- 1.55/arch/ppc/kernel/prep_setup.c	Thu May 30 11:12:10 2002
+++ edited/arch/ppc/kernel/prep_setup.c	Wed Jul  3 09:21:33 2002
@@ -743,34 +743,15 @@
 #endif /* CONFIG_SMP */
 
 /*
- * This finds the amount of physical ram and does necessary
- * setup for prep.  This is pretty architecture specific so
- * this will likely stay separate from the pmac.
- * -- Cort
+ * What ever boots us must pass in the ammount of memory.
  */
 static unsigned long __init
 prep_find_end_of_memory(void)
 {
-	unsigned long total = 0;
-	extern unsigned int boot_mem_size;
+	if (!boot_mem_size)
+		panic("Memory size is 0? Bleah!");
 
-#ifdef CONFIG_PREP_RESIDUAL	
-	total = res->TotalMemory;
-#endif	
-
-	if (total == 0 && boot_mem_size != 0)
-		total = boot_mem_size;
-	else if (total == 0) {
-		/*
-		 * I need a way to probe the amount of memory if the residual
-		 * data doesn't contain it. -- Cort
-		 */
-		total = 0x02000000;
-		printk(KERN_INFO "Ramsize from residual data was 0"
-			 " -- defaulting to %ldM\n", total>>20);
-	}
-
-	return (total);
+	return boot_mem_size;
 }
 
 /*
--- /dev/null	Wed Dec 31 17:00:00 1969
+++ linuxppc_2_4_devel/arch/ppc/boot/common/mpc10x_memory.c	Mon Jul  1 13:18:30 2002
@@ -0,0 +1,113 @@
+/*
+ * arch/ppc/boot/common/mpc10x_common.c
+ * 
+ * A routine to find out how much memory the machine has.
+ *
+ * Based on:
+ * arch/ppc/kernel/mpc10x_common.c
+ *
+ * Author: Mark A. Greer
+ *         mgreer@mvista.com
+ *
+ * Copyright 2001-2002 MontaVista Software Inc.
+ *
+ * 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 <linux/pci.h>
+#include <asm/types.h>
+#include <asm/io.h>
+#include "mpc10x.h"
+
+/*
+ * *** WARNING - A BAT MUST be set to access the PCI config addr/data regs ***
+ */
+
+
+/*
+ * PCI config space macros, similar to indirect_xxx and early_xxx macros.
+ * We assume bus 0.
+ */
+#define MPC10X_CFG_read(val, addr, type, op)	*val = op((type)(addr))
+#define MPC10X_CFG_write(val, addr, type, op)	op((type *)(addr), (val))
+
+#define MPC10X_PCI_OP(rw, size, type, op, mask)			 	\
+static void								\
+mpc10x_##rw##_config_##size(unsigned int *cfg_addr, 			\
+		unsigned int *cfg_data, int devfn, int offset,		\
+		type val)						\
+{									\
+	out_be32(cfg_addr, 						\
+		 ((offset & 0xfc) << 24) | (devfn << 16)		\
+		 | (0 << 8) | 0x80);					\
+	MPC10X_CFG_##rw(val, cfg_data + (offset & mask), type, op);	\
+	return;    					 		\
+}
+
+MPC10X_PCI_OP(read, byte,  u8 *, in_8, 3)
+MPC10X_PCI_OP(read, dword, u32 *, in_le32, 0)
+
+/*
+ * Read the memory controller registers to determine the amount of memory in
+ * the system.  This assumes that the firmware has correctly set up the memory
+ * controller registers.
+ */
+unsigned long
+mpc10x_get_mem_size(unsigned int mem_map)
+{
+	unsigned int *config_addr, *config_data, val;
+	unsigned long start, end, total, offset;
+	int i;
+	unsigned char bank_enables;
+
+	switch (mem_map) {
+		case MPC10X_MEM_MAP_A:
+			config_addr = (unsigned int *)MPC10X_MAPA_CNFG_ADDR;
+			config_data = (unsigned int *)MPC10X_MAPA_CNFG_DATA;
+			break;
+		case MPC10X_MEM_MAP_B:
+			config_addr = (unsigned int *)MPC10X_MAPB_CNFG_ADDR;
+			config_data = (unsigned int *)MPC10X_MAPB_CNFG_DATA;
+			break;
+		default:
+			return 0;
+	}
+
+	mpc10x_read_config_byte(config_addr, config_data, PCI_DEVFN(0,0),
+			MPC10X_MCTLR_MEM_BANK_ENABLES, &bank_enables);
+
+	total = 0;
+
+	for (i = 0; i < 8; i++) {
+		if (bank_enables & (1 << i)) {
+			offset = MPC10X_MCTLR_MEM_START_1 + ((i > 3) ? 4 : 0);
+			mpc10x_read_config_dword(config_addr, config_data,
+					PCI_DEVFN(0,0), offset, &val);
+			start = (val >> ((i & 3) << 3)) & 0xff;
+
+			offset = MPC10X_MCTLR_EXT_MEM_START_1 + ((i>3) ? 4 : 0);
+			mpc10x_read_config_dword(config_addr, config_data,
+					PCI_DEVFN(0,0), offset, &val);
+			val = (val >> ((i & 3) << 3)) & 0x03;
+			start = (val << 28) | (start << 20);
+
+			offset = MPC10X_MCTLR_MEM_END_1 + ((i > 3) ? 4 : 0);
+			mpc10x_read_config_dword(config_addr, config_data,
+					PCI_DEVFN(0,0), offset, &val);
+			end = (val >> ((i & 3) << 3)) & 0xff;
+
+			offset = MPC10X_MCTLR_EXT_MEM_END_1 + ((i > 3) ? 4 : 0);
+			mpc10x_read_config_dword(config_addr, config_data,
+					PCI_DEVFN(0,0), offset, &val);
+			val = (val >> ((i & 3) << 3)) & 0x03;
+			end = (val << 28) | (end << 20) | 0xfffff;
+
+			total += (end - start + 1);
+		}
+	}
+
+	return total;
+}
--- /dev/null	Wed Dec 31 17:00:00 1969
+++ linuxppc_2_4_devel/arch/ppc/boot/include/mpc10x.h	Mon Jul  1 11:03:08 2002
@@ -0,0 +1,67 @@
+/*
+ * arch/ppc/boot/include/mpc10.h
+ *
+ * Common defines for the Motorola SPS MPC106/8240/107 Host bridge/Mem
+ * ctrl/EPIC/etc.
+ *
+ * Author: Tom Rini <trini@mvista.com>
+ *
+ * This is a heavily stripped down version of:
+ * include/asm-ppc/mpc10x.h
+ *
+ * Author: Mark A. Greer
+ *         mgreer@mvista.com
+ *
+ * Copyright 2001-2002 MontaVista Software Inc.
+ *
+ * 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.
+ */
+#ifndef __BOOT_MPC10X_H__
+#define __BOOT_MPC10X_H__
+
+/*
+ * The values here don't completely map everything but should work in most
+ * cases.
+ *
+ * MAP A (PReP Map)
+ *   Processor: 0x80000000 - 0x807fffff -> PCI I/O: 0x00000000 - 0x007fffff
+ *   Processor: 0xc0000000 - 0xdfffffff -> PCI MEM: 0x00000000 - 0x1fffffff
+ *   PCI MEM:   0x80000000 -> Processor System Memory: 0x00000000
+ *   EUMB mapped to: ioremap_base - 0x00100000 (ioremap_base - 1 MB)
+ *
+ * MAP B (CHRP Map)
+ *   Processor: 0xfe000000 - 0xfebfffff -> PCI I/O: 0x00000000 - 0x00bfffff
+ *   Processor: 0x80000000 - 0xbfffffff -> PCI MEM: 0x80000000 - 0xbfffffff
+ *   PCI MEM:   0x00000000 -> Processor System Memory: 0x00000000
+ *   EUMB mapped to: ioremap_base - 0x00100000 (ioremap_base - 1 MB)
+ */
+
+/* Define the type of map to use */
+#define	MPC10X_MEM_MAP_A		1
+#define	MPC10X_MEM_MAP_B		2
+
+/* Map A (PReP Map) Defines */
+#define	MPC10X_MAPA_CNFG_ADDR		0x80000cf8
+#define	MPC10X_MAPA_CNFG_DATA		0x80000cfc
+
+/* Map B (CHRP Map) Defines */
+#define	MPC10X_MAPB_CNFG_ADDR		0xfec00000
+#define	MPC10X_MAPB_CNFG_DATA		0xfee00000
+
+/* Define offsets for the memory controller registers in the config space */
+#define MPC10X_MCTLR_MEM_START_1	0x80	/* Banks 0-3 */
+#define MPC10X_MCTLR_MEM_START_2	0x84	/* Banks 4-7 */
+#define MPC10X_MCTLR_EXT_MEM_START_1	0x88	/* Banks 0-3 */
+#define MPC10X_MCTLR_EXT_MEM_START_2	0x8c	/* Banks 4-7 */
+
+#define MPC10X_MCTLR_MEM_END_1		0x90	/* Banks 0-3 */
+#define MPC10X_MCTLR_MEM_END_2i		0x94	/* Banks 4-7 */
+#define MPC10X_MCTLR_EXT_MEM_END_1	0x98	/* Banks 0-3 */
+#define MPC10X_MCTLR_EXT_MEM_END_2	0x9c	/* Banks 4-7 */
+
+#define MPC10X_MCTLR_MEM_BANK_ENABLES	0xa0
+
+#endif	/* __BOOT_MPC10X_H__ */
===== arch/ppc/boot/common/misc-simple.c 1.22 vs edited =====
--- 1.22/arch/ppc/boot/common/misc-simple.c	Thu May 30 11:29:39 2002
+++ edited/arch/ppc/boot/common/misc-simple.c	Mon Jul  1 14:26:36 2002
@@ -30,6 +30,7 @@
 #include <platforms/ebony.h>
 #endif /* CONFIG_EBONY */
 
+#include "mpc10x.h"
 #include "nonstdio.h"
 #include "zlib.h"
 
@@ -67,6 +68,7 @@
 extern unsigned long start;
 
 extern int CRT_tstc(void);
+extern unsigned long mpc10x_get_mem_size(int map);
 extern unsigned long serial_init(int chan, void *ignored);
 extern void serial_close(unsigned long com_port);
 extern void gunzip(void *, int, unsigned char *, int *);
@@ -78,6 +80,7 @@
 	int timer = 0;
 	char *cp, ch;
 	struct bi_record *rec, *birecs;
+	unsigned long TotalMemory = 0;
 
 	serial_fixups();
 	com_port = serial_init(0, NULL);
@@ -89,6 +92,14 @@
 	__asm__ __volatile__("eieio");			/* enforce ordering */
 #endif
 
+#ifdef CONFIG_LOPEC
+	/*
+	 * This should work on any board with an MPC10X which is properly
+	 * initalized.
+	 */
+	TotalMemory = mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
+#endif
+
 	/* assume the chunk below 8M is free */
 	end_avail = (char *)0x00800000;
 
@@ -206,6 +217,13 @@
 	rec->tag = BI_FIRST;
 	rec->size = sizeof(struct bi_record);
 	rec = (struct bi_record *)((unsigned long)rec + rec->size);
+
+	if ( TotalMemory ) {
+		rec->tag = BI_MEMSIZE;
+		rec->data[0] = TotalMemory;
+		rec->size = sizeof(struct bi_record) + sizeof(unsigned long);
+		rec = (struct bi_record *)((unsigned long)rec + rec->size);
+	}
 
 	rec->tag = BI_CMD_LINE;
 	memcpy( (char *)rec->data, cmd_line, strlen(cmd_line)+1);
===== arch/ppc/boot/prep/Makefile 1.38 vs edited =====
--- 1.38/arch/ppc/boot/prep/Makefile	Mon Mar 11 22:07:28 2002
+++ edited/arch/ppc/boot/prep/Makefile	Mon Jul  1 14:25:40 2002
@@ -23,9 +23,10 @@
 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/misc-common.o \
+					../common/mpc10x_memory.o
 OBJCOPY_ARGS			= -O elf32-powerpc
 LIBS 				= ../lib/zlib.a
 
===== arch/ppc/boot/prep/head.S 1.24 vs edited =====
--- 1.24/arch/ppc/boot/prep/head.S	Mon Mar 11 22:07:28 2002
+++ edited/arch/ppc/boot/prep/head.S	Mon Jul  1 14:25:40 2002
@@ -38,10 +38,6 @@
 	isync
 
 	mr	r11,r3		/* Save pointer to residual/board data */
-	mr      r25,r5		/* Save OFW pointer */
-
-	/* Save the original MSR value */
-	mfmsr	r26
 
 	/* Establish default MSR value */
 	li	r3,MSR_IP|MSR_FP
@@ -114,17 +110,11 @@
 	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 */
 	bl	decompress_kernel
 
 	/*
===== arch/ppc/boot/prep/misc.c 1.40 vs edited =====
--- 1.40/arch/ppc/boot/prep/misc.c	Thu Apr 11 13:54:51 2002
+++ edited/arch/ppc/boot/prep/misc.c	Mon Jul  1 14:25:40 2002
@@ -20,6 +20,8 @@
 #include <asm/bootinfo.h>
 #include <asm/mmu.h>
 #include <asm/byteorder.h>
+
+#include "mpc10x.h"
 #include "nonstdio.h"
 #include "zlib.h"
 
@@ -51,7 +53,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;
@@ -66,16 +67,11 @@
 #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);
+extern unsigned long mpc10x_get_mem_size(int mem_map);
 
 void
 writel(unsigned int val, unsigned int address)
@@ -120,15 +116,12 @@
 
 unsigned long
 decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
-		  RESIDUAL *residual, void *OFW_interface)
+		  RESIDUAL *residual)
 {
 	int timer = 0;
 	extern unsigned long start;
 	char *cp, ch;
 	unsigned long TotalMemory;
-	int dev_handle;
-	int mem_info[2];
-	int res, size;
 	unsigned char board_type;
 	unsigned char base_mod;
 	int start_multi = 0;
@@ -142,6 +135,11 @@
 	vga_init((unsigned char *)0xC0000000);
 #endif /* CONFIG_VGA_CONSOLE */
 
+	/* 
+	 * Find out how much memory we have.
+	 */
+	TotalMemory = mpc10x_get_mem_size(MPC10X_MEM_MAP_A);
+
 	/*
 	 * Tell the user where we were loaded at and where we were relocated
 	 * to for debugging this process.
@@ -218,47 +215,6 @@
 	} else {
 		/* Tell the user we didn't find anything. */
 		puts("No residual data found.\n");
-
-		/* Assume 32M in the absence of more info... */
-		TotalMemory = 0x02000000;
-
-		/*
-		 * This is a 'best guess' check.  We want to make sure
-		 * we don't try this on a PReP box without OF
-		 *     -- Cort
-		 */
-		while (OFW_interface && ((unsigned long)OFW_interface < 0x10000000) )
-		{
-			/* We need to restore the slightly inaccurate
-			 * MSR so that OpenFirmware will behave. -- Tom
-			 */
-			_put_MSR(orig_MSR);
-			of_init(OFW_interface);
-
-			/* get handle to memory description */
-			res = of_finddevice("/memory@0",
-					    &dev_handle);
-			if (res)
-				break;
-
-			/* get the info */
-			res = of_getprop(dev_handle,
-					 "reg",
-					 mem_info,
-					 sizeof(mem_info),
-					 &size);
-			if (res)
-				break;
-
-			TotalMemory = mem_info[1];
-			break;
-		}
-
-		hold_residual->TotalMemory = TotalMemory;
-		residual = hold_residual;
-
-		/* Enforce a sane MSR for booting. */
-		_put_MSR(MSR_IP);
         }
 
 	/* assume the chunk below 8M is free */
@@ -361,6 +317,11 @@
 		rec->data[1] = 0;
 		rec->size = sizeof(struct bi_record) + 2 *
 			sizeof(unsigned long);
+		rec = (struct bi_record *)((unsigned long)rec + rec->size);
+
+		rec->tag = BI_MEMSIZE;
+		rec->data[0] = TotalMemory;
+		rec->size = sizeof(struct bi_record) + sizeof(unsigned long);
 		rec = (struct bi_record *)((unsigned long)rec + rec->size);
 
 		rec->tag = BI_CMD_LINE;
===== arch/ppc/boot/simple/Makefile 1.7 vs edited =====
--- 1.7/arch/ppc/boot/simple/Makefile	Mon Jul  1 10:43:25 2002
+++ edited/arch/ppc/boot/simple/Makefile	Mon Jul  1 14:25:40 2002
@@ -66,7 +66,7 @@
 ifeq ($(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750)$(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS),y)
 ZIMAGE				:= zImage-PPLUS
 ZIMAGEINITRD			:= zImage.initrd-PPLUS
-EXTRA				:= direct.o
+EXTRA				:= direct.o ../common/mpc10x_memory.o
 TFTPIMAGE			:= /tftpboot/zImage.pplus
 ZNETBOOT			:= zImage.pplus
 ZNETBOOTRD			:= zImage.initrd.pplus
===== arch/ppc/platforms/lopec_setup.c 1.19 vs edited =====
--- 1.19/arch/ppc/platforms/lopec_setup.c	Wed Jun 19 12:30:01 2002
+++ edited/arch/ppc/platforms/lopec_setup.c	Mon Jul  1 14:25:40 2002
@@ -332,7 +332,7 @@
 static unsigned long __init
 lopec_find_end_of_memory(void)
 {
-	return mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
+	return boot_mem_size;
 }
 
 TODC_ALLOC();
===== arch/ppc/platforms/prep_setup.c 1.82 vs edited =====
--- 1.82/arch/ppc/platforms/prep_setup.c	Thu May 30 12:38:36 2002
+++ edited/arch/ppc/platforms/prep_setup.c	Mon Jul  1 14:25:40 2002
@@ -1103,34 +1103,15 @@
 #endif /* CONFIG_SMP */
 
 /*
- * This finds the amount of physical ram and does necessary
- * setup for prep.  This is pretty architecture specific so
- * this will likely stay separate from the pmac.
- * -- Cort
+ * What ever boots us must pass in the ammount of memory.
  */
 static unsigned long __init
 prep_find_end_of_memory(void)
 {
-	unsigned long total = 0;
-	extern unsigned int boot_mem_size;
+	if (boot_mem_size == 0)
+		panic("No Memory? Bleah!");
 
-#ifdef CONFIG_PREP_RESIDUAL	
-	total = res->TotalMemory;
-#endif	
-
-	if (total == 0 && boot_mem_size != 0)
-		total = boot_mem_size;
-	else if (total == 0) {
-		/*
-		 * I need a way to probe the amount of memory if the residual
-		 * data doesn't contain it. -- Cort
-		 */
-		total = 0x02000000;
-		printk(KERN_INFO "Ramsize from residual data was 0"
-			 " -- defaulting to %ldM\n", total>>20);
-	}
-
-	return (total);
+	return boot_mem_size;
 }
 
 /*


Reply to: