+2011-11-12 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Defer multiboot device parsing until we're in compressed part.
+
+ * grub-core/boot/i386/pc/lnxboot.S: Remove setting dos_part and
+ bsd_part. setdevice has fallen into disuse.
+ * grub-core/boot/i386/pc/startup_raw.S (dos_part): Removed.
+ (bsd_part): Likewise.
+ (boot_dev): New variable.
+ (multiboot_trampoline): Don't parse multiboot device.
+ Pass multiboot device in %edx.
+ * grub-core/disk/i386/pc/biosdisk.c (GRUB_MOD_INIT): Parse
+ grub_boot_device.
+ * grub-core/kern/i386/pc/init.c (grub_machine_get_bootlocation):
+ Likewise.
+ * grub-core/kern/i386/pc/startup.S: Save edx.
+ (grub_boot_drive): Removed.
+ (grub_install_dos_part): Likewise.
+ (grub_install_bsd_part): Likewise.
+ (grub_boot_device): New variable.
+ * include/grub/i386/pc/kernel.h (grub_install_dos_part): Removed.
+ (grub_install_bsd_part): Likewise.
+ (grub_boot_drive): Likewise.
+ (grub_boot_device): New variable.
+ * include/grub/offsets.h (GRUB_KERNEL_I386_PC_INSTALL_DOS_PART):
+ Removed.
+ (GRUB_KERNEL_I386_PC_INSTALL_BSD_PART): Likewise.
+ (GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY): Moved lower.
+ (GRUB_KERNEL_MACHINE_INSTALL_BSD_PART): Removed.
+ (GRUB_KERNEL_MACHINE_INSTALL_DOS_PART): Likewise.
+ * util/grub-install.in: Remove redundant condition.
+
2011-11-12 Vladimir Serbinenko <phcoder@gmail.com>
Fix bug introduced by previous commit.
2:
call LOCAL(move_memory)
- movsbl %dh, %eax
- movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART)
- movsbl (reg_edx + 2 - start), %eax
- movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
-
movb $0xFF, %dh
ljmp $(DATA_ADDR >> 4), $0
LOCAL(uncompressed_size):
.long 0
- . = _start + GRUB_KERNEL_I386_PC_INSTALL_DOS_PART
-LOCAL(dos_part):
- .long 0xFFFFFFFF
- . = _start + GRUB_KERNEL_I386_PC_INSTALL_BSD_PART
-LOCAL(bsd_part):
- .long 0xFFFFFFFF
-
. = _start + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
reed_solomon_redundancy:
.long 0
* This is the area for all of the special variables.
*/
+LOCAL(boot_dev):
+ .byte 0xFF, 0xFF, 0xFF
LOCAL(boot_drive):
- .byte 0
+ .byte 0x00
/* the real mode code continues... */
LOCAL (codestart):
multiboot_trampoline:
/* fill the boot information */
- movl %edx, %eax
- shrl $8, %eax
- xorl %ebx, %ebx
- cmpb $0xFF, %ah
- je 1f
- movb %ah, %bl
- movl %ebx, LOCAL(dos_part)
-1:
- cmpb $0xFF, %al
- je 2f
- movb %al, %bl
- movl %ebx, LOCAL(bsd_part)
-2:
+ movl %edx, LOCAL(boot_dev)
shrl $24, %edx
- movb %dl, LOCAL(boot_drive)
- movb $0xFF, %dh
- movl $GRUB_MEMORY_MACHINE_PROT_STACK, %esp
/* enter the usual booting */
call prot_to_real
.code16
jmp LOCAL (codestart)
-
.code32
post_reed_solomon:
popl %esi
#endif
- movb LOCAL(boot_drive), %dl
- movl LOCAL(dos_part), %eax
- movl LOCAL(bsd_part), %ebx
+ movl LOCAL(boot_dev), %edx
movl $prot_to_real, %edi
movl $real_to_prot, %ecx
jmp *%esi
GRUB_MOD_INIT(biosdisk)
{
struct grub_biosdisk_cdrp *cdrp
- = (struct grub_biosdisk_cdrp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ = (struct grub_biosdisk_cdrp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ grub_uint8_t boot_drive;
if (grub_disk_firmware_is_tainted)
{
grub_memset (cdrp, 0, sizeof (*cdrp));
cdrp->size = sizeof (*cdrp);
cdrp->media_type = 0xFF;
- if ((! grub_biosdisk_get_cdinfo_int13_extensions (grub_boot_drive, cdrp)) &&
- ((cdrp->media_type & GRUB_BIOSDISK_CDTYPE_MASK)
- == GRUB_BIOSDISK_CDTYPE_NO_EMUL))
+ boot_drive = (grub_boot_device >> 24);
+ if ((! grub_biosdisk_get_cdinfo_int13_extensions (boot_drive, cdrp))
+ && ((cdrp->media_type & GRUB_BIOSDISK_CDTYPE_MASK)
+ == GRUB_BIOSDISK_CDTYPE_NO_EMUL))
cd_drive = cdrp->drive_no;
/* Since diskboot.S rejects devices over 0x90 it must be a CD booted with
cdboot.S
*/
- if (grub_boot_drive >= 0x90)
- cd_drive = grub_boot_drive;
+ if (boot_drive >= 0x90)
+ cd_drive = boot_drive;
grub_disk_dev_register (&grub_biosdisk_dev);
}
grub_machine_get_bootlocation (char **device, char **path)
{
char *ptr;
+ grub_uint8_t boot_drive, dos_part, bsd_part;
+
+ boot_drive = (grub_boot_device >> 24);
+ dos_part = (grub_boot_device >> 16);
+ bsd_part = (grub_boot_device >> 8);
/* No hardcoded root partition - make it from the boot drive and the
partition number encoded at the install time. */
- if (grub_boot_drive == GRUB_BOOT_MACHINE_PXE_DL)
+ if (boot_drive == GRUB_BOOT_MACHINE_PXE_DL)
{
if (grub_pc_net_config)
grub_pc_net_config (device, path);
*device = grub_malloc (DEV_SIZE);
ptr = *device;
grub_snprintf (*device, DEV_SIZE,
- "%cd%u", (grub_boot_drive & 0x80) ? 'h' : 'f',
- grub_boot_drive & 0x7f);
+ "%cd%u", (boot_drive & 0x80) ? 'h' : 'f',
+ boot_drive & 0x7f);
ptr += grub_strlen (ptr);
- if (grub_install_dos_part >= 0)
+ if (dos_part != 0xff)
grub_snprintf (ptr, DEV_SIZE - (ptr - *device),
- ",%u", grub_install_dos_part + 1);
+ ",%u", dos_part + 1);
ptr += grub_strlen (ptr);
- if (grub_install_bsd_part >= 0)
+ if (bsd_part != 0xff)
grub_snprintf (ptr, DEV_SIZE - (ptr - *device), ",%u",
- grub_install_bsd_part + 1);
+ bsd_part + 1);
ptr += grub_strlen (ptr);
*ptr = 0;
}
movsb
#endif
- movl %eax, %esi
-
/* clean out the bss */
movl $BSS_START_SYMBOL, %edi
rep
stosb
- movl %esi, EXT_C(grub_install_dos_part)
- movb %dl, EXT_C(grub_boot_drive)
- movl %ebx, EXT_C(grub_install_bsd_part)
+ movl %edx, EXT_C(grub_boot_device)
/*
* Call the start of main body of C code.
#include "../int.S"
.bss
-VARIABLE(grub_boot_drive)
- .byte 0
-VARIABLE(grub_install_dos_part)
- .long 0xFFFFFFFF
-VARIABLE(grub_install_bsd_part)
- .long 0xFFFFFFFF
+VARIABLE(grub_boot_device)
+ .long 0
/* The total size of module images following the kernel. */
extern grub_int32_t grub_total_module_size;
-/* The DOS partition number of the installed partition. */
-extern grub_int32_t grub_install_dos_part;
-
-/* The BSD partition number of the installed partition. */
-extern grub_int32_t grub_install_bsd_part;
-
-/* The boot BIOS drive number. */
-extern grub_uint8_t EXPORT_VAR(grub_boot_drive);
+extern grub_uint32_t EXPORT_VAR(grub_boot_device);
extern void (*EXPORT_VAR(grub_pc_net_config)) (char **device, char **path);
/* The offset of GRUB_COMPRESSED_SIZE. */
#define GRUB_DECOMPRESSOR_I386_PC_UNCOMPRESSED_SIZE 0x0c
-/* The offset of GRUB_INSTALL_DOS_PART. */
-#define GRUB_KERNEL_I386_PC_INSTALL_DOS_PART 0x10
-
-/* The offset of GRUB_INSTALL_BSD_PART. */
-#define GRUB_KERNEL_I386_PC_INSTALL_BSD_PART 0x14
-
/* Offset of reed_solomon_redundancy. */
-#define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x18
+#define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x10
#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x6e0
#define GRUB_BOOT_MACHINE_KERNEL_SEG GRUB_OFFSETS_CONCAT (GRUB_BOOT_, GRUB_MACHINE, _KERNEL_SEG)
#define GRUB_MEMORY_MACHINE_UPPER GRUB_OFFSETS_CONCAT (GRUB_MEMORY_, GRUB_MACHINE, _UPPER)
-#define GRUB_KERNEL_MACHINE_INSTALL_BSD_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _INSTALL_BSD_PART)
-#define GRUB_KERNEL_MACHINE_INSTALL_DOS_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _INSTALL_DOS_PART)
#define GRUB_MACHINE_LINK_ADDR GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _LINK_ADDR)
#define GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_DECOMPRESSOR_, GRUB_MACHINE, _COMPRESSED_SIZE)
echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/load.cfg"
config_opt="-c ${grubdir}/load.cfg "
modules="$modules search_fs_uuid"
- elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ] || [ "x$platform" = xieee1275 ]; then
+ else
# we need to hardcode the partition number in the core image's prefix.
if [ x"$grub_partition" = x ]; then
prefix_drive="()"
grub_uint16_t elf_target;
unsigned section_align;
signed vaddr_offset;
- unsigned install_dos_part, install_bsd_part;
grub_uint64_t link_addr;
unsigned mod_gap, mod_align;
grub_compression_t default_compression;
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR,
.elf_target = EM_386,
.link_align = 4,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR,
.elf_target = EM_386,
.link_align = 4,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = GRUB_KERNEL_I386_PC_INSTALL_DOS_PART,
- .install_bsd_part = GRUB_KERNEL_I386_PC_INSTALL_BSD_PART,
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
},
{
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = GRUB_KERNEL_I386_PC_INSTALL_DOS_PART,
- .install_bsd_part = GRUB_KERNEL_I386_PC_INSTALL_BSD_PART,
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
},
{
+ sizeof (struct grub_pe32_optional_header)
+ 4 * sizeof (struct grub_pe32_section_table),
GRUB_PE32_SECTION_ALIGNMENT),
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.pe_target = GRUB_PE32_MACHINE_I386,
.elf_target = EM_386,
},
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_I386_IEEE1275_LINK_ADDR,
.elf_target = EM_386,
.mod_gap = GRUB_KERNEL_I386_IEEE1275_MOD_GAP,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_I386_QEMU_LINK_ADDR
},
{
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
.vaddr_offset = EFI64_HEADER_SIZE,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.pe_target = GRUB_PE32_MACHINE_X86_64,
.elf_target = EM_X86_64,
},
.decompressor_uncompressed_addr = GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
.decompressor_uncompressed_addr = GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
.decompressor_uncompressed_addr = GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR,
.elf_target = EM_PPC,
.mod_gap = GRUB_KERNEL_POWERPC_IEEE1275_MOD_GAP,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
},
{
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
},
{
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
.vaddr_offset = EFI64_HEADER_SIZE,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.pe_target = GRUB_PE32_MACHINE_IA64,
.elf_target = EM_IA_64,
},
.decompressor_uncompressed_addr = GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_ARC_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN,
.decompressor_uncompressed_addr = GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
.decompressor_uncompressed_addr = GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
.decompressor_uncompressed_addr = GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
.decompressor_uncompressed_addr = GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
- .install_dos_part = TARGET_NO_FIELD,
- .install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
core_size = full_size;
}
- /* If we included a drive in our prefix, let GRUB know it doesn't have to
- prepend the drive told by BIOS. */
- if (image_target->install_dos_part != TARGET_NO_FIELD
- && image_target->install_bsd_part != TARGET_NO_FIELD && prefix[0] == '(')
- {
- *((grub_int32_t *) (core_img + image_target->install_dos_part))
- = grub_host_to_target32 (-2);
- *((grub_int32_t *) (core_img + image_target->install_bsd_part))
- = grub_host_to_target32 (-2);
- }
-
switch (image_target->id)
{
case IMAGE_I386_PC:
{
#ifdef GRUB_MACHINE_PCBIOS
{
- grub_int32_t *install_dos_part, *install_bsd_part;
- grub_int32_t dos_part, bsd_part;
grub_uint8_t *boot_drive;
grub_disk_addr_t *kernel_sector;
boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE);
kernel_sector = (grub_disk_addr_t *) (boot_img
+ GRUB_BOOT_MACHINE_KERNEL_SECTOR);
-
- install_dos_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
- + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART);
- install_bsd_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
- + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART);
-
- /* If we hardcoded drive as part of prefix, we don't want to
- override the current setting. */
- if (*install_dos_part != -2)
- {
- /* Embed information about the installed location. */
- if (root_dev->disk->partition)
- {
- if (root_dev->disk->partition->parent)
- {
- if (root_dev->disk->partition->parent->parent)
- grub_util_error (_("Installing on doubly nested partitions "
- "is not supported"));
- dos_part = root_dev->disk->partition->parent->number;
- bsd_part = root_dev->disk->partition->number;
- }
- else
- {
- dos_part = root_dev->disk->partition->number;
- bsd_part = -1;
- }
- }
- else
- dos_part = bsd_part = -1;
- }
- else
- {
- dos_part = grub_le_to_cpu32 (*install_dos_part);
- bsd_part = grub_le_to_cpu32 (*install_bsd_part);
- }
-
- grub_util_info ("dos partition is %d, bsd partition is %d",
- dos_part, bsd_part);
-
- *install_dos_part = grub_cpu_to_le32 (dos_part);
- *install_bsd_part = grub_cpu_to_le32 (bsd_part);
-
/* FIXME: can this be skipped? */
*boot_drive = 0xFF;