1 |
/* grub-setup.c - make GRUB usable */ |
/* grub-setup.c - make GRUB usable */ |
2 |
/* |
/* |
3 |
* GRUB -- GRand Unified Bootloader |
* GRUB -- GRand Unified Bootloader |
4 |
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. |
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc. |
5 |
* |
* |
6 |
* GRUB is free software; you can redistribute it and/or modify |
* GRUB is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
86 |
grub_device_t root_dev, dest_dev; |
grub_device_t root_dev, dest_dev; |
87 |
grub_uint8_t *boot_drive; |
grub_uint8_t *boot_drive; |
88 |
grub_uint32_t *kernel_sector; |
grub_uint32_t *kernel_sector; |
89 |
|
grub_uint16_t *boot_drive_check; |
90 |
struct boot_blocklist *first_block, *block; |
struct boot_blocklist *first_block, *block; |
91 |
grub_int32_t *install_dos_part, *install_bsd_part; |
grub_int32_t *install_dos_part, *install_bsd_part; |
92 |
char *install_prefix; |
char *install_prefix; |
169 |
boot_img = grub_util_read_image (boot_path); |
boot_img = grub_util_read_image (boot_path); |
170 |
free (boot_path); |
free (boot_path); |
171 |
|
|
172 |
/* Set the addresses of BOOT_DRIVE and KERNEL_SECTOR. */ |
/* Set the addresses of BOOT_DRIVE, KERNEL_SECTOR and BOOT_DRIVE_CHECK. */ |
173 |
boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE); |
boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE); |
174 |
kernel_sector = (grub_uint32_t *) (boot_img |
kernel_sector = (grub_uint32_t *) (boot_img |
175 |
+ GRUB_BOOT_MACHINE_KERNEL_SECTOR); |
+ GRUB_BOOT_MACHINE_KERNEL_SECTOR); |
176 |
|
boot_drive_check = (grub_uint16_t *) (boot_img |
177 |
|
+ GRUB_BOOT_MACHINE_DRIVE_CHECK); |
178 |
|
|
179 |
core_path = grub_util_get_path (dir, core_file); |
core_path = grub_util_get_path (dir, core_file); |
180 |
core_size = grub_util_get_image_size (core_path); |
core_size = grub_util_get_image_size (core_path); |
231 |
|
|
232 |
free (tmp_img); |
free (tmp_img); |
233 |
|
|
234 |
|
/* If DEST_DRIVE is a hard disk, enable the workaround, which is |
235 |
|
for buggy BIOSes which don't pass boot drive correctly. Instead, |
236 |
|
they pass 0x00 or 0x01 even when booted from 0x80. */ |
237 |
|
if (dest_dev->disk->id & 0x80) |
238 |
|
/* Replace the jmp (2 bytes) with double nop's. */ |
239 |
|
*boot_drive_check = 0x9090; |
240 |
|
|
241 |
/* If the destination device can have partitions and it is the MBR, |
/* If the destination device can have partitions and it is the MBR, |
242 |
try to embed the core image into after the MBR. */ |
try to embed the core image into after the MBR. */ |
243 |
if (dest_dev->disk->has_partitions && ! dest_dev->disk->partition) |
if (dest_dev->disk->has_partitions && ! dest_dev->disk->partition) |