Move GRUB out of system area when using xorriso 1.2.9 or later.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-14 18:53:14 +02:00
parent 5351da81e0
commit b49fe8792a
5 changed files with 159 additions and 80 deletions

View file

@ -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> 2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
* tests/grub_cmd_date.in: Add missing exit 1. * tests/grub_cmd_date.in: Add missing exit 1.

View file

@ -281,6 +281,19 @@ image = {
enable = sparc64_ieee1275; 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 = { image = {
name = cdboot; name = cdboot;

View file

@ -28,6 +28,81 @@
#define MSG(x) movw $x, %si; call LOCAL(message) #define MSG(x) movw $x, %si; call LOCAL(message)
#define ERR(x) movw $x, %si; jmp LOCAL(error_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" .file "boot.S"
.text .text
@ -51,6 +126,34 @@ start:
jmp LOCAL(after_BPB) jmp LOCAL(after_BPB)
nop /* do I care about this ??? */ 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 * This space is for the BIOS parameter block!!!! Don't change
* the first jump, nor start the code anywhere but right after * the first jump, nor start the code anywhere but right after
@ -59,27 +162,14 @@ start:
. = _start + GRUB_BOOT_MACHINE_BPB_START . = _start + GRUB_BOOT_MACHINE_BPB_START
. = _start + 4 . = _start + 4
#endif
/* scratch space */ #ifdef HYBRID_BOOT
mode: floppy
.byte 0 #else
disk_address_packet: scratch
sectors: #endif
.long 0
heads:
.long 0
cylinders:
.word 0
sector_start:
.byte 0
head_start:
.byte 0
cylinder_start:
.word 0
/* more space... */
. = _start + GRUB_BOOT_MACHINE_BPB_END . = _start + GRUB_BOOT_MACHINE_BPB_END
/* /*
* End of BIOS parameter block. * End of BIOS parameter block.
*/ */
@ -87,9 +177,11 @@ cylinder_start:
kernel_address: kernel_address:
.word GRUB_BOOT_MACHINE_KERNEL_ADDR .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#ifndef HYBRID_BOOT
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR . = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
kernel_sector: kernel_sector:
.long 1, 0 .long 1, 0
#endif
. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE . = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
boot_drive: boot_drive:
@ -410,6 +502,11 @@ LOCAL(message):
* number here. * number here.
*/ */
#ifdef HYBRID_BOOT
. = _start + 0x1b0
kernel_sector:
.long 1, 0
#endif
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC . = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic: nt_magic:
.long 0 .long 0
@ -422,57 +519,12 @@ nt_magic:
*/ */
. = _start + GRUB_BOOT_MACHINE_PART_START . = _start + GRUB_BOOT_MACHINE_PART_START
part_start:
probe_values: #ifndef HYBRID_BOOT
.byte 36, 18, 15, 9, 0 floppy
#else
LOCAL(floppy_probe): scratch
/* #endif
* 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)
. = _start + GRUB_BOOT_MACHINE_PART_END . = _start + GRUB_BOOT_MACHINE_PART_END

View file

@ -93,11 +93,12 @@ LOCAL(read_cdrom):
pushw $CDBLK_LENG pushw $CDBLK_LENG
/* Block number. */ /* Block number. */
incl %esi
pushl %eax pushl %eax
pushl %esi pushl %esi
/* Buffer address. */ /* Buffer address. */
pushw $((DATA_ADDR - 0x400)>> 4) pushw $((DATA_ADDR - 0x200)>> 4)
pushl %eax pushl %eax
pushw $0x10 pushw $0x10
@ -167,6 +168,6 @@ err_noboot_msg:
err_cdfail_msg: err_cdfail_msg:
.ascii "cdrom read fails\0" .ascii "cdrom read fails\0"
. = start + 0x1FF . = start + 0x7FF
.byte 0 .byte 0

View file

@ -365,15 +365,25 @@ if test -e "${pc_dir}" ; then
iso9660 biosdisk iso9660 biosdisk
cat "${pc_dir}/cdboot.img" "${core_img}" > "${iso9660_dir}/boot/grub/i386-pc/eltorito.img" 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" 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 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
fi
rm -f "${core_img}"
fi fi
# build multiboot core.img # build multiboot core.img
@ -495,6 +505,5 @@ fi
rm -rf "${iso9660_dir}" rm -rf "${iso9660_dir}"
rm -f "${sysarea_img}" rm -f "${sysarea_img}"
rm -f "${embed_img}"
exit 0 exit 0