Add --no-rs-codes flag to optionally disable reed-solomon codes in grub-install and grub-bios-setup for x86 BIOS targets.

This commit is contained in:
Jon McCune 2013-12-09 16:52:12 -08:00
parent 7a148da6dd
commit dd73313cba
6 changed files with 81 additions and 23 deletions

View file

@ -248,7 +248,8 @@ void
SETUP (const char *dir,
const char *boot_file, const char *core_file,
const char *dest, int force,
int fs_probe, int allow_floppy)
int fs_probe, int allow_floppy,
int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */
{
char *core_path;
char *boot_img, *core_img, *boot_path;
@ -486,7 +487,11 @@ SETUP (const char *dir,
nsec = core_sectors;
maxsec = 2 * core_sectors;
if (add_rs_codes)
maxsec = 2 * core_sectors;
else
maxsec = core_sectors;
if (maxsec > ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
>> GRUB_DISK_SECTOR_BITS))
maxsec = ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
@ -543,15 +548,16 @@ SETUP (const char *dir,
write_rootdev (root_dev, boot_img, bl.first_sector);
core_img = realloc (core_img, nsec * GRUB_DISK_SECTOR_SIZE);
/* Round up to the nearest sector boundary, and zero the extra memory */
core_img = xrealloc (core_img, nsec * GRUB_DISK_SECTOR_SIZE);
assert (core_img && (nsec * GRUB_DISK_SECTOR_SIZE >= core_size));
memset (core_img + core_size, 0, nsec * GRUB_DISK_SECTOR_SIZE - core_size);
bl.first_block = (struct grub_boot_blocklist *) (core_img
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*bl.block));
grub_size_t no_rs_length;
grub_set_unaligned32 ((core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY),
grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size));
no_rs_length = grub_target_to_host16
(grub_get_unaligned16 (core_img
+ GRUB_DISK_SECTOR_SIZE
@ -560,14 +566,21 @@ SETUP (const char *dir,
if (no_rs_length == 0xffff)
grub_util_error ("%s", _("core.img version mismatch"));
void *tmp = xmalloc (core_size);
grub_memcpy (tmp, core_img, core_size);
grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE,
core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE,
nsec * GRUB_DISK_SECTOR_SIZE
- core_size);
assert (grub_memcmp (tmp, core_img, core_size) == 0);
free (tmp);
if (add_rs_codes)
{
grub_set_unaligned32 ((core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY),
grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size));
void *tmp = xmalloc (core_size);
grub_memcpy (tmp, core_img, core_size);
grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE,
core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE,
nsec * GRUB_DISK_SECTOR_SIZE
- core_size);
assert (grub_memcmp (tmp, core_img, core_size) == 0);
free (tmp);
}
/* Write the core image onto the disk. */
for (i = 0; i < nsec; i++)