Re: Patch for IBM PRePs
On Wed, Jul 03, 2002 at 09:02:32PM +0200, Olaf Hering wrote:
> On Mon, Jul 01, Tom Rini wrote:
>
> > Lemme know if you still have the correct ammount of memory reported
> > still. Thanks.
>
> ocan you provide a new patch for _devel? I used that one and it doesnt
> compile
D'oh. I forgot to add <asm/bootinfo.h> to prep_setup.c. New patches
attached.
--
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:27:37 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 +216,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 +318,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 16:50:08 2002
@@ -57,6 +57,7 @@
#include <asm/keyboard.h>
#include <asm/vga.h>
#include <asm/time.h>
+#include <asm/bootinfo.h>
#include "local_irq.h"
#include "i8259.h"
@@ -743,34 +744,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;
-
-#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);
- }
+ if (!boot_mem_size)
+ panic("Memory size is 0? Bleah!");
- return (total);
+ return boot_mem_size;
}
/*
===== 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 Wed Jul 3 16:38:18 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 Wed Jul 3 16:38:18 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
@@ -51,7 +52,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.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 Wed Jul 3 16:38:18 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 Wed Jul 3 16:38:18 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 +216,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 +318,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 Wed Jul 3 16:38:18 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 Wed Jul 3 16:38:18 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 Wed Jul 3 16:49:12 2002
@@ -59,6 +59,7 @@
#include <asm/time.h>
#include <asm/i8259.h>
#include <asm/open_pic.h>
+#include <asm/bootinfo.h>
unsigned char ucSystemType;
unsigned char ucBoardRev;
@@ -1103,34 +1104,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;
-
-#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);
- }
+ if (boot_mem_size == 0)
+ panic("No Memory? Bleah!");
- return (total);
+ return boot_mem_size;
}
/*
Reply to: