From 8a02952132bdc58a643b468f28e38594d9caecfa Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 14 Apr 2013 17:10:55 +0200 Subject: [PATCH 303/364] Support mkrescue on sparc64. --- ChangeLog | 4 ++ INSTALL | 2 +- Makefile.util.def | 1 + grub-core/Makefile.core.def | 9 ++++ grub-core/boot/sparc64/ieee1275/boot.S | 24 ++++++++- util/grub-mkimage.c | 21 +++++++- util/grub-mkrescue.in | 89 +++++++++++++++++++++++++--------- 7 files changed, 123 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index df9e300..4c1e28d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2013-04-14 Vladimir Serbinenko + Support mkrescue on sparc64. + +2013-04-14 Vladimir Serbinenko + Allow IEEE1275 ports on path even if it wasn't detected automatically. Needed on OpenBIOS due to incomplete device tree. diff --git a/INSTALL b/INSTALL index 128bf47..3333686 100644 --- a/INSTALL +++ b/INSTALL @@ -45,7 +45,7 @@ need the following. Prerequisites for make-check: * qemu, specifically the binary 'qemu-system-i386' -* xorriso, for grub-mkrescue and grub-shell +* xorriso 1.2.9 or later, for grub-mkrescue and grub-shell Configuring the GRUB ==================== diff --git a/Makefile.util.def b/Makefile.util.def index ef3c4ea..ed7b412 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -475,6 +475,7 @@ script = { enable = mips_loongson; enable = ia64_efi; enable = powerpc_ieee1275; + enable = sparc64_ieee1275; }; script = { diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 6aead4c..f1f1012 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -283,10 +283,19 @@ image = { image = { name = cdboot; + i386_pc = boot/i386/pc/cdboot.S; i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)'; i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00'; + + sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S; + sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big'; + sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000'; + sparc64_ieee1275_cppflags = '-DCDBOOT=1'; + objcopyflags = '-O binary'; + + enable = sparc64_ieee1275; enable = i386_pc; }; diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S index f796995..0ab9a4a 100644 --- a/grub-core/boot/sparc64/ieee1275/boot.S +++ b/grub-core/boot/sparc64/ieee1275/boot.S @@ -28,6 +28,7 @@ pic_base: call boot_continue mov %o4, CIF_REG +#ifndef CDBOOT /* The offsets to these locations are defined by the * GRUB_BOOT_MACHINE_foo macros in include/grub/sparc/ieee1275/boot.h, * and grub-setup uses this to patch these next three values as needed. @@ -43,9 +44,19 @@ pic_base: . = _start + GRUB_BOOT_MACHINE_BOOT_DEVPATH boot_path: . = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE -boot_path_end: kernel_byte: .xword (2 << 9) +boot_path_end: kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR +#else +#define boot_path (_start + 512) +#define boot_path_end (_start + 1024) +#include + + . = _start + 8 +kernel_byte: .xword (2 << 9) +kernel_size: .word 512 +kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS +#endif prom_finddev_name: .asciz "finddevice" prom_chosen_path: .asciz "/chosen" @@ -158,8 +169,10 @@ boot_continue: mov GRUB_NAME_LEN, %o3 GET_ABS(boot_path, %o3) +#ifndef CDBOOT ldub [%o3], %o1 brnz,pn %o1, bootpath_known +#endif /* getprop(chosen_node, "bootpath", &buffer, buffer_size) */ GET_ABS(prom_bootpath_name, %o2) @@ -194,12 +207,19 @@ bootpath_known: GET_ABS(prom_read_name, %o0) LDUW_ABS(kernel_address, 0x00, %o2) call prom_call_3_1_o1 +#ifdef CDBOOT + LDUW_ABS(kernel_size, 0x00, %o3) +#else mov 512, %o3 +#endif LDUW_ABS(kernel_address, 0x00, %o2) jmpl %o2, %o7 +#ifdef CDBOOT + mov CIF_REG, %o4 +#else nop - +#endif . = _start + GRUB_BOOT_MACHINE_CODE_END /* the last 4 bytes in the sector 0 contain the signature */ diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 80e7d81..96279a4 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -67,7 +67,8 @@ struct image_target_desc int bigendian; enum { IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT, - IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275, + IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE, + IMAGE_I386_IEEE1275, IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC, IMAGE_QEMU_MIPS_FLASH @@ -336,6 +337,21 @@ struct image_target_desc image_targets[] = }, { .dirname = "sparc64-ieee1275", + .names = { "sparc64-ieee1275-cdcore", NULL }, + .voidp_sizeof = 8, + .bigendian = 1, + .id = IMAGE_SPARC64_CDCORE, + .flags = PLATFORM_FLAGS_NONE, + .total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE, + .decompressor_compressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .section_align = 1, + .vaddr_offset = 0, + .link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR + }, + { + .dirname = "sparc64-ieee1275", .names = { "sparc64-ieee1275-aout", NULL }, .voidp_sizeof = 8, .bigendian = 1, @@ -1021,6 +1037,7 @@ generate_image (const char *dir, const char *prefix, break; case IMAGE_SPARC64_AOUT: case IMAGE_SPARC64_RAW: + case IMAGE_SPARC64_CDCORE: case IMAGE_I386_IEEE1275: case IMAGE_PPC: break; @@ -1360,6 +1377,8 @@ generate_image (const char *dir, const char *prefix, free (boot_path); } break; + case IMAGE_SPARC64_CDCORE: + break; case IMAGE_YEELOONG_FLASH: case IMAGE_FULOONG2F_FLASH: { diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in index a244b2a..c74c8ca 100644 --- a/util/grub-mkrescue.in +++ b/util/grub-mkrescue.in @@ -44,6 +44,7 @@ i386_ieee1275_dir="${libdir}/@PACKAGE@/i386-ieee1275" efi32_dir="${libdir}/@PACKAGE@/i386-efi" efi64_dir="${libdir}/@PACKAGE@/x86_64-efi" ia64_dir="${libdir}/@PACKAGE@/ia64-efi" +sparc64_dir="${libdir}/@PACKAGE@/sparc64-ieee1275" ppc_dir="${libdir}/@PACKAGE@/powerpc-ieee1275" rom_directory= override_dir= @@ -90,6 +91,7 @@ usage () { print_option_help "--label-bgcolor=$(gettext "COLOR")" "$(gettext "use COLOR for label background")" print_option_help "--product-name=$(gettext "STR")" "$(gettext "use STR as product")" print_option_help "--product-version=$(gettext "STR")" "$(gettext "use STR as product version")" + print_option_help "--sparc-boot" "$(gettext "enable sparc boot. Disables HFS+, APM and boot as disk image for i386-pc")" echo gettext_printf "%s generates a bootable rescue image with specified source files, source directories, or mkisofs options listed by the output of \`%s'\n" "xorriso -as mkisofs -help" "$self" | grub_fmt echo @@ -99,6 +101,8 @@ usage () { gettext "Mail xorriso support requests to ."; echo } +system_area=auto + # Check the arguments. while test $# -gt 0 do @@ -147,6 +151,9 @@ do export PATH ;; + --sparc-boot) + system_area=sparc64 ;; + --product-name) product_name=`argument $option "$@"`; shift ;; --product-name=*) @@ -230,9 +237,7 @@ make_image () gettext_printf "Enabling %s support ...\n" "$2" - memdisk_img="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 - memdisk_dir="`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 - mkdir -p "${memdisk_dir}/boot/grub" + load_cfg="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" (cat << EOF search --fs-uuid --set=root ${iso_uuid} @@ -240,18 +245,36 @@ set prefix=(\${root})/boot/grub EOF for i in $(cat "${source_directory}/partmap.lst") ${modules} ; do echo "insmod $i" - done ; \ - echo "source \$prefix/grub.cfg") \ - > "${memdisk_dir}/boot/grub/grub.cfg" - - (cd "${memdisk_dir}"; tar -cf - boot) > "${memdisk_img}" - rm -rf "${memdisk_dir}" - "$grub_mkimage" -O ${platform} -d "${source_directory}" -m "${memdisk_img}" -o "$3" --prefix='(memdisk)/boot/grub' \ - search iso9660 configfile normal memdisk tar $4 - rm -rf "${memdisk_img}" + done ; ) > "${load_cfg}" + + "$grub_mkimage" -O ${platform} -d "${source_directory}" -c "${load_cfg}" -o "$3" \ + search iso9660 $4 + rm -rf "${load_cfg}" +} + +make_image_fwdisk () +{ + source_directory="$1" + platform=$2 + if ! test -e "${source_directory}"; then + return; + fi + + gettext_printf "Enabling %s support ...\n" "$2" + + "$grub_mkimage" -O ${platform} -d "${source_directory}" -p '()/boot/grub' -o "$3" \ + iso9660 $4 } if [ "${override_dir}" = "" ] ; then + if [ "$system_area" = auto ]; then + if test -e "${pc_dir}" || test -e "${ppc_dir}" \ + || test -e "${efi32_dir}" || test -e "${efi64_dir}"; then + system_area=common; + elif test -e "${sparc64_dir}" ; then + system_area=sparc64; + fi + fi if test -e "${multiboot_dir}" ; then process_input_dir "${multiboot_dir}" i386-multiboot fi @@ -288,6 +311,9 @@ if [ "${override_dir}" = "" ] ; then if test -e "${ppc_dir}" ; then process_input_dir "${ppc_dir}" powerpc-ieee1275 fi + if test -e "${sparc64_dir}" ; then + process_input_dir "${sparc64_dir}" sparc64-ieee1275 + fi else . "${override_dir}"/modinfo.sh process_input_dir "${override_dir}" ${grub_modinfo_target_cpu}-${grub_modinfo_platform} @@ -303,18 +329,20 @@ else loongson_dir= ppc_dir= i386_ieee1275_dir= + sparc64_dir= case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in i386-multiboot) multiboot_dir="${override_dir}" ;; i386-coreboot) coreboot_dir="${override_dir}" ;; i386-qemu) qemu_dir="${override_dir}" ;; - i386-pc) pc_dir="${override_dir}" ;; - i386-efi) efi32_dir="${override_dir}" ;; - x86_64-efi) efi64_dir="${override_dir}" ;; + i386-pc) pc_dir="${override_dir}"; system_area=common;; + i386-efi) efi32_dir="${override_dir}"; system_area=common ;; + x86_64-efi) efi64_dir="${override_dir}"; system_area=common ;; ia64-efi) ia64_dir="${override_dir}" ;; mipsel-qemu_mips) mipsel_qemu_dir="${override_dir}" ;; mipsel-loongson) loongson_dir="${override_dir}" ;; mips-qemu_mips) mips_qemu_dir="${override_dir}" ;; - powerpc-ieee1275) ppc_dir="${override_dir}" ;; + powerpc-ieee1275) ppc_dir="${override_dir}"; system_area=common ;; + sparc64-ieee1275) sparc64_dir="${override_dir}"; system_area=sparc64 ;; i386-ieee1275) i386_ieee1275_dir="${override_dir}" ;; esac fi @@ -342,14 +370,16 @@ if test -e "${pc_dir}" ; then rm -f "${core_img}" - grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-info-table \ - --embedded-boot ${embed_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}" + fi fi # build multiboot core.img make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "pata ahci at_keyboard" -make_image "${i386_ieee1275_dir}" i386-ieee1275 "${iso9660_dir}/boot/ofwx86.elf" "" +make_image_fwdisk "${i386_ieee1275_dir}" i386-ieee1275 "${iso9660_dir}/boot/ofwx86.elf" "" if test -e "${efi64_dir}" || test -e "${efi32_dir}" || test -e "${ia64_dir}"; then efi_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 @@ -384,7 +414,7 @@ if test -e "${efi64_dir}" || test -e "${efi32_dir}" || test -e "${ia64_dir}"; th grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img" fi -make_image "${ppc_dir}" powerpc-ieee1275 "${iso9660_dir}/boot/powerpc.elf" "" +make_image_fwdisk "${ppc_dir}" powerpc-ieee1275 "${iso9660_dir}/boot/powerpc.elf" "" if [ -e "${iso9660_dir}"/System/Library/CoreServices/boot.efi ] || [ -e "${iso9660_dir}/boot/powerpc.elf" ]; then mkdir -p "${iso9660_dir}"/System/Library/CoreServices touch "${iso9660_dir}/mach_kernel" @@ -402,20 +432,32 @@ if [ -e "${iso9660_dir}"/System/Library/CoreServices/boot.efi ] || [ -e "${iso96 EOF "$grub_render_label" -f "$label_font" -b "$label_bgcolor" -c "$label_color" -t "${product_name} ${product_version}" -o "${iso9660_dir}/System/Library/CoreServices/.disk_label" echo "${product_name} ${product_version}" > "${iso9660_dir}/System/Library/CoreServices/.disk_label.contentDetails" - grub_mkisofs_arguments="${grub_mkisofs_arguments} -hfsplus -hfsplus-file-creator-type chrp tbxj /System/Library/CoreServices/.disk_label" + if [ "$system_area" = common ]; then + grub_mkisofs_arguments="${grub_mkisofs_arguments} -hfsplus -hfsplus-file-creator-type chrp tbxj /System/Library/CoreServices/.disk_label" + fi fi if [ -e "${iso9660_dir}/boot/powerpc.elf" ] ; then cp "${ppc_dir}/grub.chrp" "${iso9660_dir}"/System/Library/CoreServices/BootX cp "${iso9660_dir}/boot/powerpc.elf" "${iso9660_dir}"/System/Library/CoreServices/grub.elf # FIXME: add PreP - grub_mkisofs_arguments="${grub_mkisofs_arguments} -hfsplus-file-creator-type chrp tbxi /System/Library/CoreServices/BootX -hfs-bless-by p /System/Library/CoreServices -sysid PPC" + if [ "$system_area" = common ]; then + grub_mkisofs_arguments="${grub_mkisofs_arguments} -hfsplus-file-creator-type chrp tbxi /System/Library/CoreServices/BootX -hfs-bless-by p /System/Library/CoreServices" + fi + grub_mkisofs_arguments="${grub_mkisofs_arguments} -sysid PPC" fi -if [ -e "${iso9660_dir}"/System/Library/CoreServices/boot.efi ]; then +if [ -e "${iso9660_dir}"/System/Library/CoreServices/boot.efi ] && [ "$system_area" = common ]; then grub_mkisofs_arguments="${grub_mkisofs_arguments} -hfs-bless-by i /System/Library/CoreServices/boot.efi" fi +make_image_fwdisk "${sparc64_dir}" sparc64-ieee1275-cdcore "${iso9660_dir}/boot/grub/sparc64-ieee1275/core.img" "" +if [ -e "${iso9660_dir}"/boot/grub/sparc64-ieee1275/core.img ] && [ "$system_area" = sparc64 ]; then + sysarea_img="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 + dd if=/dev/zero count=1 bs=512 | cat - "${sparc64_dir}"/cdboot.img > "$sysarea_img" + grub_mkisofs_arguments="${grub_mkisofs_arguments} -G $sysarea_img -B , --grub2-sparc-core /boot/grub/sparc64-ieee1275/core.img" +fi + make_image "${mipsel_qemu_dir}" mipsel-qemu_mips-elf "${iso9660_dir}/boot/mipsel-qemu_mips.elf" "pata" if [ -e "${iso9660_dir}/boot/mipsel-qemu_mips.elf" ] && [ -d "${rom_directory}" ]; then cp "${iso9660_dir}/boot/mipsel-qemu_mips.elf" "${rom_directory}/mipsel-qemu_mips.elf" @@ -452,6 +494,7 @@ fi "${xorriso}" -as mkisofs -graft-points ${grub_mkisofs_arguments} --protective-msdos-label -o "${output_image}" -r "${iso9660_dir}" --sort-weight 0 / --sort-weight 1 /boot ${source} rm -rf "${iso9660_dir}" +rm -f "${sysarea_img}" rm -f "${embed_img}" exit 0 -- 1.8.1.4