* include/grub/misc.h (ALIGN_UP_OVERHEAD): New define.
* grub-core/loader/i386/linux.c (grub_cmd_initrd): Align initrds at 4. * grub-core/loader/i386/pc/linux.c (grub_cmd_initrd): Likewise. * grub-core/loader/ia64/efi/linux.c (grub_cmd_initrd): Likewise. * grub-core/loader/mips/linux.c (grub_cmd_initrd): Likewise. * grub-core/loader/powerpc/ieee1275/linux.c (grub_cmd_initrd): Likewise. * grub-core/loader/sparc64/ieee1275/linux.c (grub_cmd_initrd): Likewise.
This commit is contained in:
parent
90eeab76b0
commit
1a2fd1e674
8 changed files with 29 additions and 6 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2012-03-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* include/grub/misc.h (ALIGN_UP_OVERHEAD): New define.
|
||||
* grub-core/loader/i386/linux.c (grub_cmd_initrd): Align initrds at 4.
|
||||
* grub-core/loader/i386/pc/linux.c (grub_cmd_initrd): Likewise.
|
||||
* grub-core/loader/ia64/efi/linux.c (grub_cmd_initrd): Likewise.
|
||||
* grub-core/loader/mips/linux.c (grub_cmd_initrd): Likewise.
|
||||
* grub-core/loader/powerpc/ieee1275/linux.c (grub_cmd_initrd): Likewise.
|
||||
* grub-core/loader/sparc64/ieee1275/linux.c (grub_cmd_initrd): Likewise.
|
||||
|
||||
2012-03-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/commands/menuentry.c (options): Remove
|
||||
|
|
|
@ -1034,7 +1034,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (! files[i])
|
||||
goto fail;
|
||||
nfiles++;
|
||||
size += grub_file_size (files[i]);
|
||||
size += ALIGN_UP (grub_file_size (files[i]), 4);
|
||||
}
|
||||
|
||||
initrd_pages = (page_align (size) >> 12);
|
||||
|
@ -1101,6 +1101,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto fail;
|
||||
}
|
||||
ptr += cursize;
|
||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||
}
|
||||
|
||||
grub_dprintf ("linux", "Initrd, addr=0x%x, size=0x%x\n",
|
||||
|
|
|
@ -421,7 +421,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (! files[i])
|
||||
goto fail;
|
||||
nfiles++;
|
||||
size += grub_file_size (files[i]);
|
||||
size += ALIGN_UP (grub_file_size (files[i]), 4);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -449,6 +449,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto fail;
|
||||
}
|
||||
ptr += cursize;
|
||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||
}
|
||||
|
||||
lh->ramdisk_image = initrd_addr;
|
||||
|
|
|
@ -597,7 +597,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (! files[i])
|
||||
goto fail;
|
||||
nfiles++;
|
||||
initrd_size += grub_file_size (files[i]);
|
||||
initrd_size += ALIGN_UP (grub_file_size (files[i]), 4);
|
||||
grub_dprintf ("linux", "File %d: %s\n", i, argv[i]);
|
||||
}
|
||||
|
||||
|
@ -624,6 +624,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto fail;
|
||||
}
|
||||
ptr += cursize;
|
||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||
}
|
||||
fail:
|
||||
for (i = 0; i < nfiles; i++)
|
||||
|
|
|
@ -468,7 +468,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (! files[i])
|
||||
goto fail;
|
||||
nfiles++;
|
||||
size += grub_file_size (files[i]);
|
||||
size += ALIGN_UP (grub_file_size (files[i]), 4);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -499,6 +499,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto fail;
|
||||
}
|
||||
ptr += cursize;
|
||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||
}
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
|
||||
|
|
|
@ -350,7 +350,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (! files[i])
|
||||
goto fail;
|
||||
nfiles++;
|
||||
size += grub_file_size (files[i]);
|
||||
size += ALIGN_UP (grub_file_size (files[i]), 4);
|
||||
}
|
||||
|
||||
first_addr = linux_addr + linux_size;
|
||||
|
@ -376,6 +376,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto fail;
|
||||
}
|
||||
ptr += cursize;
|
||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||
}
|
||||
|
||||
initrd_addr = addr;
|
||||
|
|
|
@ -403,7 +403,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (! files[i])
|
||||
goto fail;
|
||||
nfiles++;
|
||||
size += grub_file_size (files[i]);
|
||||
size += ALIGN_UP(grub_file_size (files[i]), 4);
|
||||
}
|
||||
|
||||
addr = 0x60000000;
|
||||
|
@ -438,6 +438,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto fail;
|
||||
}
|
||||
ptr += cursize;
|
||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||
}
|
||||
|
||||
initrd_addr = addr;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
#define ALIGN_UP(addr, align) \
|
||||
((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
|
||||
#define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1))
|
||||
#define ALIGN_DOWN(addr, align) \
|
||||
((addr) & ~((typeof (addr)) align - 1))
|
||||
#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
|
||||
|
|
Loading…
Reference in a new issue