mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-24 14:32:58 +00:00
f74b50e380
Signed-off-by: Peter Jones <pjones@redhat.com>
373 lines
7.7 KiB
Diff
373 lines
7.7 KiB
Diff
From 1a14b474415a15b4c75400eda67c9ef00895f0d1 Mon Sep 17 00:00:00 2001
|
|
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
Date: Sun, 14 Apr 2013 18:53:14 +0200
|
|
Subject: [PATCH 308/482] Move GRUB out of system area when using
|
|
xorriso 1.2.9 or later.
|
|
|
|
---
|
|
ChangeLog | 4 +
|
|
grub-core/Makefile.core.def | 13 +++
|
|
grub-core/boot/i386/pc/boot.S | 194 +++++++++++++++++++++++++---------------
|
|
grub-core/boot/i386/pc/cdboot.S | 5 +-
|
|
util/grub-mkrescue.in | 23 +++--
|
|
5 files changed, 159 insertions(+), 80 deletions(-)
|
|
|
|
diff --git a/ChangeLog b/ChangeLog
|
|
index 60effd3..fc3dd51 100644
|
|
--- a/ChangeLog
|
|
+++ b/ChangeLog
|
|
@@ -1,5 +1,9 @@
|
|
2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
|
+ Move GRUB out of system area when using xorriso 1.2.9 or later.
|
|
+
|
|
+2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
|
+
|
|
* tests/grub_cmd_date.in: Add missing exit 1.
|
|
|
|
2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
|
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
|
index f1f1012..459e566 100644
|
|
--- a/grub-core/Makefile.core.def
|
|
+++ b/grub-core/Makefile.core.def
|
|
@@ -282,6 +282,19 @@ image = {
|
|
};
|
|
|
|
image = {
|
|
+ name = boot_hybrid;
|
|
+ i386_pc = boot/i386/pc/boot.S;
|
|
+
|
|
+ cppflags = '-DHYBRID_BOOT=1';
|
|
+
|
|
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
|
|
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
|
|
+
|
|
+ objcopyflags = '-O binary';
|
|
+ enable = i386_pc;
|
|
+};
|
|
+
|
|
+image = {
|
|
name = cdboot;
|
|
|
|
i386_pc = boot/i386/pc/cdboot.S;
|
|
diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S
|
|
index 314f140..c0880c6 100644
|
|
--- a/grub-core/boot/i386/pc/boot.S
|
|
+++ b/grub-core/boot/i386/pc/boot.S
|
|
@@ -28,6 +28,81 @@
|
|
#define MSG(x) movw $x, %si; call LOCAL(message)
|
|
#define ERR(x) movw $x, %si; jmp LOCAL(error_message)
|
|
|
|
+ .macro floppy
|
|
+part_start:
|
|
+
|
|
+probe_values:
|
|
+ .byte 36, 18, 15, 9, 0
|
|
+
|
|
+LOCAL(floppy_probe):
|
|
+/*
|
|
+ * Perform floppy probe.
|
|
+ */
|
|
+
|
|
+ movw $probe_values - 1, %si
|
|
+
|
|
+LOCAL(probe_loop):
|
|
+ /* reset floppy controller INT 13h AH=0 */
|
|
+ xorw %ax, %ax
|
|
+ int $0x13
|
|
+
|
|
+ incw %si
|
|
+ movb (%si), %cl
|
|
+
|
|
+ /* if number of sectors is 0, display error and die */
|
|
+ cmpb $0, %cl
|
|
+ jne 1f
|
|
+
|
|
+/*
|
|
+ * Floppy disk probe failure.
|
|
+ */
|
|
+ MSG(fd_probe_error_string)
|
|
+ jmp LOCAL(general_error)
|
|
+
|
|
+/* "Floppy" */
|
|
+fd_probe_error_string: .asciz "Floppy"
|
|
+
|
|
+1:
|
|
+ /* perform read */
|
|
+ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
|
|
+ movw %bx, %es
|
|
+ xorw %bx, %bx
|
|
+ movw $0x201, %ax
|
|
+ movb $0, %ch
|
|
+ movb $0, %dh
|
|
+ int $0x13
|
|
+
|
|
+ /* if error, jump to "LOCAL(probe_loop)" */
|
|
+ jc LOCAL(probe_loop)
|
|
+
|
|
+ /* %cl is already the correct value! */
|
|
+ movb $1, %dh
|
|
+ movb $79, %ch
|
|
+
|
|
+ jmp LOCAL(final_init)
|
|
+ .endm
|
|
+
|
|
+ .macro scratch
|
|
+
|
|
+ /* scratch space */
|
|
+mode:
|
|
+ .byte 0
|
|
+disk_address_packet:
|
|
+sectors:
|
|
+ .long 0
|
|
+heads:
|
|
+ .long 0
|
|
+cylinders:
|
|
+ .word 0
|
|
+sector_start:
|
|
+ .byte 0
|
|
+head_start:
|
|
+ .byte 0
|
|
+cylinder_start:
|
|
+ .word 0
|
|
+ /* more space... */
|
|
+ .endm
|
|
+
|
|
.file "boot.S"
|
|
|
|
.text
|
|
@@ -51,6 +126,34 @@ start:
|
|
jmp LOCAL(after_BPB)
|
|
nop /* do I care about this ??? */
|
|
|
|
+#ifdef HYBRID_BOOT
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+
|
|
+ nop
|
|
+ nop
|
|
+ jmp LOCAL(after_BPB)
|
|
+#else
|
|
/*
|
|
* This space is for the BIOS parameter block!!!! Don't change
|
|
* the first jump, nor start the code anywhere but right after
|
|
@@ -59,27 +162,14 @@ start:
|
|
|
|
. = _start + GRUB_BOOT_MACHINE_BPB_START
|
|
. = _start + 4
|
|
-
|
|
- /* scratch space */
|
|
-mode:
|
|
- .byte 0
|
|
-disk_address_packet:
|
|
-sectors:
|
|
- .long 0
|
|
-heads:
|
|
- .long 0
|
|
-cylinders:
|
|
- .word 0
|
|
-sector_start:
|
|
- .byte 0
|
|
-head_start:
|
|
- .byte 0
|
|
-cylinder_start:
|
|
- .word 0
|
|
- /* more space... */
|
|
+#endif
|
|
+#ifdef HYBRID_BOOT
|
|
+ floppy
|
|
+#else
|
|
+ scratch
|
|
+#endif
|
|
|
|
. = _start + GRUB_BOOT_MACHINE_BPB_END
|
|
-
|
|
/*
|
|
* End of BIOS parameter block.
|
|
*/
|
|
@@ -87,9 +177,11 @@ cylinder_start:
|
|
kernel_address:
|
|
.word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
|
|
|
+#ifndef HYBRID_BOOT
|
|
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
|
|
kernel_sector:
|
|
.long 1, 0
|
|
+#endif
|
|
|
|
. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
|
|
boot_drive:
|
|
@@ -410,6 +502,11 @@ LOCAL(message):
|
|
* number here.
|
|
*/
|
|
|
|
+#ifdef HYBRID_BOOT
|
|
+ . = _start + 0x1b0
|
|
+kernel_sector:
|
|
+ .long 1, 0
|
|
+#endif
|
|
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
|
|
nt_magic:
|
|
.long 0
|
|
@@ -419,62 +516,17 @@ nt_magic:
|
|
* This is where an MBR would go if on a hard disk. The code
|
|
* here isn't even referenced unless we're on a floppy. Kinda
|
|
* sneaky, huh?
|
|
- */
|
|
+ */
|
|
|
|
. = _start + GRUB_BOOT_MACHINE_PART_START
|
|
-part_start:
|
|
-
|
|
-probe_values:
|
|
- .byte 36, 18, 15, 9, 0
|
|
-
|
|
-LOCAL(floppy_probe):
|
|
-/*
|
|
- * Perform floppy probe.
|
|
- */
|
|
-
|
|
- movw $probe_values - 1, %si
|
|
-
|
|
-LOCAL(probe_loop):
|
|
- /* reset floppy controller INT 13h AH=0 */
|
|
- xorw %ax, %ax
|
|
- int $0x13
|
|
-
|
|
- incw %si
|
|
- movb (%si), %cl
|
|
-
|
|
- /* if number of sectors is 0, display error and die */
|
|
- cmpb $0, %cl
|
|
- jne 1f
|
|
-
|
|
-/*
|
|
- * Floppy disk probe failure.
|
|
- */
|
|
- MSG(fd_probe_error_string)
|
|
- jmp LOCAL(general_error)
|
|
-
|
|
-/* "Floppy" */
|
|
-fd_probe_error_string: .asciz "Floppy"
|
|
-
|
|
-1:
|
|
- /* perform read */
|
|
- movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
|
|
- movw %bx, %es
|
|
- xorw %bx, %bx
|
|
- movw $0x201, %ax
|
|
- movb $0, %ch
|
|
- movb $0, %dh
|
|
- int $0x13
|
|
|
|
- /* if error, jump to "LOCAL(probe_loop)" */
|
|
- jc LOCAL(probe_loop)
|
|
-
|
|
- /* %cl is already the correct value! */
|
|
- movb $1, %dh
|
|
- movb $79, %ch
|
|
-
|
|
- jmp LOCAL(final_init)
|
|
+#ifndef HYBRID_BOOT
|
|
+ floppy
|
|
+#else
|
|
+ scratch
|
|
+#endif
|
|
|
|
. = _start + GRUB_BOOT_MACHINE_PART_END
|
|
-
|
|
+
|
|
/* the last 2 bytes in the sector 0 contain the signature */
|
|
.word GRUB_BOOT_MACHINE_SIGNATURE
|
|
diff --git a/grub-core/boot/i386/pc/cdboot.S b/grub-core/boot/i386/pc/cdboot.S
|
|
index d939835..92df7c7 100644
|
|
--- a/grub-core/boot/i386/pc/cdboot.S
|
|
+++ b/grub-core/boot/i386/pc/cdboot.S
|
|
@@ -93,11 +93,12 @@ LOCAL(read_cdrom):
|
|
pushw $CDBLK_LENG
|
|
|
|
/* Block number. */
|
|
+ incl %esi
|
|
pushl %eax
|
|
pushl %esi
|
|
|
|
/* Buffer address. */
|
|
- pushw $((DATA_ADDR - 0x400)>> 4)
|
|
+ pushw $((DATA_ADDR - 0x200)>> 4)
|
|
pushl %eax
|
|
pushw $0x10
|
|
|
|
@@ -167,6 +168,6 @@ err_noboot_msg:
|
|
err_cdfail_msg:
|
|
.ascii "cdrom read fails\0"
|
|
|
|
- . = start + 0x1FF
|
|
+ . = start + 0x7FF
|
|
|
|
.byte 0
|
|
diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in
|
|
index c74c8ca..b97d674 100644
|
|
--- a/util/grub-mkrescue.in
|
|
+++ b/util/grub-mkrescue.in
|
|
@@ -365,15 +365,25 @@ if test -e "${pc_dir}" ; then
|
|
iso9660 biosdisk
|
|
cat "${pc_dir}/cdboot.img" "${core_img}" > "${iso9660_dir}/boot/grub/i386-pc/eltorito.img"
|
|
|
|
- embed_img="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
|
|
- cat "${pc_dir}/boot.img" "${core_img}" > "${embed_img}"
|
|
-
|
|
- rm -f "${core_img}"
|
|
-
|
|
grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table"
|
|
if [ "$system_area" = common ]; then
|
|
- grub_mkisofs_arguments="--embedded-boot ${embed_img}"
|
|
+ if "${xorriso}" -as mkisofs -help 2>&1 | fgrep "grub2-boot-info" >/dev/null; then
|
|
+ grub_mkisofs_arguments="${grub_mkisofs_arguments} --grub2-boot-info --grub2-mbr ${pc_dir}/boot_hybrid.img"
|
|
+ else
|
|
+ gettext "Your xorriso doesn't support \`--grub2-boot-info'. Some features are disabled. Please use xorriso 1.2.9 or later."
|
|
+ echo
|
|
+ sysarea_img="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
|
|
+ cat "${pc_dir}/boot.img" "${core_img}" > "${sysarea_img}"
|
|
+ if [ "$(wc -c "${sysarea_img}" | awk '{ print $1; }')" -gt 32768 ]; then
|
|
+ gettext "Your xorriso doesn't support \`--grub2-boot-info'. Your core image is too big. Boot as disk is disabled. Please use xorriso 1.2.9 or later."
|
|
+ echo
|
|
+ else
|
|
+ grub_mkisofs_arguments="${grub_mkisofs_arguments} -G ${sysarea_img}"
|
|
+ fi
|
|
+ fi
|
|
fi
|
|
+
|
|
+ rm -f "${core_img}"
|
|
fi
|
|
|
|
# build multiboot core.img
|
|
@@ -495,6 +505,5 @@ fi
|
|
rm -rf "${iso9660_dir}"
|
|
|
|
rm -f "${sysarea_img}"
|
|
-rm -f "${embed_img}"
|
|
|
|
exit 0
|
|
--
|
|
1.8.2.1
|
|
|