- /*
- * Relocate initrd, if present.
- */
-
- if (bp->s.initrd_start) {
- /* %%TBD */
- MEMCPY(15 * 1024 * 1024, bp->s.initrd_start, bp->s.initrd_size);
- bp->s.initrd_start = 15 * 1024 * 1024;
- }
+ /*
+ * Relocate kernel (if needed), and initrd (if present).
+ * Copy kernel first, in case kernel was loaded overlapping where we're
+ * planning to copy the initrd. This assumes that the initrd didn't
+ * get loaded overlapping where we're planning to copy the kernel, but
+ * that's pretty unlikely since we couldn't alloc that space for the
+ * kernel (or the kernel would already be there).
+ */
+ if (kernel_start != kernel_load_address) {
+ MEMCPY(kernel_start, kernel_load_address, kernel_size);
+ }
+
+ if (bp->s.initrd_start) {
+ temp = bp->s.initrd_start;
+ MEMCPY(INITRD_START, temp , bp->s.initrd_size);
+ bp->s.initrd_start = INITRD_START;
+ }