]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Move GRUB out of system area when using xorriso 1.2.9 or later.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 14 Apr 2013 16:53:14 +0000 (18:53 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 14 Apr 2013 16:53:14 +0000 (18:53 +0200)
ChangeLog
grub-core/Makefile.core.def
grub-core/boot/i386/pc/boot.S
grub-core/boot/i386/pc/cdboot.S
util/grub-mkrescue.in

index 60effd3d128419cca8f7bcbdcd75ac91a7b1fb0e..fc3dd5172af50a5f6c49b6b6f4c2a745ea35eb84 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+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.
index f1f10125aa5b89fd896b11be461c99017a76b2cc..459e56645b46ad51219880af73f9723a9d45d2c7 100644 (file)
@@ -281,6 +281,19 @@ image = {
   enable = sparc64_ieee1275;
 };
 
+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;
 
index 314f1401618cc9d9fdba472f8342fe1cc5f95d1c..c0880c6b854c350c43ce6e3cf39e8e4f85936fe1 100644 (file)
 #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
index d939835a9df2969348345085ff6bda6b5478e680..92df7c76f056e710c1bf7005ea2efc15cc83d1a1 100644 (file)
@@ -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
index c74c8ca66c84aa4a993b71fb4ef8c1b0b1daa48c..b97d674b6a05d54251bb36752252c9c286f721cb 100644 (file)
@@ -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