Index: arch/mips/boot/addinitrd.c
===================================================================
RCS file: /cvs/linux/arch/mips/boot/addinitrd.c,v
retrieving revision 1.1
diff -u -u -r1.1 addinitrd.c
--- arch/mips/boot/addinitrd.c	1999/03/13 12:36:50	1.1
+++ arch/mips/boot/addinitrd.c	2001/10/02 16:59:40
@@ -44,7 +44,7 @@
 	char buf[1024];
 	unsigned long loadaddr;
 	unsigned long initrd_header[2];
-	int i;
+	int i,cnt;
 	int swab = 0;
 
 	if (argc != 4) {
@@ -60,7 +60,6 @@
 		die ("read aout header");
 	if (read (fd_vmlinux, esecs, sizeof esecs) != sizeof esecs)
 		die ("read section headers");
-
 	/*
 	 * check whether the file is good for us
 	 */
@@ -98,9 +97,20 @@
 		die ("write aout header");
 	if (write (fd_outfile, esecs, sizeof esecs) != sizeof esecs)
 		die ("write section headers");
-	while ((i = read (fd_vmlinux, buf, sizeof buf)) > 0)
+	/* skip padding */
+	if(lseek(fd_vmlinux, SWAB(esecs[0].s_scnptr), SEEK_SET) == (off_t)-1)
+		die ("lseek vmlinux");
+	if(lseek(fd_outfile, SWAB(esecs[0].s_scnptr), SEEK_SET) == (off_t)-1)
+		die ("lseek outfile");
+	/* copy text segment */
+	cnt = SWAB(eaout.tsize);
+	while (cnt) {
+		if ((i = read (fd_vmlinux, buf, sizeof buf)) <= 0)
+			die ("read vmlinux");
 		if (write (fd_outfile, buf, i) != i)
 			die ("write vmlinux");
+		cnt -= i;
+	}
 	if (write (fd_outfile, initrd_header, sizeof initrd_header) != sizeof initrd_header)
 		die ("write initrd header");
 	while ((i = read (fd_initrd, buf, sizeof buf)) > 0)
Index: arch/mips/kernel/setup.c
===================================================================
RCS file: /cvs/linux/arch/mips/kernel/setup.c,v
retrieving revision 1.72
diff -u -u -r1.72 setup.c
--- arch/mips/kernel/setup.c	2001/09/15 11:58:03	1.72
+++ arch/mips/kernel/setup.c	2001/10/02 16:59:42
@@ -529,6 +529,8 @@
 
 	unsigned long bootmap_size;
 	unsigned long start_pfn, max_pfn, first_usable_pfn;
+	unsigned long tmp;
+	unsigned long* initrd_header;
 
 	int i;
 
@@ -645,11 +647,23 @@
 #define PFN_DOWN(x)	((x) >> PAGE_SHIFT)
 #define PFN_PHYS(x)	((x) << PAGE_SHIFT)
 
+#ifdef CONFIG_BLK_DEV_INITRD
+	tmp = (((unsigned long)&_end + PAGE_SIZE-1) & PAGE_MASK) - 8; 
+	if (tmp < (unsigned long)&_end) 
+		tmp += PAGE_SIZE;
+	initrd_header = (unsigned long *)tmp;
+	if (initrd_header[0] == 0x494E5244) {
+		initrd_start = (unsigned long)&initrd_header[2];
+		initrd_end = initrd_start + initrd_header[1];
+	}
+	start_pfn = PFN_UP(__pa((&_end)+(initrd_end - initrd_start) + PAGE_SIZE));
+#else
 	/*
 	 * Partially used pages are not usable - thus
 	 * we are rounding upwards.
 	 */
 	start_pfn = PFN_UP(__pa(&_end));
+#endif	/* CONFIG_BLK_DEV_INITRD */
 
 	/* Find the highest page frame number we have available.  */
 	max_pfn = 0;
