From: Dave Cinege <[EMAIL PROTECTED]>
Subject: [PATCH] Multiple initrd files.
Date: Sun, 28 Jan 2001 01:19:14 -0500

> What do you think about this? To implement this the 'right way' (allowing
> continuous loading accross multiple entries) would require recoding
> load_initrd() entirly.

No, that's quite easy. See the patch attached to this message. It's a
just "three minutes" hack.

But a more important question should be if your patch for Linux is
accepted. If your solution won't be used with the official Linux
version, I don't see any benefit from adding the support to GRUB.

Okuji
Index: stage2/boot.c
===================================================================
RCS file: /home/cvs/grub/stage2/boot.c,v
retrieving revision 1.30
diff -u -r1.30 boot.c
--- stage2/boot.c       2000/10/16 04:27:56     1.30
+++ stage2/boot.c       2001/01/28 08:44:37
@@ -627,21 +627,38 @@
       return 0;
     }
 
-  moveto = ((mbi.mem_upper + 0x400) * 0x400 - len) & 0xfffff000;
-  if (moveto + len >= LINUX_INITRD_MAX_ADDRESS)
-    moveto = (LINUX_INITRD_MAX_ADDRESS - len) & 0xfffff000;
-  
-  /* XXX: Linux 2.3.xx has a bug in the memory range check, so avoid
-     the last page.  */
-  moveto -= 0x1000;
-  memmove ((void *) RAW_ADDR (moveto), (void *) cur_addr, len);
-
-  printf ("   [Linux-initrd @ 0x%x, 0x%x bytes]\n", moveto, len);
-
   /* FIXME: Should check if the kernel supports INITRD.  */
   lh = (struct linux_kernel_header *) LINUX_SETUP;
-  lh->ramdisk_image = RAW_ADDR (moveto);
-  lh->ramdisk_size = len;
+
+  /* If called multiple times, move the previously loaded image forward.  */
+  if (lh->ramdisk_size)
+    {
+      moveto = (lh->ramdisk_image - len) & 0xfffff000;
+      grub_memmove ((void *) moveto, (void *) lh->ramdisk_image,
+                   lh->ramdisk_size);
+      lh->ramdisk_image = moveto;
+      
+      moveto += lh->ramdisk_size;
+      grub_memmove ((void *) moveto, (void *) cur_addr, len);
+      lh->ramdisk_size += len;
+    }
+  else
+    {
+      moveto = ((mbi.mem_upper + 0x400) * 0x400 - filemax) & 0xfffff000;
+      if (moveto + filemax >= LINUX_INITRD_MAX_ADDRESS)
+       moveto = (LINUX_INITRD_MAX_ADDRESS - filemax) & 0xfffff000;
+      
+      /* XXX: Linux 2.3.xx has a bug in the memory range check, so avoid
+        the last page.  */
+      moveto -= 0x1000;
+      
+      grub_memmove ((void *) RAW_ADDR (moveto), (void *) cur_addr, len);
+      lh->ramdisk_image = RAW_ADDR (moveto);
+      lh->ramdisk_size = len;
+    }
+
+  grub_printf ("   [Linux-initrd @ 0x%x, 0x%x bytes]\n",
+              lh->ramdisk_image, lh->ramdisk_size);
 
   grub_close ();
   return 1;

Reply via email to