#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
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
. = _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.
*/
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:
* number here.
*/
+#ifdef HYBRID_BOOT
+ . = _start + 0x1b0
+kernel_sector:
+ .long 1, 0
+#endif
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic:
.long 0
* 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
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
rm -rf "${iso9660_dir}"
rm -f "${sysarea_img}"
-rm -f "${embed_img}"
exit 0