diff --git a/0001-script-provide-overridable-root-by-subvol.patch b/0001-script-provide-overridable-root-by-subvol.patch index c2a6fad..e2414dc 100644 --- a/0001-script-provide-overridable-root-by-subvol.patch +++ b/0001-script-provide-overridable-root-by-subvol.patch @@ -11,17 +11,12 @@ v1: Introduce $boot_prefix for setting prefix on seeking other /boot directory. -v2: -Refresh for s390x-emu. - Signed-off-by: Michael Chang ---- - util/grub.d/10_linux.in | 57 ++++++++++++++++++++++++++++++++++++++++-------- - 1 file changed, 48 insertions(+), 9 deletions(-) - ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in +Index: grub-2.02~beta2/util/grub.d/10_linux.in +=================================================================== +--- grub-2.02~beta2.orig/util/grub.d/10_linux.in ++++ grub-2.02~beta2/util/grub.d/10_linux.in @@ -55,7 +55,9 @@ case x"$GRUB_FS" in xbtrfs) rootsubvol="`make_system_path_relative_to_its_root /`" @@ -33,10 +28,10 @@ Signed-off-by: Michael Chang GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" fi;; xzfs) -@@ -145,17 +147,43 @@ linux_entry () +@@ -126,17 +128,43 @@ linux_entry () + fi printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" fi - fi + + if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then + sed "s/^/$submenu_indentation/" << EOF @@ -79,7 +74,7 @@ Signed-off-by: Michael Chang fi if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. -@@ -163,13 +191,21 @@ EOF +@@ -144,13 +172,21 @@ EOF if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then sed "s/^/$submenu_indentation/" << EOF echo '$message' @@ -103,21 +98,17 @@ Signed-off-by: Michael Chang fi fi sed "s/^/$submenu_indentation/" << EOF -@@ -179,10 +215,13 @@ EOF - +@@ -161,11 +197,11 @@ EOF machine=`uname -m` - case "$machine" in -- i?86 | x86_64) klist="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*" ;; -- s390 | s390x) klist="/boot/image-* /boot/kernel-*" ;; -- *) klist="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* \ -- /boot/kernel-*" ;; -+ i?86 | x86_64) klist="${boot_prefix}/boot/vmlinuz-* \ -+ ${boot_prefix}/vmlinuz-* ${boot_prefix}/boot/kernel-*" ;; -+ s390 | s390x) klist="${boot_prefix}/boot/image-* \ -+ ${boot_prefix}/boot/kernel-*" ;; -+ *) klist="${boot_prefix}/boot/vmlinuz-* \ -+ ${boot_prefix}/boot/vmlinux-* ${boot_prefix}/vmlinuz-* \ -+ ${boot_prefix}/vmlinux-* /boot/kernel-*" ;; + case "x$machine" in + xi?86 | xx86_64) +- list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do ++ list=`for i in ${boot_prefix}/boot/vmlinuz-* ${boot_prefix}/vmlinuz-* ${boot_prefix}/boot/kernel-* ; do + if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi + done` ;; + *) +- list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do ++ list=`for i in ${boot_prefix}/boot/vmlinuz-* ${boot_prefix}/boot/vmlinux-* ${boot_prefix}/vmlinuz-* ${boot_prefix}/vmlinux-* ${boot_prefix}/boot/kernel-* ; do + if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi + done` ;; esac - list=`for i in $klist; do - if grub_file_is_not_garbage "$i" ; then diff --git a/80_suse_btrfs_snapshot b/80_suse_btrfs_snapshot deleted file mode 100644 index 365e899..0000000 --- a/80_suse_btrfs_snapshot +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh -set -e -if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && - [ "x${GRUB_FS}" = "xbtrfs" ] ; then - cat < [Enter] "engage" - '^[' => [ESC] "abort" / return to previous "state" - '^i' => [TAB] try completion (in edit & shell mode) - -Available Keys in Menu Mode: - '^a' first entry '^e' last entry - '^p' previous entry '^n' next entry - '^g' previous page '^c' next page - '^f' boot selected entry/enter sub-menu (same as '^j') - 'e' edit selected entry 'c' enter grub-shell - -Available Keys in Edit Mode: - '^p' previous line '^n' next line - '^b' backward char '^f' forward char - '^a' beginning of line '^e' end of line - '^h' backspace '^d' delete - '^k' kill (to end of) line '^y' yank - '^o' open line '^l' refresh screen - '^x' boot entry '^c' enter grub-shell - -Availble Keys on Command Line Mode: - '^p' previous command '^n' next command (from history) - '^a' beginning of line '^e' end of line - '^b' backward char '^f' forward char - '^h' backspace '^d' delete - '^k' kill (to end of) line '^u' discard line - '^y' yank - diff --git a/SUSE_BTRFS_SNAPSHOT_BOOTING.patch b/SUSE_BTRFS_SNAPSHOT_BOOTING.patch deleted file mode 100644 index b556eca..0000000 --- a/SUSE_BTRFS_SNAPSHOT_BOOTING.patch +++ /dev/null @@ -1,99 +0,0 @@ -Index: grub-2.02~beta2/util/grub-mkconfig_lib.in -=================================================================== ---- grub-2.02~beta2.orig/util/grub-mkconfig_lib.in -+++ grub-2.02~beta2/util/grub-mkconfig_lib.in -@@ -49,7 +49,12 @@ grub_warn () - - make_system_path_relative_to_its_root () - { -+ if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && -+ [ "x${GRUB_FS}" = "xbtrfs" ] ; then -+ readlink -f "$1" -+ else - "${grub_mkrelpath}" "$1" -+ fi - } - - is_path_readable_by_grub () -Index: grub-2.02~beta2/util/grub.d/00_header.in -=================================================================== ---- grub-2.02~beta2.orig/util/grub.d/00_header.in -+++ grub-2.02~beta2/util/grub.d/00_header.in -@@ -27,6 +27,14 @@ export TEXTDOMAINDIR="@localedir@" - - . "@datadir@/@PACKAGE@/grub-mkconfig_lib" - -+if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && -+ [ "x${GRUB_FS}" = "xbtrfs" ] ; then -+ cat </dev/null || true` -Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in -=================================================================== ---- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in -+++ grub-2.02~beta2/util/grub.d/20_linux_xen.in -@@ -67,10 +67,14 @@ fi - - case x"$GRUB_FS" in - xbtrfs) -+ if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then -+ GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}" -+ else - rootsubvol="`make_system_path_relative_to_its_root /`" - rootsubvol="${rootsubvol#/}" - if [ "x${rootsubvol}" != x ]; then - GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" -+ fi - fi;; - xzfs) - rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` diff --git a/btrfs_follow_default.patch b/btrfs_follow_default.patch deleted file mode 100644 index 523f721..0000000 --- a/btrfs_follow_default.patch +++ /dev/null @@ -1,179 +0,0 @@ -Index: grub-2.02~beta2/grub-core/fs/btrfs.c -=================================================================== ---- grub-2.02~beta2.orig/grub-core/fs/btrfs.c -+++ grub-2.02~beta2/grub-core/fs/btrfs.c -@@ -913,6 +913,7 @@ grub_btrfs_mount (grub_device_t dev) - { - struct grub_btrfs_data *data; - grub_err_t err; -+ const char *relpath = grub_env_get ("btrfs_relative_path"); - - if (!dev->disk) - { -@@ -943,11 +944,14 @@ grub_btrfs_mount (grub_device_t dev) - data->devices_attached[0].dev = dev; - data->devices_attached[0].id = data->sblock.this_device.device_id; - -- err = btrfs_handle_subvol (data); -- if (err) -+ if (relpath && (relpath[0] == '1' || relpath[0] == 'y')) - { -- grub_free (data); -- return NULL; -+ err = btrfs_handle_subvol (data); -+ if (err) -+ { -+ grub_free (data); -+ return NULL; -+ } - } - - return data; -@@ -1407,24 +1411,39 @@ find_path (struct grub_btrfs_data *data, - grub_size_t allocated = 0; - struct grub_btrfs_dir_item *direl = NULL; - struct grub_btrfs_key key_out; -+ int follow_default; - const char *ctoken; - grub_size_t ctokenlen; - char *path_alloc = NULL; - char *origpath = NULL; - unsigned symlinks_max = 32; -+ const char *relpath = grub_env_get ("btrfs_relative_path"); - -+ follow_default = 0; - origpath = grub_strdup (path); - if (!origpath) - return grub_errno; - -- if (data->fs_tree) -+ if (relpath && (relpath[0] == '1' || relpath[0] == 'y')) - { -- *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; -- *tree = data->fs_tree; -- /* This is a tree root, so everything starts at objectid 256 */ -- key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK); -- key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; -- key->offset = 0; -+ if (data->fs_tree) -+ { -+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; -+ *tree = data->fs_tree; -+ /* This is a tree root, so everything starts at objectid 256 */ -+ key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK); -+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; -+ key->offset = 0; -+ } -+ else -+ { -+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; -+ *tree = data->sblock.root_tree; -+ key->object_id = data->sblock.root_dir_objectid; -+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; -+ key->offset = 0; -+ follow_default = 1; -+ } - } - else - { -@@ -1435,15 +1454,23 @@ find_path (struct grub_btrfs_data *data, - - while (1) - { -- while (path[0] == '/') -- path++; -- if (!path[0]) -- break; -- slash = grub_strchr (path, '/'); -- if (!slash) -- slash = path + grub_strlen (path); -- ctoken = path; -- ctokenlen = slash - path; -+ if (!follow_default) -+ { -+ while (path[0] == '/') -+ path++; -+ if (!path[0]) -+ break; -+ slash = grub_strchr (path, '/'); -+ if (!slash) -+ slash = path + grub_strlen (path); -+ ctoken = path; -+ ctokenlen = slash - path; -+ } -+ else -+ { -+ ctoken = "default"; -+ ctokenlen = sizeof ("default") - 1; -+ } - - if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY) - { -@@ -1454,7 +1481,9 @@ find_path (struct grub_btrfs_data *data, - - if (ctokenlen == 1 && ctoken[0] == '.') - { -- path = slash; -+ if (!follow_default) -+ path = slash; -+ follow_default = 0; - continue; - } - if (ctokenlen == 2 && ctoken[0] == '.' && ctoken[1] == '.') -@@ -1485,8 +1514,9 @@ find_path (struct grub_btrfs_data *data, - *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; - key->object_id = key_out.offset; - -- path = slash; -- -+ if (!follow_default) -+ path = slash; -+ follow_default = 0; - continue; - } - -@@ -1555,7 +1585,9 @@ find_path (struct grub_btrfs_data *data, - return err; - } - -- path = slash; -+ if (!follow_default) -+ path = slash; -+ follow_default = 0; - if (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK) - { - struct grub_btrfs_inode inode; -@@ -1605,14 +1637,26 @@ find_path (struct grub_btrfs_data *data, - path = path_alloc = tmp; - if (path[0] == '/') - { -- if (data->fs_tree) -+ if (relpath && (relpath[0] == '1' || relpath[0] == 'y')) - { -- *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; -- *tree = data->fs_tree; -- /* This is a tree root, so everything starts at objectid 256 */ -- key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK); -- key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; -- key->offset = 0; -+ if (data->fs_tree) -+ { -+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; -+ *tree = data->fs_tree; -+ /* This is a tree root, so everything starts at objectid 256 */ -+ key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK); -+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; -+ key->offset = 0; -+ } -+ else -+ { -+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; -+ *tree = data->sblock.root_tree; -+ key->object_id = data->sblock.root_dir_objectid; -+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; -+ key->offset = 0; -+ follow_default = 1; -+ } - } - else - { diff --git a/grub2-powerpc-libgcc.patch b/grub2-powerpc-libgcc.patch new file mode 100644 index 0000000..5dc409f --- /dev/null +++ b/grub2-powerpc-libgcc.patch @@ -0,0 +1,301 @@ +Index: grub-2.02~beta2/configure.ac +=================================================================== +--- grub-2.02~beta2.orig/configure.ac ++++ grub-2.02~beta2/configure.ac +@@ -1014,7 +1014,7 @@ else + CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" + fi + CPPFLAGS="$TARGET_CPPFLAGS" +-if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then ++if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test x$target_cpu = xpowerpc || test "x$grub_cv_cc_target_clang" = xyes ; then + TARGET_LIBGCC= + else + TARGET_LIBGCC=-lgcc +Index: grub-2.02~beta2/grub-core/kern/powerpc/crtsavres.S +=================================================================== +--- /dev/null ++++ grub-2.02~beta2/grub-core/kern/powerpc/crtsavres.S +@@ -0,0 +1,125 @@ ++/* ++ * Special support for eabi and SVR4 ++ * ++ * Copyright (C) 1995, 1996, 1998, 2000, 2001 Free Software Foundation, Inc. ++ * Written By Michael Meissner ++ * 64-bit support written by David Edelsohn ++ * ++ * This file is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License as published by the ++ * Free Software Foundation; either version 2, or (at your option) any ++ * later version. ++ * ++ * In addition to the permissions in the GNU General Public License, the ++ * Free Software Foundation gives you unlimited permission to link the ++ * compiled version of this file with other programs, and to distribute ++ * those programs without any restriction coming from the use of this ++ * file. (The General Public License restrictions do apply in other ++ * respects; for example, they cover modification of the file, and ++ * distribution when not linked into another program.) ++ * ++ * This file is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; see the file COPYING. If not, write to ++ * the Free Software Foundation, 51 Franklin Street, Fifth Floor, ++ * Boston, MA 02110-1301, USA. ++ * ++ * As a special exception, if you link this library with files ++ * compiled with GCC to produce an executable, this does not cause ++ * the resulting executable to be covered by the GNU General Public License. ++ * This exception does not however invalidate any other reasons why ++ * the executable file might be covered by the GNU General Public License. ++ */ ++ ++/* Do any initializations needed for the eabi environment */ ++ ++ .file "crtsavres.S" ++ .section ".text" ++ ++/* On PowerPC64 Linux, these functions are provided by the linker. */ ++#ifndef __powerpc64__ ++ ++#define FUNC_START(name) \ ++ .type name,@function; \ ++ .globl name; \ ++name: ++ ++/* Routines for saving integer registers, called by the compiler. */ ++/* Called with r11 pointing to the stack header word of the caller of the */ ++/* function, just beyond the end of the integer save area. */ ++ ++FUNC_START(_savegpr_14) stw 14,-72(11) /* save gp registers */ ++FUNC_START(_savegpr_15) stw 15,-68(11) ++FUNC_START(_savegpr_16) stw 16,-64(11) ++FUNC_START(_savegpr_17) stw 17,-60(11) ++FUNC_START(_savegpr_18) stw 18,-56(11) ++FUNC_START(_savegpr_19) stw 19,-52(11) ++FUNC_START(_savegpr_20) stw 20,-48(11) ++FUNC_START(_savegpr_21) stw 21,-44(11) ++FUNC_START(_savegpr_22) stw 22,-40(11) ++FUNC_START(_savegpr_23) stw 23,-36(11) ++FUNC_START(_savegpr_24) stw 24,-32(11) ++FUNC_START(_savegpr_25) stw 25,-28(11) ++FUNC_START(_savegpr_26) stw 26,-24(11) ++FUNC_START(_savegpr_27) stw 27,-20(11) ++FUNC_START(_savegpr_28) stw 28,-16(11) ++FUNC_START(_savegpr_29) stw 29,-12(11) ++FUNC_START(_savegpr_30) stw 30,-8(11) ++FUNC_START(_savegpr_31) stw 31,-4(11) ++ blr ++ ++/* Routines for restoring integer registers, called by the compiler. */ ++/* Called with r11 pointing to the stack header word of the caller of the */ ++/* function, just beyond the end of the integer restore area. */ ++ ++FUNC_START(_restgpr_14) lwz 14,-72(11) /* restore gp registers */ ++FUNC_START(_restgpr_15) lwz 15,-68(11) ++FUNC_START(_restgpr_16) lwz 16,-64(11) ++FUNC_START(_restgpr_17) lwz 17,-60(11) ++FUNC_START(_restgpr_18) lwz 18,-56(11) ++FUNC_START(_restgpr_19) lwz 19,-52(11) ++FUNC_START(_restgpr_20) lwz 20,-48(11) ++FUNC_START(_restgpr_21) lwz 21,-44(11) ++FUNC_START(_restgpr_22) lwz 22,-40(11) ++FUNC_START(_restgpr_23) lwz 23,-36(11) ++FUNC_START(_restgpr_24) lwz 24,-32(11) ++FUNC_START(_restgpr_25) lwz 25,-28(11) ++FUNC_START(_restgpr_26) lwz 26,-24(11) ++FUNC_START(_restgpr_27) lwz 27,-20(11) ++FUNC_START(_restgpr_28) lwz 28,-16(11) ++FUNC_START(_restgpr_29) lwz 29,-12(11) ++FUNC_START(_restgpr_30) lwz 30,-8(11) ++FUNC_START(_restgpr_31) lwz 31,-4(11) ++ blr ++ ++/* Routines for restoring integer registers, called by the compiler. */ ++/* Called with r11 pointing to the stack header word of the caller of the */ ++/* function, just beyond the end of the integer restore area. */ ++ ++FUNC_START(_restgpr_14_x) lwz 14,-72(11) /* restore gp registers */ ++FUNC_START(_restgpr_15_x) lwz 15,-68(11) ++FUNC_START(_restgpr_16_x) lwz 16,-64(11) ++FUNC_START(_restgpr_17_x) lwz 17,-60(11) ++FUNC_START(_restgpr_18_x) lwz 18,-56(11) ++FUNC_START(_restgpr_19_x) lwz 19,-52(11) ++FUNC_START(_restgpr_20_x) lwz 20,-48(11) ++FUNC_START(_restgpr_21_x) lwz 21,-44(11) ++FUNC_START(_restgpr_22_x) lwz 22,-40(11) ++FUNC_START(_restgpr_23_x) lwz 23,-36(11) ++FUNC_START(_restgpr_24_x) lwz 24,-32(11) ++FUNC_START(_restgpr_25_x) lwz 25,-28(11) ++FUNC_START(_restgpr_26_x) lwz 26,-24(11) ++FUNC_START(_restgpr_27_x) lwz 27,-20(11) ++FUNC_START(_restgpr_28_x) lwz 28,-16(11) ++FUNC_START(_restgpr_29_x) lwz 29,-12(11) ++FUNC_START(_restgpr_30_x) lwz 30,-8(11) ++FUNC_START(_restgpr_31_x) lwz 0,4(11) ++ lwz 31,-4(11) ++ mtlr 0 ++ mr 1,11 ++ blr ++#endif +Index: grub-2.02~beta2/grub-core/Makefile.core.def +=================================================================== +--- grub-2.02~beta2.orig/grub-core/Makefile.core.def ++++ grub-2.02~beta2/grub-core/Makefile.core.def +@@ -250,6 +250,8 @@ kernel = { + extra_dist = video/sis315_init.c; + mips_loongson = commands/keylayouts.c; + ++ powerpc_ieee1275 = kern/powerpc/crtsavres.S; ++ powerpc_ieee1275 = disk/ieee1275/libgcc.c; + powerpc_ieee1275 = kern/powerpc/cache.S; + powerpc_ieee1275 = kern/powerpc/dl.c; + +Index: grub-2.02~beta2/grub-core/disk/ieee1275/libgcc.c +=================================================================== +--- /dev/null ++++ grub-2.02~beta2/grub-core/disk/ieee1275/libgcc.c +@@ -0,0 +1,106 @@ ++ ++typedef int int32 __attribute__ ((mode (SI))); ++typedef unsigned int uint32 __attribute__ ((mode (SI))); ++typedef int int64 __attribute__ ((mode (DI))); ++typedef unsigned uint64 __attribute__ ((mode (DI))); ++ ++typedef union { ++ int64 ll; ++ struct { ++ int32 low, high; ++ } u; ++} DWunion; ++extern int64 __ashldi3 (int64, int32); ++int64 __ashldi3(int64 x, int32 count) ++{ ++ if (!count) ++ return x; ++ ++ const DWunion uu = {.ll = x}; ++ const int32 bm = 4 * sizeof (int64) - count; /* 8 * size (int64) / 2 */ ++ DWunion w; ++ ++ if (bm <= 0) ++ { ++ w.u.low = 0; ++ w.u.high = (uint32) uu.u.low << -bm; ++ } ++ else ++ { ++ const uint32 carries = (uint32) uu.u.low >> bm; ++ ++ w.u.low = (uint32) uu.u.low << count; ++ w.u.high = ((uint32) uu.u.high << count) | carries; ++ } ++ ++ return w.ll; ++} ++extern int64 __lshrdi3 (int64 , int32); ++int64 __lshrdi3(int64 x, int32 count) ++{ ++ if (!count) ++ return x; ++ ++ const DWunion uu = {.ll = x}; ++ const int32 bm = 4 * sizeof (int64) - count; ++ DWunion w; ++ ++ if (bm <= 0) ++ { ++ w.u.high = 0; ++ w.u.low = (uint32) uu.u.high >> -bm; ++ } ++ else ++ { ++ const uint32 carries = (uint32) uu.u.high << bm; ++ ++ w.u.high = (uint32) uu.u.high >> count; ++ w.u.low = ((uint32) uu.u.low >> count) | carries; ++ } ++ ++ return w.ll; ++} ++ ++extern int64 __ashrdi3 (int64, int32); ++int64 __ashrdi3(int64 x, int32 count) ++{ ++ if (!count) ++ return x; ++ ++ const DWunion uu = {.ll = x}; ++ const int32 bm = 4 * sizeof (int64) - count; /* 8 * size (int64) / 2 */ ++ DWunion w; ++ ++ if (bm <= 0) ++ { ++ w.u.high = ++ uu.u.high >> 31; ++ w.u.low = uu.u.high >> -bm; ++ } ++ else ++ { ++ const uint32 carries = (uint32) uu.u.high << bm; ++ ++ w.u.high = (uint32) uu.u.high >> count; ++ w.u.low = ((uint32) uu.u.low >> count) | carries; ++ } ++ ++ return w.ll; ++} ++extern int64 __ucmpdi2 (int64, int64); ++int64 __ucmpdi2(int64 a, int64 b) ++{ ++ const DWunion au = {.ll = a}; ++ const DWunion bu = {.ll = b}; ++ ++ if ((unsigned int) au.u.high < (unsigned int) bu.u.high) ++ return 0; ++ else if ((unsigned int) au.u.high > (unsigned int) bu.u.high) ++ return 2; ++ if ((unsigned int) au.u.low < (unsigned int) bu.u.low) ++ return 0; ++ else if ((unsigned int) au.u.low > (unsigned int) bu.u.low) ++ return 2; ++ return 1; ++} ++ +Index: grub-2.02~beta2/include/grub/libgcc.h +=================================================================== +--- grub-2.02~beta2.orig/include/grub/libgcc.h ++++ grub-2.02~beta2/include/grub/libgcc.h +@@ -24,16 +24,16 @@ + + /* On x86 these functions aren't really needed. Save some space. */ + #if !defined (__i386__) && !defined (__x86_64__) +-# ifdef HAVE___ASHLDI3 ++# if defined (HAVE___ASHLDI3) || defined (__powerpc__) + void EXPORT_FUNC (__ashldi3) (void); + # endif +-# ifdef HAVE___ASHRDI3 ++# if defined (HAVE___ASHRDI3) || defined (__powerpc__) + void EXPORT_FUNC (__ashrdi3) (void); + # endif +-# ifdef HAVE___LSHRDI3 ++# if defined (HAVE___LSHRDI3) || defined (__powerpc__) + void EXPORT_FUNC (__lshrdi3) (void); + # endif +-# ifdef HAVE___UCMPDI2 ++# if defined (HAVE___UCMPDI2) || defined (__powerpc__) + void EXPORT_FUNC (__ucmpdi2) (void); + # endif + # ifdef HAVE___BSWAPSI2 +@@ -50,7 +50,7 @@ void EXPORT_FUNC (__ctzsi2) (void); + # endif + #endif + +-#ifdef HAVE__RESTGPR_14_X ++#if defined (HAVE__RESTGPR_14_X) || defined (__powerpc__) + void EXPORT_FUNC (_restgpr_14_x) (void); + void EXPORT_FUNC (_restgpr_15_x) (void); + void EXPORT_FUNC (_restgpr_16_x) (void); diff --git a/grub2-ppc64-build-ppc64-32bit.patch b/grub2-ppc64-build-ppc64-32bit.patch deleted file mode 100644 index 2419284..0000000 --- a/grub2-ppc64-build-ppc64-32bit.patch +++ /dev/null @@ -1,39 +0,0 @@ -Index: grub-2.02~beta2/util/mkimage.c -=================================================================== ---- grub-2.02~beta2.orig/util/mkimage.c -+++ grub-2.02~beta2/util/mkimage.c -@@ -354,13 +354,10 @@ static const struct grub_install_image_t - { - .dirname = "powerpc-ieee1275", - .names = { "powerpc-ieee1275", NULL }, -- --#ifdef __powerpc64__ -+#ifdef __powerpc64le__ - .voidp_sizeof = 8, -- .elf_target = EM_PPC64, - #else - .voidp_sizeof = 4, -- .elf_target = EM_PPC, - #endif - - #ifdef __powerpc64le__ -@@ -368,7 +365,6 @@ static const struct grub_install_image_t - #else - .bigendian = 1, - #endif -- - .id = IMAGE_PPC, - .flags = PLATFORM_FLAGS_NONE, - .total_module_size = TARGET_NO_FIELD, -@@ -378,6 +374,11 @@ static const struct grub_install_image_t - .section_align = 1, - .vaddr_offset = 0, - .link_addr = GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR, -+#ifdef __powerpc64le__ -+ .elf_target = EM_PPC64, -+#else -+ .elf_target = EM_PPC, -+#endif - .mod_gap = GRUB_KERNEL_POWERPC_IEEE1275_MOD_GAP, - .mod_align = GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN, - .link_align = 4 diff --git a/grub2-ppc64-qemu.patch b/grub2-ppc64-qemu.patch deleted file mode 100644 index 1522447..0000000 --- a/grub2-ppc64-qemu.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 90f6eed0b4ffdfe361c2966e62fcb8ed11b528bc Mon Sep 17 00:00:00 2001 -From: Nikunj A Dadhania -Date: Thu, 20 Mar 2014 16:39:29 +0530 -Subject: [PATCH] ieee1275: check for IBM pseries emulated machine - -As there is no check for IBM pSeries qemu machine, is_qemu is not -set. So feature like GRUB_IEEE1275_FLAG_HAS_CURSORONOFF is not -enabled. This results in cursor not being displayed during the -grub-menu. - -Signed-off-by: Nikunj A Dadhania ---- - grub-core/kern/ieee1275/cmain.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c -index d92ae14..3e12e6b 100644 ---- a/grub-core/kern/ieee1275/cmain.c -+++ b/grub-core/kern/ieee1275/cmain.c -@@ -84,8 +84,10 @@ grub_ieee1275_find_options (void) - - rc = grub_ieee1275_get_property (root, "model", - tmp, sizeof (tmp), 0); -- if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC")) -+ if (rc >= 0 && (!grub_strcmp (tmp, "Emulated PC") -+ || !grub_strcmp (tmp, "IBM pSeries (emulated by qemu)"))) { - is_qemu = 1; -+ } - - if (rc >= 0 && grub_strncmp (tmp, "IBM", 3) == 0) - grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS); --- -1.8.3.1 diff --git a/grub2-ppc64le-01-Add-Little-Endian-support-for-Power64-to-the-build.patch b/grub2-ppc64le-01-Add-Little-Endian-support-for-Power64-to-the-build.patch deleted file mode 100644 index 1a0c46f..0000000 --- a/grub2-ppc64le-01-Add-Little-Endian-support-for-Power64-to-the-build.patch +++ /dev/null @@ -1,52 +0,0 @@ -From aae96031c1d54796334d5e49f8fbf7144ead1883 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Mon, 24 Feb 2014 22:26:14 +0000 -Subject: [PATCH 01/23] Add Little-Endian support for Power64 to the build - -Signed-off-by: Ram Pai -Signed-off-by: Tomohiro B Berry -Signed-off-by: Thomas Falcon ---- - config.h.in | 4 ++++ - configure.ac | 6 ++++++ - 2 files changed, 10 insertions(+) - -Index: grub-2.02~beta2/config.h.in -=================================================================== ---- grub-2.02~beta2.orig/config.h.in -+++ grub-2.02~beta2/config.h.in -@@ -6,6 +6,10 @@ - #define __powerpc__ 1 - #endif - -+#if defined(__PPC64__) && defined(__LITTLE_ENDIAN__) -+#define __powerpc64le__ 1 -+#endif -+ - #define GCRYPT_NO_DEPRECATED 1 - - /* Define to 1 to enable disk cache statistics. */ -Index: grub-2.02~beta2/configure.ac -=================================================================== ---- grub-2.02~beta2.orig/configure.ac -+++ grub-2.02~beta2/configure.ac -@@ -137,6 +137,7 @@ case "$target_cpu"-"$platform" in - x86_64-xen) ;; - x86_64-*) target_cpu=i386 ;; - powerpc64-ieee1275) target_cpu=powerpc ;; -+ powerpc64le-ieee1275) target_cpu=powerpc; do_bits=64 ;; - esac - - # Check if the platform is supported, make final adjustments. -@@ -344,6 +345,11 @@ AC_SYS_LARGEFILE - # Identify characteristics of the host architecture. - unset ac_cv_c_bigendian - -+if test -n "$do_bits" ; then -+ target_m32=0; -+ target_m64=1; -+fi -+ - if test x"$target_cpu-$platform" = xsparc64-emu ; then - CFLAGS="$CFLAGS -m64" - HOST_CFLAGS="$HOST_CFLAGS -m64" diff --git a/grub2-ppc64le-02-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch b/grub2-ppc64le-02-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch deleted file mode 100644 index 3f56513..0000000 --- a/grub2-ppc64le-02-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch +++ /dev/null @@ -1,32 +0,0 @@ -e5d79c82de59b004d65399e Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Mon, 24 Feb 2014 23:01:07 +0000 -Subject: [PATCH 02/23] Build grub as O1 until we add savegpr and restgpr - routines - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - configure.ac | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index c9d2ce6..7b9d7ed 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -73,7 +73,12 @@ grub_TRANSFORM([grub-file]) - - # Optimization flag. Allow user to override. - if test "x$TARGET_CFLAGS" = x; then -- TARGET_CFLAGS="$TARGET_CFLAGS -Os" -+ if test "x$target_cpu" = xpowerpc64le; then -+ #HACK till savegpr/addgpr is supported -+ TARGET_CFLAGS="$TARGET_CFLAGS -O1" -+ else -+ TARGET_CFLAGS="$TARGET_CFLAGS -Os" -+ fi - fi - - # Default HOST_CPPFLAGS --- -1.8.3.1 diff --git a/grub2-ppc64le-03-disable-creation-of-vsx-and-altivec-instructions.patch b/grub2-ppc64le-03-disable-creation-of-vsx-and-altivec-instructions.patch deleted file mode 100644 index d3bbddb..0000000 --- a/grub2-ppc64le-03-disable-creation-of-vsx-and-altivec-instructions.patch +++ /dev/null @@ -1,27 +0,0 @@ -From f3b10c3a7e098f22a6f3863c3b56a483e3fe96a7 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Fri, 28 Feb 2014 20:17:34 +0000 -Subject: [PATCH 03/23] disable creation of vsx and altivec instructions. - -These instructions fault on power7. - -Signed-off-by: Ram Pai ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 7b9d7ed..ded7dbc 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -75,7 +75,7 @@ grub_TRANSFORM([grub-file]) - if test "x$TARGET_CFLAGS" = x; then - if test "x$target_cpu" = xpowerpc64le; then - #HACK till savegpr/addgpr is supported -- TARGET_CFLAGS="$TARGET_CFLAGS -O1" -+ TARGET_CFLAGS="$TARGET_CFLAGS -O1 -mno-altivec -mno-vsx" - else - TARGET_CFLAGS="$TARGET_CFLAGS -Os" - fi --- -1.8.3.1 diff --git a/grub2-ppc64le-04-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch b/grub2-ppc64le-04-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch deleted file mode 100644 index ca6bab8..0000000 --- a/grub2-ppc64le-04-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch +++ /dev/null @@ -1,30 +0,0 @@ -From ccd71bef390c23fa2e513d6144d16d591279d0a2 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Mon, 24 Feb 2014 23:41:41 +0000 -Subject: [PATCH 04/23] ignore .TOC. symbol during build - - powerpc64 LE's linker knows how to handle the undefined - symbol .TOC. in grub modules. So just ignore that symbol during build. - -Signed-off-by: Ram Pai ---- - grub-core/gensyminfo.sh.in | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/grub-core/gensyminfo.sh.in b/grub-core/gensyminfo.sh.in -index 2e8716b..7754dc9 100644 ---- a/grub-core/gensyminfo.sh.in -+++ b/grub-core/gensyminfo.sh.in -@@ -34,4 +34,9 @@ else - fi - - # Print all undefined symbols used by module --@TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module | sed "s@^\([^ ]*\).*@undefined $modname \1@g" -+if test x"@GRUB_TARGET_CPU@" = xpowerpc; then -+ #ignore the special .TOC. symbol on powerpc64le -+ @TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module | grep -w -v '.TOC.' -+else -+ @TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module -+fi | sed "s@^\([^ ]*\).*@undefined $modname \1@g" --- -1.8.3.1 diff --git a/grub2-ppc64le-05-grub-install-can-now-recognize-and-install-a-LE-grub.patch b/grub2-ppc64le-05-grub-install-can-now-recognize-and-install-a-LE-grub.patch deleted file mode 100644 index 44bd0bd..0000000 --- a/grub2-ppc64le-05-grub-install-can-now-recognize-and-install-a-LE-grub.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 36ac10e085ecf53e9c76685e05a1ebe7b5221ca3 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Tue, 25 Feb 2014 00:07:43 +0000 -Subject: [PATCH 05/23] recognize and install a LE grub boot loader - -grub-install can now recognize and install a LE grub boot loader - -Signed-off-by: Ram Pai ---- - util/mkimage.c | 14 +++++++++++++- - 1 file changed, 13 insertions(+), 1 deletion(-) - -diff --git a/util/mkimage.c b/util/mkimage.c -index 26d9816..9374ccd 100644 ---- a/util/mkimage.c -+++ b/util/mkimage.c -@@ -354,8 +354,21 @@ static const struct grub_install_image_target_desc image_targets[] = - { - .dirname = "powerpc-ieee1275", - .names = { "powerpc-ieee1275", NULL }, -+ -+#ifdef __powerpc64__ -+ .voidp_sizeof = 8, -+ .elf_target = EM_PPC64, -+#else - .voidp_sizeof = 4, -+ .elf_target = EM_PPC, -+#endif -+ -+#ifdef __powerpc64le__ -+ .bigendian = 0, -+#else - .bigendian = 1, -+#endif -+ - .id = IMAGE_PPC, - .flags = PLATFORM_FLAGS_NONE, - .total_module_size = TARGET_NO_FIELD, -@@ -365,7 +378,6 @@ static const struct grub_install_image_target_desc image_targets[] = - .section_align = 1, - .vaddr_offset = 0, - .link_addr = GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR, -- .elf_target = EM_PPC, - .mod_gap = GRUB_KERNEL_POWERPC_IEEE1275_MOD_GAP, - .mod_align = GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN, - .link_align = 4 --- -1.8.3.1 diff --git a/grub2-ppc64le-06-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch b/grub2-ppc64le-06-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch deleted file mode 100644 index 3514178..0000000 --- a/grub2-ppc64le-06-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 12d83a4bded734551415df888bd80b97fdb3d4ad Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Wed, 26 Feb 2014 10:28:13 +0000 -Subject: [PATCH 06/23] set the ABI version correctly - - set the ABI version to 0x02 in the e_flag of the PPC64LE ELF image. - -Signed-off-by: Ram Pai ---- - include/grub/elf.h | 1 + - util/grub-mkimagexx.c | 4 ++++ - 2 files changed, 5 insertions(+) - -diff --git a/include/grub/elf.h b/include/grub/elf.h -index caa7963..bee7583 100644 ---- a/include/grub/elf.h -+++ b/include/grub/elf.h -@@ -1851,6 +1851,7 @@ typedef Elf32_Addr Elf32_Conflict; - - /* Values for Elf32/64_Ehdr.e_flags. */ - #define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ -+#define EF_PPC64LE_ABIV2 0x00000002 /* PowerPC 64 LE flag */ - - /* Cygnus local bits below */ - #define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ -diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c -index 0a1ac9e..b1833a1 100644 ---- a/util/grub-mkimagexx.c -+++ b/util/grub-mkimagexx.c -@@ -141,11 +141,15 @@ SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target - phdr->p_vaddr = grub_host_to_target32 (target_addr); - phdr->p_paddr = grub_host_to_target32 (target_addr); - phdr->p_align = grub_host_to_target32 (align > image_target->link_align ? align : image_target->link_align); -+ - if (image_target->id == IMAGE_LOONGSON_ELF) - ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER - | EF_MIPS_PIC | EF_MIPS_CPIC); -+ else if (image_target->id == IMAGE_PPC && image_target->bigendian == 0) -+ ehdr->e_flags = grub_host_to_target32 (EF_PPC64LE_ABIV2); - else - ehdr->e_flags = 0; -+ - if (image_target->id == IMAGE_LOONGSON_ELF) - { - phdr->p_filesz = grub_host_to_target32 (*core_size); --- -1.8.3.1 diff --git a/grub2-ppc64le-07-Add-IEEE1275_ADDR-helper.patch b/grub2-ppc64le-07-Add-IEEE1275_ADDR-helper.patch deleted file mode 100644 index a4191e4..0000000 --- a/grub2-ppc64le-07-Add-IEEE1275_ADDR-helper.patch +++ /dev/null @@ -1,236 +0,0 @@ -From c3718600e10e985fe770d13e0110f086256b984f Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:29:32 +1100 -Subject: [PATCH 07/23] Add IEEE1275_ADDR helper - -If the target pointer size doesn't match the IEEE1275 cell size, we -need to cast twice to avoid a warning. - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - grub-core/disk/ieee1275/ofdisk.c | 4 ++-- - grub-core/kern/ieee1275/ieee1275.c | 30 +++++++++++++++--------------- - grub-core/kern/ieee1275/openfw.c | 6 +++--- - grub-core/lib/ieee1275/datetime.c | 4 ++-- - grub-core/net/drivers/ieee1275/ofnet.c | 2 +- - include/grub/ieee1275/ieee1275.h | 4 +++- - 6 files changed, 26 insertions(+), 24 deletions(-) - -diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c -index 6870b39..1b72f06 100644 ---- a/grub-core/disk/ieee1275/ofdisk.c -+++ b/grub-core/disk/ieee1275/ofdisk.c -@@ -224,7 +224,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) - return; - - INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); -- args.method = (grub_ieee1275_cell_t) "vscsi-report-luns"; -+ args.method = IEEE1275_ADDR("vscsi-report-luns"); - args.ihandle = ihandle; - args.table = 0; - args.nentries = 0; -@@ -613,7 +613,7 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); - - INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2); -- args_ieee1275.method = (grub_ieee1275_cell_t) "block-size"; -+ args_ieee1275.method = IEEE1275_ADDR("block-size"); - args_ieee1275.ihandle = last_ihandle; - args_ieee1275.result = 1; - -diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c -index 9821702..f933c89 100644 ---- a/grub-core/kern/ieee1275/ieee1275.c -+++ b/grub-core/kern/ieee1275/ieee1275.c -@@ -38,7 +38,7 @@ grub_ieee1275_finddevice (const char *name, grub_ieee1275_phandle_t *phandlep) - args; - - INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); -- args.device = (grub_ieee1275_cell_t) name; -+ args.device = IEEE1275_ADDR(name); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -@@ -66,8 +66,8 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, - - INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); - args.phandle = phandle; -- args.prop = (grub_ieee1275_cell_t) property; -- args.buf = (grub_ieee1275_cell_t) buf; -+ args.prop = IEEE1275_ADDR(property); -+ args.buf = IEEE1275_ADDR(buf); - args.buflen = (grub_ieee1275_cell_t) size; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -@@ -115,8 +115,8 @@ grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, - - INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); - args.phandle = phandle; -- args.prev_prop = (grub_ieee1275_cell_t) prev_prop; -- args.next_prop = (grub_ieee1275_cell_t) prop; -+ args.prev_prop = IEEE1275_ADDR(prev_prop); -+ args.next_prop = IEEE1275_ADDR(prop); - args.flags = (grub_ieee1275_cell_t) -1; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -@@ -139,7 +139,7 @@ grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, - - INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); - args.phandle = phandle; -- args.prop = (grub_ieee1275_cell_t) prop; -+ args.prop = IEEE1275_ADDR(prop); - args.length = (grub_ieee1275_cell_t) -1; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -@@ -190,7 +190,7 @@ grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, - - INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); - args.phandle = phandle; -- args.buf = (grub_ieee1275_cell_t) path; -+ args.buf = IEEE1275_ADDR(path); - args.buflen = (grub_ieee1275_cell_t) len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -@@ -219,7 +219,7 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle, - - INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); - args.ihandle = ihandle; -- args.buf = (grub_ieee1275_cell_t) path; -+ args.buf = IEEE1275_ADDR(path); - args.buflen = (grub_ieee1275_cell_t) len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -@@ -247,7 +247,7 @@ grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer, - - INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); - args.ihandle = ihandle; -- args.buf = (grub_ieee1275_cell_t) buffer; -+ args.buf = IEEE1275_ADDR(buffer); - args.len = (grub_ieee1275_cell_t) len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -@@ -273,7 +273,7 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, - - INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); - args.ihandle = ihandle; -- args.buf = (grub_ieee1275_cell_t) buffer; -+ args.buf = IEEE1275_ADDR(buffer); - args.len = (grub_ieee1275_cell_t) len; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -@@ -401,7 +401,7 @@ grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch) - return -1; - - INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1); -- args.command = (grub_ieee1275_cell_t) command; -+ args.command = IEEE1275_ADDR(command); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -@@ -453,7 +453,7 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) - args; - - INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); -- args.path = (grub_ieee1275_cell_t) path; -+ args.path = IEEE1275_ADDR(path); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -@@ -548,8 +548,8 @@ grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle, - - INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); - args.size = (grub_ieee1275_cell_t) size; -- args.buf = (grub_ieee1275_cell_t) buf; -- args.propname = (grub_ieee1275_cell_t) propname; -+ args.buf = IEEE1275_ADDR(buf); -+ args.propname = IEEE1275_ADDR(propname); - args.phandle = (grub_ieee1275_cell_t) phandle; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -@@ -578,7 +578,7 @@ grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle, - args; - - INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); -- args.method = (grub_ieee1275_cell_t) "color!"; -+ args.method = IEEE1275_ADDR("color!"); - args.ihandle = ihandle; - args.index = index; - args.r = r; -diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c -index ddb7783..a8bbc71 100644 ---- a/grub-core/kern/ieee1275/openfw.c -+++ b/grub-core/kern/ieee1275/openfw.c -@@ -285,7 +285,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size, - 6, - #endif - 1); -- args.method = (grub_ieee1275_cell_t) "map"; -+ args.method = IEEE1275_ADDR("map"); - args.ihandle = grub_ieee1275_mmu; - #ifdef __sparc__ - args.phys_high = 0; -@@ -543,8 +543,8 @@ grub_ieee1275_canonicalise_devname (const char *path) - return NULL; - - INIT_IEEE1275_COMMON (&args.common, "canon", 3, 1); -- args.path = (grub_ieee1275_cell_t) path; -- args.buf = (grub_ieee1275_cell_t) buf; -+ args.path = IEEE1275_ADDR(path); -+ args.buf = IEEE1275_ADDR(buf); - args.inlen = (grub_ieee1275_cell_t) (bufsize - 1); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c -index 74578f1..fa0d3b6 100644 ---- a/grub-core/lib/ieee1275/datetime.c -+++ b/grub-core/lib/ieee1275/datetime.c -@@ -84,7 +84,7 @@ grub_get_datetime (struct grub_datetime *datetime) - - INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 7); - args.device = (grub_ieee1275_cell_t) ihandle; -- args.method = (grub_ieee1275_cell_t) "get-time"; -+ args.method = IEEE1275_ADDR("get-time"); - - status = IEEE1275_CALL_ENTRY_FN (&args); - -@@ -136,7 +136,7 @@ grub_set_datetime (struct grub_datetime *datetime) - - INIT_IEEE1275_COMMON (&args.common, "call-method", 8, 1); - args.device = (grub_ieee1275_cell_t) ihandle; -- args.method = (grub_ieee1275_cell_t) "set-time"; -+ args.method = IEEE1275_ADDR("set-time"); - - args.year = datetime->year; - args.month = datetime->month; -diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index eea8e71..ea6456f 100644 ---- a/grub-core/net/drivers/ieee1275/ofnet.c -+++ b/grub-core/net/drivers/ieee1275/ofnet.c -@@ -386,7 +386,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) - args; - INIT_IEEE1275_COMMON (&args.common, "interpret", 2, 2); - args.len = card->txbufsize; -- args.method = (grub_ieee1275_cell_t) "alloc-mem"; -+ args.method = IEEE1275_ADDR("alloc-mem"); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1 - || args.catch) -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 8e42513..2e5270c 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -49,8 +49,10 @@ struct grub_ieee1275_common_hdr - grub_ieee1275_cell_t nr_outs; - }; - -+#define IEEE1275_ADDR(x) (grub_uint32_t)(grub_addr_t)(x) -+ - #define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \ -- (p)->name = (grub_ieee1275_cell_t) xname; \ -+ (p)->name = (grub_ieee1275_cell_t) IEEE1275_ADDR(xname); \ - (p)->nr_ins = (grub_ieee1275_cell_t) xins; \ - (p)->nr_outs = (grub_ieee1275_cell_t) xouts - --- -1.8.3.1 diff --git a/grub2-ppc64le-08-Fix-some-more-warnings-when-casting.patch b/grub2-ppc64le-08-Fix-some-more-warnings-when-casting.patch deleted file mode 100644 index e019a3d..0000000 --- a/grub2-ppc64le-08-Fix-some-more-warnings-when-casting.patch +++ /dev/null @@ -1,67 +0,0 @@ -From ab7a0d7323fd2f6eb4f55da50386378d6a7a7af0 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:36:41 +1100 -Subject: [PATCH 08/23] Fix some more warnings when casting. - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - grub-core/disk/ieee1275/ofdisk.c | 2 +- - grub-core/lib/powerpc/relocator.c | 8 ++++---- - grub-core/net/drivers/ieee1275/ofnet.c | 2 +- - 3 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c -index 1b72f06..d785d6a 100644 ---- a/grub-core/disk/ieee1275/ofdisk.c -+++ b/grub-core/disk/ieee1275/ofdisk.c -@@ -244,7 +244,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) - { - grub_uint64_t *ptr; - -- ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i); -+ ptr = *(grub_uint64_t **) ((grub_addr_t)args.table + 4 + 8 * i); - while (*ptr) - { - grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++); -diff --git a/grub-core/lib/powerpc/relocator.c b/grub-core/lib/powerpc/relocator.c -index bdf2b11..4bac96f 100644 ---- a/grub-core/lib/powerpc/relocator.c -+++ b/grub-core/lib/powerpc/relocator.c -@@ -84,8 +84,8 @@ grub_cpu_relocator_backward (void *ptr0, void *src, void *dest, - grub_size_t size) - { - void *ptr = ptr0; -- write_reg (8, (grub_uint32_t) src, &ptr); -- write_reg (9, (grub_uint32_t) dest, &ptr); -+ write_reg (8, (grub_uint32_t) (grub_addr_t) src, &ptr); -+ write_reg (9, (grub_uint32_t) (grub_addr_t) dest, &ptr); - write_reg (10, (grub_uint32_t) size, &ptr); - grub_memcpy (ptr, &grub_relocator_backward_start, - RELOCATOR_SRC_SIZEOF (backward)); -@@ -96,8 +96,8 @@ grub_cpu_relocator_forward (void *ptr0, void *src, void *dest, - grub_size_t size) - { - void *ptr = ptr0; -- write_reg (8, (grub_uint32_t) src, &ptr); -- write_reg (9, (grub_uint32_t) dest, &ptr); -+ write_reg (8, (grub_uint32_t) (grub_addr_t) src, &ptr); -+ write_reg (9, (grub_uint32_t) (grub_addr_t) dest, &ptr); - write_reg (10, (grub_uint32_t) size, &ptr); - grub_memcpy (ptr, &grub_relocator_forward_start, - RELOCATOR_SRC_SIZEOF (forward)); -diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index ea6456f..07c8446 100644 ---- a/grub-core/net/drivers/ieee1275/ofnet.c -+++ b/grub-core/net/drivers/ieee1275/ofnet.c -@@ -395,7 +395,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); - } - else -- card->txbuf = (void *) args.result; -+ card->txbuf = (void *) (grub_addr_t) args.result; - } - else - card->txbuf = grub_zalloc (card->txbufsize); --- -1.8.3.1 diff --git a/grub2-ppc64le-09-Add-powerpc64-types.patch b/grub2-ppc64le-09-Add-powerpc64-types.patch deleted file mode 100644 index 32dd3cd..0000000 --- a/grub2-ppc64le-09-Add-powerpc64-types.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 71a44537c3293d14184901a39f87e2b9d748c8ce Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:37:54 +1100 -Subject: [PATCH 09/23] Add powerpc64 types - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - include/grub/powerpc/types.h | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h -index a098ae6..7a2fc6b 100644 ---- a/include/grub/powerpc/types.h -+++ b/include/grub/powerpc/types.h -@@ -19,11 +19,19 @@ - #ifndef GRUB_TYPES_CPU_HEADER - #define GRUB_TYPES_CPU_HEADER 1 - -+#ifdef __powerpc64le__ -+/* The size of void *. */ -+#define GRUB_TARGET_SIZEOF_VOID_P 8 -+ -+/* The size of long. */ -+#define GRUB_TARGET_SIZEOF_LONG 8 -+#else - /* The size of void *. */ - #define GRUB_TARGET_SIZEOF_VOID_P 4 - - /* The size of long. */ - #define GRUB_TARGET_SIZEOF_LONG 4 -+#endif - - /* powerpc is big-endian. */ - #define GRUB_TARGET_WORDS_BIGENDIAN 1 --- -1.8.3.1 diff --git a/grub2-ppc64le-10-powerpc64-is-not-necessarily-BigEndian-anymore.patch b/grub2-ppc64le-10-powerpc64-is-not-necessarily-BigEndian-anymore.patch deleted file mode 100644 index d5d994e..0000000 --- a/grub2-ppc64le-10-powerpc64-is-not-necessarily-BigEndian-anymore.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 258ae455c8fdcee9884fa9e4cf432a4d22694ce2 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:37:54 +1100 -Subject: [PATCH 10/23] powerpc64 is not necessarily BigEndian - - powerpc64 is not necessarily BigEndian anymore! :) - -Signed-off-by: Ram Pai ---- - include/grub/powerpc/types.h | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h -index 7a2fc6b..ab138d4 100644 ---- a/include/grub/powerpc/types.h -+++ b/include/grub/powerpc/types.h -@@ -19,7 +19,7 @@ - #ifndef GRUB_TYPES_CPU_HEADER - #define GRUB_TYPES_CPU_HEADER 1 - --#ifdef __powerpc64le__ -+#ifdef __powerpc64__ - /* The size of void *. */ - #define GRUB_TARGET_SIZEOF_VOID_P 8 - -@@ -33,8 +33,12 @@ - #define GRUB_TARGET_SIZEOF_LONG 4 - #endif - --/* powerpc is big-endian. */ --#define GRUB_TARGET_WORDS_BIGENDIAN 1 -+#ifdef __powerpc64le__ -+#undef GRUB_TARGET_WORDS_BIGENDIAN -+#else -+#define GRUB_TARGET_WORDS_BIGENDIAN 1 -+#endif -+ - - - #endif /* ! GRUB_TYPES_CPU_HEADER */ --- -1.8.3.1 diff --git a/grub2-ppc64le-11-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch b/grub2-ppc64le-11-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch deleted file mode 100644 index 7ebfbda..0000000 --- a/grub2-ppc64le-11-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 65dc046ba1f73ae2454ed6495145d645ad452596 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:38:28 +1100 -Subject: [PATCH 11/23] Fix warnings when building powerpc linux loader 64bit - -Fix warnings when building powerpc linux loader 64bit - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - grub-core/loader/powerpc/ieee1275/linux.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c -index 4a14f66..9dde053 100644 ---- a/grub-core/loader/powerpc/ieee1275/linux.c -+++ b/grub-core/loader/powerpc/ieee1275/linux.c -@@ -141,9 +141,9 @@ grub_linux_boot (void) - grub_ieee1275_set_property (grub_ieee1275_chosen, "bootargs", linux_args, - grub_strlen (linux_args) + 1, &actual); - -- grub_dprintf ("loader", "Entry point: 0x%x\n", linux_entry); -- grub_dprintf ("loader", "Initrd at: 0x%x, size 0x%x\n", initrd_addr, -- initrd_size); -+ grub_dprintf ("loader", "Entry point: 0x%lx\n", (unsigned long)linux_entry); -+ grub_dprintf ("loader", "Initrd at: 0x%lx, size 0x%lx\n", -+ (unsigned long)initrd_addr, (unsigned long)initrd_size); - grub_dprintf ("loader", "Boot arguments: %s\n", linux_args); - grub_dprintf ("loader", "Jumping to Linux...\n"); - -@@ -360,7 +360,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - if (addr == (grub_addr_t) -1) - goto fail; - -- grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size); -+ grub_dprintf ("loader", "Loading initrd at 0x%lx, size 0x%lx\n", -+ (unsigned long)addr, (unsigned long)size); - - if (grub_initrd_load (&initrd_ctx, argv, (void *) addr)) - goto fail; --- -1.8.3.1 diff --git a/grub2-ppc64le-12-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch b/grub2-ppc64le-12-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch deleted file mode 100644 index e4483f4..0000000 --- a/grub2-ppc64le-12-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch +++ /dev/null @@ -1,45 +0,0 @@ -From b94389e81084af714c6e6ad71d50e64174018c39 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Tue, 25 Feb 2014 01:35:51 +0000 -Subject: [PATCH 12/23] GRUB_ELF_R_PPC_* processing fix - -GRUB_ELF_R_PPC_* processing is applicable only for 32 - bit bootloader. - -Signed-off-by: Ram Pai ---- - grub-core/kern/powerpc/dl.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/powerpc/dl.c b/grub-core/kern/powerpc/dl.c -index 3a7fa3e..7677e5a 100644 ---- a/grub-core/kern/powerpc/dl.c -+++ b/grub-core/kern/powerpc/dl.c -@@ -94,6 +94,7 @@ grub_err_t - grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - Elf_Shdr *s, grub_dl_segment_t seg) - { -+#ifdef powerpc - Elf_Rela *rel, *max; - - for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset), -@@ -155,7 +156,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - case GRUB_ELF_R_PPC_REL32: - *addr = value - (Elf_Word) addr; - break; -- - default: - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - N_("relocation 0x%x is not implemented yet"), -@@ -164,4 +164,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - } - - return GRUB_ERR_NONE; -+#else -+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ N_("relocation is not implemented yet for module=%llx ehdr=%llx Elf_Shdr=%llx seg=%llx"), -+ mod, ehdr, s, seg); -+#endif - } --- -1.8.3.1 diff --git a/grub2-ppc64le-13-Fix-powerpc-setjmp-longjmp-64bit-issues.patch b/grub2-ppc64le-13-Fix-powerpc-setjmp-longjmp-64bit-issues.patch deleted file mode 100644 index 88005f2..0000000 --- a/grub2-ppc64le-13-Fix-powerpc-setjmp-longjmp-64bit-issues.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 653e20ad39923aace0117fb7b51df27784587652 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:39:32 +1100 -Subject: [PATCH 13/23] Fix powerpc setjmp/longjmp 64bit issues - -Fix powerpc setjmp/longjmp 64bit issues - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - grub-core/lib/powerpc/setjmp.S | 94 +++++++++++++++++++++++------------------- - 1 file changed, 52 insertions(+), 42 deletions(-) - -diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S -index 716b563..51fcae9 100644 ---- a/grub-core/lib/powerpc/setjmp.S -+++ b/grub-core/lib/powerpc/setjmp.S -@@ -25,33 +25,43 @@ GRUB_MOD_LICENSE "GPLv3+" - - .text - -+#if defined( __powerpc64__ ) || defined( __powerpc64le__ ) -+#define LOAD ld -+#define STORE std -+#define SZ_LONG 8 -+#else -+#define LOAD lwz -+#define STORE stw -+#define SZ_LONG 4 -+#endif -+ - /* - * int grub_setjmp (grub_jmp_buf env) - */ - FUNCTION(grub_setjmp) -- stw 1, 0(3) -- stw 14, 4(3) -- stw 15, 8(3) -- stw 16, 12(3) -- stw 17, 16(3) -- stw 18, 20(3) -- stw 19, 24(3) -- stw 20, 28(3) -- stw 21, 32(3) -- stw 22, 36(3) -- stw 23, 40(3) -- stw 24, 44(3) -- stw 25, 48(3) -- stw 26, 52(3) -- stw 27, 56(3) -- stw 28, 60(3) -- stw 29, 64(3) -- stw 30, 68(3) -- stw 31, 72(3) -+ STORE 1, 0(3) -+ STORE 14, 1*SZ_LONG(3) -+ STORE 15, 2*SZ_LONG(3) -+ STORE 16, 3*SZ_LONG(3) -+ STORE 17, 4*SZ_LONG(3) -+ STORE 18, 5*SZ_LONG(3) -+ STORE 19, 6*SZ_LONG(3) -+ STORE 20, 7*SZ_LONG(3) -+ STORE 21, 8*SZ_LONG(3) -+ STORE 22, 9*SZ_LONG(3) -+ STORE 23, 10*SZ_LONG(3) -+ STORE 24, 11*SZ_LONG(3) -+ STORE 25, 12*SZ_LONG(3) -+ STORE 26, 13*SZ_LONG(3) -+ STORE 27, 14*SZ_LONG(3) -+ STORE 28, 15*SZ_LONG(3) -+ STORE 29, 16*SZ_LONG(3) -+ STORE 30, 17*SZ_LONG(3) -+ STORE 31, 18*SZ_LONG(3) - mflr 4 -- stw 4, 76(3) -+ STORE 4, 19*SZ_LONG(3) - mfcr 4 -- stw 4, 80(3) -+ STORE 4, 20*SZ_LONG(3) - li 3, 0 - blr - -@@ -59,28 +69,28 @@ FUNCTION(grub_setjmp) - * int grub_longjmp (grub_jmp_buf env, int val) - */ - FUNCTION(grub_longjmp) -- lwz 1, 0(3) -- lwz 14, 4(3) -- lwz 15, 8(3) -- lwz 16, 12(3) -- lwz 17, 16(3) -- lwz 18, 20(3) -- lwz 19, 24(3) -- lwz 20, 28(3) -- lwz 21, 32(3) -- lwz 22, 36(3) -- lwz 23, 40(3) -- lwz 24, 44(3) -- lwz 25, 48(3) -- lwz 26, 52(3) -- lwz 27, 56(3) -- lwz 28, 60(3) -- lwz 29, 64(3) -- lwz 30, 68(3) -- lwz 31, 72(3) -- lwz 5, 76(3) -+ LOAD 1, 0(3) -+ LOAD 14, 1*SZ_LONG(3) -+ LOAD 15, 2*SZ_LONG(3) -+ LOAD 16, 3*SZ_LONG(3) -+ LOAD 17, 4*SZ_LONG(3) -+ LOAD 18, 5*SZ_LONG(3) -+ LOAD 19, 6*SZ_LONG(3) -+ LOAD 20, 7*SZ_LONG(3) -+ LOAD 21, 8*SZ_LONG(3) -+ LOAD 22, 9*SZ_LONG(3) -+ LOAD 23, 10*SZ_LONG(3) -+ LOAD 24, 11*SZ_LONG(3) -+ LOAD 25, 12*SZ_LONG(3) -+ LOAD 26, 13*SZ_LONG(3) -+ LOAD 27, 14*SZ_LONG(3) -+ LOAD 28, 15*SZ_LONG(3) -+ LOAD 29, 16*SZ_LONG(3) -+ LOAD 30, 17*SZ_LONG(3) -+ LOAD 31, 18*SZ_LONG(3) -+ LOAD 5, 19*SZ_LONG(3) - mtlr 5 -- lwz 5, 80(3) -+ LOAD 5, 20*SZ_LONG(3) - mtcr 5 - mr. 3, 4 - bne 1f --- -1.8.3.1 diff --git a/grub2-ppc64le-14-Add-powerpc64-ieee1275-trampoline.patch b/grub2-ppc64le-14-Add-powerpc64-ieee1275-trampoline.patch deleted file mode 100644 index d903997..0000000 --- a/grub2-ppc64le-14-Add-powerpc64-ieee1275-trampoline.patch +++ /dev/null @@ -1,201 +0,0 @@ -From dc0b31e8fe09b4143488e85a7aeb7c532e48f81d Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:40:17 +1100 -Subject: [PATCH 14/23] Add powerpc64 ieee1275 trampoline - -Add a trampoline so a 64bit grub can call a 32 bit OF - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - grub-core/Makefile.core.def | 1 + - grub-core/kern/powerpc/ieee1275/entry.S | 150 +++++++++++++++++++++++++++++++ - include/grub/powerpc/ieee1275/ieee1275.h | 6 ++ - 3 files changed, 157 insertions(+) - create mode 100644 grub-core/kern/powerpc/ieee1275/entry.S - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 42443bc..9563eeb 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -252,6 +252,7 @@ kernel = { - - powerpc_ieee1275 = kern/powerpc/cache.S; - powerpc_ieee1275 = kern/powerpc/dl.c; -+ powerpc_ieee1275 = kern/powerpc/ieee1275/entry.S; - - sparc64_ieee1275 = kern/sparc64/cache.S; - sparc64_ieee1275 = kern/sparc64/dl.c; -diff --git a/grub-core/kern/powerpc/ieee1275/entry.S b/grub-core/kern/powerpc/ieee1275/entry.S -new file mode 100644 -index 0000000..5d58149 ---- /dev/null -+++ b/grub-core/kern/powerpc/ieee1275/entry.S -@@ -0,0 +1,150 @@ -+/* entry.S - open firmware call entry and return */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2004,2007,2010,2014 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+ -+#define STACK_FRAME_SIZE (48 + 64 + 16 + 144) -+#define MSR_OFFSET (48 + 64) -+#define R13_OFFSET (MSR_OFFSET + 8) -+#define NVREG_OFFSET(i) (STACK_FRAME_SIZE - (32-(i))*8) -+#define SAVE_NVGPR(A) std (A),NVREG_OFFSET(A)(r1) -+#define REST_NVGPR(A) ld (A),NVREG_OFFSET(A)(r1) -+#define SPRN_SRR0 0x01A -+#define SPRN_SRR1 0x01B -+#define r1 sp -+ -+ -+#if defined(_CALL_ELF) && _CALL_ELF == 1 /* BIG ENDIAN */ -+#define TOC_OFFSET 40 -+#define r2 toc -+#endif -+ -+/* -+ * OF runs in 32 bit mode so it clobbers the high 32 bits of all registers -+ * it saves. We save and restore all the non volatile registers to avoid -+ * this issue. -+ * -+ * unsigned int ieee1275_call_entry_fn(void *args, unsigned long entry); -+ */ -+FUNC_START(ieee1275_call_entry_fn) -+ mflr r0 -+ std r0,16(r1) -+ stdu r1,-STACK_FRAME_SIZE(r1) -+ -+#if defined(_CALL_ELF) && _CALL_ELF == 1 /* BIG ENDIAN */ -+ std r2,TOC_OFFSET(r1) -+#endif -+ std r13,R13_OFFSET(r1) -+ -+ SAVE_NVGPR(r14) -+ SAVE_NVGPR(r15) -+ SAVE_NVGPR(r16) -+ SAVE_NVGPR(r17) -+ SAVE_NVGPR(r18) -+ SAVE_NVGPR(r19) -+ SAVE_NVGPR(r20) -+ SAVE_NVGPR(r21) -+ SAVE_NVGPR(r22) -+ SAVE_NVGPR(r23) -+ SAVE_NVGPR(r24) -+ SAVE_NVGPR(r25) -+ SAVE_NVGPR(r26) -+ SAVE_NVGPR(r27) -+ SAVE_NVGPR(r28) -+ SAVE_NVGPR(r29) -+ SAVE_NVGPR(r30) -+ SAVE_NVGPR(r31) -+ -+ mfmsr r31 -+ std r31, MSR_OFFSET(r1) -+ -+ /* Clear 64bit mode */ -+ rldicl r31,r31,0,1 -+ -+#if defined(_CALL_ELF) && _CALL_ELF == 2 /* LITTLE ENDIAN */ -+ /* Clear LE mode */ -+ rldicr r31,r31,0,62 -+#endif -+ -+ mtspr SPRN_SRR0,r4 -+ mtspr SPRN_SRR1,r31 -+ -+ /* Point the LR at our return code */ -+ bl 1f -+1: mflr r30 -+ addi r30,r30,(2f - 1b) -+ mtlr r30 -+ -+ /* Call OF */ -+ rfid -+ -+#if defined(_CALL_ELF) && _CALL_ELF == 2 /* LITTLE ENDIAN */ -+2: .long 0x05009f42 /* bcl 20,31,$+4 */ -+ .long 0xa602487d /* mflr r10 */ -+ .long 0x1c004a39 /* addi r10,r10,28 */ -+ .long 0xa6035a7d /* mtsrr0 r10 */ -+ .long 0xa600407d /* mfmsr r10 */ -+ .long 0x01004a69 /* xori r10,r10,1 */ -+ .long 0xa6035b7d /* mtsrr1 r10 */ -+ .long 0x2400004c /* rfid */ -+#endif -+ -+ /* Clear the top 32 bits of r1, just in case */ -+2: rldicl r1,r1,0,32 -+ -+ /* Reset our MSR */ -+ ld r31,MSR_OFFSET(r1) -+ mtspr SPRN_SRR1,r31 -+ -+ bl 3f -+3: mflr r30 -+ addi r30,r30,(4f - 3b) -+ mtspr SPRN_SRR0,r30 -+ -+ rfid -+ -+#if defined(_CALL_ELF) && _CALL_ELF == 1 /* BIG ENDIAN */ -+4: ld r2,TOC_OFFSET(r1) -+#endif -+4: ld r13,R13_OFFSET(r1) -+ -+ REST_NVGPR(r14) -+ REST_NVGPR(r15) -+ REST_NVGPR(r16) -+ REST_NVGPR(r17) -+ REST_NVGPR(r18) -+ REST_NVGPR(r19) -+ REST_NVGPR(r20) -+ REST_NVGPR(r21) -+ REST_NVGPR(r22) -+ REST_NVGPR(r23) -+ REST_NVGPR(r24) -+ REST_NVGPR(r25) -+ REST_NVGPR(r26) -+ REST_NVGPR(r27) -+ REST_NVGPR(r28) -+ REST_NVGPR(r29) -+ REST_NVGPR(r30) -+ REST_NVGPR(r31) -+ -+ addi r1,r1,STACK_FRAME_SIZE -+ ld r0,16(r1) -+ mtlr r0 -+ blr -+FUNC_END(ieee1275_call_entry_fn) -diff --git a/include/grub/powerpc/ieee1275/ieee1275.h b/include/grub/powerpc/ieee1275/ieee1275.h -index 3c7683f..14bdc43 100644 ---- a/include/grub/powerpc/ieee1275/ieee1275.h -+++ b/include/grub/powerpc/ieee1275/ieee1275.h -@@ -25,4 +25,10 @@ - #define GRUB_IEEE1275_CELL_SIZEOF 4 - typedef grub_uint32_t grub_ieee1275_cell_t; - -+#ifdef __powerpc64__ -+int EXPORT_FUNC(ieee1275_call_entry_fn)(void *args, void *entry); -+#define IEEE1275_CALL_ENTRY_FN(args) \ -+ ieee1275_call_entry_fn((args), grub_ieee1275_entry_fn) -+#endif -+ - #endif /* ! GRUB_IEEE1275_MACHINE_HEADER */ --- -1.8.3.1 diff --git a/grub2-ppc64le-15-Add-64bit-support-to-powerpc-startup-code.patch b/grub2-ppc64le-15-Add-64bit-support-to-powerpc-startup-code.patch deleted file mode 100644 index 981fe08..0000000 --- a/grub2-ppc64le-15-Add-64bit-support-to-powerpc-startup-code.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 303109b36a45f53400cbcdaf2ad90ca5790ce1d6 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:41:29 +1100 -Subject: [PATCH 15/23] Add 64bit support to powerpc startup code - - Add 64bit support to powerpc startup code - -From: Anton Blanchard -Signed-off-by: Ram Pai ---- - grub-core/kern/powerpc/ieee1275/startup.S | 33 +++++++++++++++++++++++++++---- - 1 file changed, 29 insertions(+), 4 deletions(-) - -diff --git a/grub-core/kern/powerpc/ieee1275/startup.S b/grub-core/kern/powerpc/ieee1275/startup.S -index 21c884b..03f80d8 100644 ---- a/grub-core/kern/powerpc/ieee1275/startup.S -+++ b/grub-core/kern/powerpc/ieee1275/startup.S -@@ -19,15 +19,28 @@ - - #include - #include -+#include - - .extern __bss_start - .extern _end - - .text -- .align 2 -- .globl start, _start --start: --_start: -+ -+FUNC_START(_start) -+ -+#if defined(_CALL_ELF) && _CALL_ELF == 2 /* LITTLE ENDIAN */ -+ tdi 0,0,0x48 /* Reverse endian of b . + 8 */ -+ b $+36 /* Skip trampoline if already LE mode */ -+ .long 0x05009f42 /* bcl 20,31,$+4 */ -+ .long 0xa602487d /* mflr r10 */ -+ .long 0x1c004a39 /* addi r10,r10,28 */ -+ .long 0xa600607d /* mfmsr r11 */ -+ .long 0x01006b69 /* xori r11,r11,1 */ -+ .long 0xa6035a7d /* mtsrr0 r10 */ -+ .long 0xa6037b7d /* mtsrr1 r11 */ -+ .long 0x2400004c /* rfid */ -+#endif -+ - li 2, 0 - li 13, 0 - -@@ -61,7 +74,19 @@ _start: - - /* Store r5 in grub_ieee1275_entry_fn. */ - lis 9, grub_ieee1275_entry_fn@ha -+#if defined(_CALL_ELF) && _CALL_ELF == 1 /* BIG ENDIAN */ -+ std 5, grub_ieee1275_entry_fn@l(9) -+#else - stw 5, grub_ieee1275_entry_fn@l(9) -+#endif -+ -+#if defined(_CALL_ELF) && _CALL_ELF == 2 /* LITTLE ENDIAN */ -+ bl 3f -+3: mflr 9 -+ addis 2,9,.TOC.-3b@ha -+ addi 2,2,.TOC.-3b@l -+#endif - - bl grub_main - 1: b 1b -+FUNC_END(_start) --- -1.8.3.1 diff --git a/grub2-ppc64le-16-Add-grub_dl_find_section_addr.patch b/grub2-ppc64le-16-Add-grub_dl_find_section_addr.patch deleted file mode 100644 index 86fb38a..0000000 --- a/grub2-ppc64le-16-Add-grub_dl_find_section_addr.patch +++ /dev/null @@ -1,77 +0,0 @@ -From ca7d011e65c6dc1b633c85b7105c807b929598f1 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:42:12 +1100 -Subject: [PATCH 16/23] Add grub_dl_find_section_addr - -ppc64 needs to find the address of the toc section. -Create grub_dl_find_section_addr to do this. - -We also need grub_dl_find_section, so make it global. - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - grub-core/kern/dl.c | 27 ++++++++++++++++++++++++++- - include/grub/dl.h | 2 ++ - 2 files changed, 28 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 6850e04..de2d0ed 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -191,6 +191,31 @@ grub_dl_get_section_addr (grub_dl_t mod, unsigned n) - return 0; - } - -+void *grub_dl_find_section_addr (grub_dl_t mod, Elf_Ehdr *e, const char *name) -+{ -+ Elf_Shdr *s; -+ const char *str; -+ unsigned i; -+ grub_dl_segment_t seg; -+ -+ s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize); -+ str = (char *) e + s->sh_offset; -+ -+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); -+ i < e->e_shnum; -+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) -+ { -+ if (grub_strcmp (str + s->sh_name, name) == 0) -+ { -+ for (seg = mod->segment; seg; seg = seg->next) -+ if (seg->section == i) -+ return seg->addr; -+ } -+ } -+ -+ return 0; -+} -+ - /* Check if EHDR is a valid ELF header. */ - static grub_err_t - grub_dl_check_header (void *ehdr, grub_size_t size) -@@ -427,7 +452,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) - return GRUB_ERR_NONE; - } - --static Elf_Shdr * -+Elf_Shdr * - grub_dl_find_section (Elf_Ehdr *e, const char *name) - { - Elf_Shdr *s; -diff --git a/include/grub/dl.h b/include/grub/dl.h -index 9562fa6..39c73a7 100644 ---- a/include/grub/dl.h -+++ b/include/grub/dl.h -@@ -250,6 +250,8 @@ grub_err_t grub_arch_dl_check_header (void *ehdr); - grub_err_t - grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - Elf_Shdr *s, grub_dl_segment_t seg); -+Elf_Shdr * grub_dl_find_section (Elf_Ehdr *e, const char *name); -+void *grub_dl_find_section_addr (grub_dl_t mod, Elf_Ehdr *e, const char *name); - #endif - - #if defined (_mips) --- -1.8.3.1 diff --git a/grub2-ppc64le-17-Add-ppc64-relocations.patch b/grub2-ppc64le-17-Add-ppc64-relocations.patch deleted file mode 100644 index b68b122..0000000 --- a/grub2-ppc64le-17-Add-ppc64-relocations.patch +++ /dev/null @@ -1,310 +0,0 @@ -From 96d6b8d370e653386982b808f10a2a67849f73f1 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:44:46 +1100 -Subject: [PATCH 17/23] Add ppc64 relocations - - Add ppc64 relocations - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - grub-core/kern/powerpc/dl.c | 185 ++++++++++++++++++++++++++++++++++++++++---- - include/grub/elf.h | 3 + - 2 files changed, 174 insertions(+), 14 deletions(-) - -diff --git a/grub-core/kern/powerpc/dl.c b/grub-core/kern/powerpc/dl.c -index 7677e5a..cc496d3 100644 ---- a/grub-core/kern/powerpc/dl.c -+++ b/grub-core/kern/powerpc/dl.c -@@ -23,6 +23,20 @@ - #include - #include - -+#if defined( __powerpc64__ ) || defined( __powerpc64le__ ) -+#define ELFCLASSXX ELFCLASS64 -+#define ELFMACHINEXX EM_PPC64 -+#else -+#define ELFCLASSXX ELFCLASS32 -+#define ELFMACHINEXX EM_PPC -+#endif -+ -+#if defined( __powerpc64le__ ) -+#define ELFDATA2XSB ELFDATA2LSB -+#else -+#define ELFDATA2XSB ELFDATA2MSB -+#endif -+ - /* Check if EHDR is a valid ELF header. */ - grub_err_t - grub_arch_dl_check_header (void *ehdr) -@@ -30,14 +44,86 @@ grub_arch_dl_check_header (void *ehdr) - Elf_Ehdr *e = ehdr; - - /* Check the magic numbers. */ -- if (e->e_ident[EI_CLASS] != ELFCLASS32 -- || e->e_ident[EI_DATA] != ELFDATA2MSB -- || e->e_machine != EM_PPC) -+ if (e->e_ident[EI_CLASS] != ELFCLASSXX -+ || e->e_ident[EI_DATA] != ELFDATA2XSB -+ || e->e_machine != ELFMACHINEXX) - return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic")); - - return GRUB_ERR_NONE; - } - -+ -+ -+ -+#if defined( __powerpc64le__ ) -+struct trampoline -+{ -+ grub_uint32_t std; -+ grub_uint32_t addis; -+ grub_uint32_t addi; -+ grub_uint32_t mtctr; -+ grub_uint32_t bctr; -+}; -+ -+static const struct trampoline trampoline_template = -+ { -+ 0xf8410018, /* std r2,24(r1) */ -+ 0x3d800000, /* addis r12,0,0 */ -+ 0x398c0000, /* addi r12,r12,0 */ -+ 0x7d8903a6, /* mtctr r12 */ -+ 0x4e800420, /* bctr */ -+ }; -+ -+#define PPC_NOP 0x60000000 -+#define RESTORE_TOC 0xe8410018 /* ld r2,24(r1) */ -+ -+#define STO_PPC64_LOCAL_BIT 5 -+#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT) -+ -+static unsigned long grub_arch_dl_get_toc (grub_dl_t mod, void *ehdr) -+{ -+ unsigned long i = (unsigned long)grub_dl_find_section_addr(mod, ehdr, ".toc"); -+ if (!i) -+ return 0; -+ -+ return i; -+} -+ -+static inline unsigned int -+ppc64_decode_local_entry(unsigned int other) -+{ -+ return ((1 << other) >> 2) << 2; -+} -+ -+#define PPC64_LOCAL_ENTRY_OFFSET(other) \ -+ ppc64_decode_local_entry (((other) & STO_PPC64_LOCAL_MASK) \ -+ >> STO_PPC64_LOCAL_BIT) -+ -+ -+ -+#elif defined( __powerpc64__ ) -+ -+#error "NOT IMPLEMENTED YET" -+ -+static int grub_arch_dl_is_in_opd (grub_dl_t mod, void *ehdr, unsigned long addr) -+{ -+ unsigned long start, end; -+ Elf_Shdr *s = grub_dl_find_section(ehdr, ".opd"); -+ -+ if (!s) -+ return 0; -+ -+ start = (unsigned long)grub_dl_find_section_addr(mod, ehdr, ".opd"); -+ end = start + s->sh_size; -+ -+ if ((start <= addr) && (addr < end)) -+ return 1; -+ else -+ return 0; -+} -+ -+#else -+ - /* For low-endian reverse lis and addr_high as well as ori and addr_low. */ - struct trampoline - { -@@ -47,7 +133,7 @@ struct trampoline - grub_uint32_t bctr; - }; - --static const struct trampoline trampoline_template = -+static const struct trampoline trampoline_template = - { - 0x3d800000, - 0x618c0000, -@@ -55,6 +141,8 @@ static const struct trampoline trampoline_template = - 0x4e800420, - }; - -+#endif -+ - #pragma GCC diagnostic ignored "-Wcast-align" - - grub_err_t -@@ -74,14 +162,13 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, - if (s->sh_type == SHT_RELA) - { - const Elf_Rela *rel, *max; -- -+ - for (rel = (const Elf_Rela *) ((const char *) e + s->sh_offset), - max = rel + s->sh_size / s->sh_entsize; - rel < max; - rel++) - if (ELF_R_TYPE (rel->r_info) == GRUB_ELF_R_PPC_REL24) - (*tramp)++; -- - } - - *tramp *= sizeof (struct trampoline); -@@ -89,12 +176,15 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, - return GRUB_ERR_NONE; - } - -+#define PPC_LO(v) ((v) & 0xffff) -+#define PPC_HI(v) (((v) >> 16) & 0xffff) -+#define PPC_HA(v) PPC_HI ((v) + 0x8000) -+ - /* Relocate symbols. */ - grub_err_t - grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - Elf_Shdr *s, grub_dl_segment_t seg) - { --#ifdef powerpc - Elf_Rela *rel, *max; - - for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset), -@@ -104,7 +194,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - { - Elf_Word *addr; - Elf_Sym *sym; -- grub_uint32_t value; -+ Elf_Addr value; - - if (seg->size < rel->r_offset) - return grub_error (GRUB_ERR_BAD_MODULE, -@@ -119,6 +209,76 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - value = sym->st_value + rel->r_addend; - switch (ELF_R_TYPE (rel->r_info)) - { -+#ifdef __powerpc64le__ -+ case GRUB_ELF_R_PPC_REL24: -+ { -+ struct trampoline *tptr = mod->trampptr; -+ Elf_Sword delta; -+ if (sym->st_shndx == SHN_UNDEF) -+ { -+ grub_memcpy (tptr, &trampoline_template, sizeof (*tptr)); -+ -+ tptr->addis |= PPC_HA(value); -+ tptr->addi |= PPC_LO(value); -+ -+ mod->trampptr = tptr + 1; -+ delta = (grub_uint8_t *) tptr - (grub_uint8_t *) addr; -+ -+ if (*(addr+1) != PPC_NOP) -+ return grub_error (GRUB_ERR_BAD_MODULE, -+ "Missing NOP after PPC_REL24 got %x", *(addr+1)); -+ *(addr+1) = RESTORE_TOC; -+ } else -+ delta = (grub_uint8_t *)value - (grub_uint8_t *) addr + -+ PPC64_LOCAL_ENTRY_OFFSET(sym->st_other); -+ -+ -+ if (delta << 6 >> 6 != delta) -+ return grub_error (GRUB_ERR_BAD_MODULE, -+ "relocation overflow"); -+ -+ *(Elf_Word *) (addr) = (*addr & ~0x03fffffc) | (delta & 0x03fffffc); -+ } -+ break; -+ -+ case GRUB_ELF_R_PPC64_ADDR64: -+ *(Elf_Xword *) addr = value; -+ break; -+ -+ case GRUB_ELF_R_PPC64_TOC: -+ *(Elf_Xword *) addr = grub_arch_dl_get_toc(mod, ehdr); -+ break; -+ -+ case GRUB_ELF_R_PPC64_TOC16_HA: -+ value -= grub_arch_dl_get_toc(mod, ehdr); -+ *(Elf_Half *) addr = PPC_HA(value); -+ break; -+ -+ case GRUB_ELF_R_PPC64_TOC16_LO: -+ value -= grub_arch_dl_get_toc(mod, ehdr); -+ *(Elf_Half *) addr = PPC_LO(value); -+ break; -+ -+ case GRUB_ELF_R_PPC64_TOC16_LO_DS: -+ value -= grub_arch_dl_get_toc(mod, ehdr); -+ if (value & 3) -+ return grub_error (GRUB_ERR_BAD_MODULE, -+ "bad TOC16_LO_DS relocation"); -+ -+ *(Elf_Half *) addr = ((*(Elf_Half *) addr) & ~0xfffc) | (value & 0xfffc); -+ break; -+ -+ case GRUB_ELF_R_PPC64_REL16_HA: -+ value -= (unsigned long) addr; -+ *(Elf_Half *) addr = PPC_HA(value); -+ break; -+ -+ case GRUB_ELF_R_PPC64_REL16_LO: -+ value -= (unsigned long) addr; -+ *(Elf_Half *) addr = PPC_LO(value); -+ break; -+#else -+ - case GRUB_ELF_R_PPC_ADDR16_LO: - *(Elf_Half *) addr = value; - break; -@@ -137,7 +297,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - tptr->ori |= ((value) & 0xffff); - mod->trampptr = tptr + 1; - } -- -+ - if (delta << 6 >> 6 != delta) - return grub_error (GRUB_ERR_BAD_MODULE, - "relocation overflow"); -@@ -156,6 +316,8 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - case GRUB_ELF_R_PPC_REL32: - *addr = value - (Elf_Word) addr; - break; -+#endif -+ - default: - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - N_("relocation 0x%x is not implemented yet"), -@@ -164,9 +326,4 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - } - - return GRUB_ERR_NONE; --#else -- return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -- N_("relocation is not implemented yet for module=%llx ehdr=%llx Elf_Shdr=%llx seg=%llx"), -- mod, ehdr, s, seg); --#endif - } -diff --git a/include/grub/elf.h b/include/grub/elf.h -index bee7583..224d164 100644 ---- a/include/grub/elf.h -+++ b/include/grub/elf.h -@@ -1998,6 +1998,9 @@ typedef Elf32_Addr Elf32_Conflict; - #define GRUB_ELF_R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ - #define GRUB_ELF_R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ - -+#define GRUB_ELF_R_PPC64_REL16_LO 250 -+#define GRUB_ELF_R_PPC64_REL16_HA 252 -+ - /* This is a phony reloc to handle any old fashioned TOC16 references - that may still be in object files. */ - #define GRUB_ELF_R_PPC_TOC16 255 --- -1.8.3.1 diff --git a/grub2-ppc64le-18-ppc64-doesn-t-need-libgcc-routines.patch b/grub2-ppc64le-18-ppc64-doesn-t-need-libgcc-routines.patch deleted file mode 100644 index 4f5f725..0000000 --- a/grub2-ppc64le-18-ppc64-doesn-t-need-libgcc-routines.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 8dc2290890dc8e1cf534b6e44ab44bab4d694da5 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:49:12 +1100 -Subject: [PATCH 18/23] ppc64 doesn't need libgcc routines - - ppc64 doesn't need libgcc routines - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - include/grub/libgcc.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h -index fdc6611..69a95bc 100644 ---- a/include/grub/libgcc.h -+++ b/include/grub/libgcc.h -@@ -23,7 +23,7 @@ - #include - - /* On x86 these functions aren't really needed. Save some space. */ --#if !defined (__i386__) && !defined (__x86_64__) -+#if !defined (__i386__) && !defined (__x86_64__) && !defined (__powerpc64le__) - # ifdef HAVE___ASHLDI3 - void EXPORT_FUNC (__ashldi3) (void); - # endif --- -1.8.3.1 diff --git a/grub2-ppc64le-19-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch b/grub2-ppc64le-19-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch deleted file mode 100644 index 2f958cc..0000000 --- a/grub2-ppc64le-19-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch +++ /dev/null @@ -1,76 +0,0 @@ -From d63aa12f89bfd5e0cc11983601323694e9a24be7 Mon Sep 17 00:00:00 2001 -From: Anton Blanchard -Date: Wed, 29 Jan 2014 10:52:28 +1100 -Subject: [PATCH 19/23] Use FUNC_START/FUNC_END - - Use FUNC_START/FUNC_END for powerpc function definitions - -Signed-off-by: Ram Pai -From: Anton Blanchard ---- - grub-core/kern/powerpc/cache.S | 6 ++++-- - grub-core/lib/powerpc/setjmp.S | 8 +++++--- - 2 files changed, 9 insertions(+), 5 deletions(-) - -diff --git a/grub-core/kern/powerpc/cache.S b/grub-core/kern/powerpc/cache.S -index d85e68d..82f10f8 100644 ---- a/grub-core/kern/powerpc/cache.S -+++ b/grub-core/kern/powerpc/cache.S -@@ -17,10 +17,12 @@ - * along with GRUB. If not, see . - */ - -+#include -+ - .text - - .align 2 -- .globl grub_arch_sync_caches --grub_arch_sync_caches: -+FUNC_START(grub_arch_sync_caches) - #include "cache_flush.S" - blr -+FUNC_END(grub_arch_sync_caches) -diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S -index 51fcae9..6fdd60e 100644 ---- a/grub-core/lib/powerpc/setjmp.S -+++ b/grub-core/lib/powerpc/setjmp.S -@@ -18,6 +18,7 @@ - - #include - #include -+#include - - .file "setjmp.S" - -@@ -38,7 +39,7 @@ GRUB_MOD_LICENSE "GPLv3+" - /* - * int grub_setjmp (grub_jmp_buf env) - */ --FUNCTION(grub_setjmp) -+FUNC_START(grub_setjmp) - STORE 1, 0(3) - STORE 14, 1*SZ_LONG(3) - STORE 15, 2*SZ_LONG(3) -@@ -64,11 +65,12 @@ FUNCTION(grub_setjmp) - STORE 4, 20*SZ_LONG(3) - li 3, 0 - blr -+FUNC_END(grub_setjmp) - - /* - * int grub_longjmp (grub_jmp_buf env, int val) - */ --FUNCTION(grub_longjmp) -+FUNC_START(grub_longjmp) - LOAD 1, 0(3) - LOAD 14, 1*SZ_LONG(3) - LOAD 15, 2*SZ_LONG(3) -@@ -96,4 +98,4 @@ FUNCTION(grub_longjmp) - bne 1f - li 3, 1 - 1: blr -- -+FUNC_END(grub_longjmp) --- -1.8.3.1 diff --git a/grub2-ppc64le-20-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch b/grub2-ppc64le-20-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch deleted file mode 100644 index 904c680..0000000 --- a/grub2-ppc64le-20-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 8212195e18301ed18a060722e2b5933d2052b2c1 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Tue, 25 Feb 2014 18:59:13 +0000 -Subject: [PATCH 20/23] handle .TOC. symbol while loading - -.TOC. symbol is special in ppc64le . It maps to the - address of the .toc section. - -Signed-off-by: Ram Pai ---- - grub-core/kern/dl.c | 34 +++++++++++++++++++++++++++++++++- - 1 file changed, 33 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index de2d0ed..ce2ff38 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -343,6 +343,26 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) - return GRUB_ERR_NONE; - } - -+#ifdef __powerpc64le__ -+static int -+grub_dl_find_section_index (Elf_Ehdr *e, const char *name) -+{ -+ Elf_Shdr *s; -+ const char *str; -+ unsigned i; -+ -+ s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize); -+ str = (char *) e + s->sh_offset; -+ -+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); -+ i < e->e_shnum; -+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) -+ if (grub_strcmp (str + s->sh_name, name) == 0) -+ return i; -+ return -1; -+} -+#endif -+ - static grub_err_t - grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) - { -@@ -392,7 +412,19 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) - /* Resolve a global symbol. */ - if (sym->st_name != 0 && sym->st_shndx == 0) - { -- grub_symbol_t nsym = grub_dl_resolve_symbol (name); -+ grub_symbol_t nsym; -+ -+#ifdef __powerpc64le__ -+ if (grub_strcmp(name, ".TOC.") == 0) { -+ int j = grub_dl_find_section_index (e, ".toc"); -+ if (j < 0) -+ return grub_error (GRUB_ERR_BAD_MODULE, -+ N_("section '.toc' not found"), name); -+ sym->st_value = (Elf_Addr) grub_dl_get_section_addr (mod, j); -+ break; -+ } -+#endif -+ nsym = grub_dl_resolve_symbol (name); - if (! nsym) - return grub_error (GRUB_ERR_BAD_MODULE, - N_("symbol `%s' not found"), name); --- -1.8.3.1 diff --git a/grub2-ppc64le-21-the-.toc-section-in-powerpc64le-modules-are-sometime.patch b/grub2-ppc64le-21-the-.toc-section-in-powerpc64le-modules-are-sometime.patch deleted file mode 100644 index 6893eac..0000000 --- a/grub2-ppc64le-21-the-.toc-section-in-powerpc64le-modules-are-sometime.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 584206ed234f18aab8c9e41e869b539003c56c44 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Tue, 25 Feb 2014 20:49:28 +0000 -Subject: [PATCH 21/23] fix the .toc section alignment - - - the .toc section in powerpc64le modules are sometimes - not aligned on a four byte boundary. This fails the module linker especially - when processing R_PPC64_TOC16_LO_DS, since the addresses are expected to be - aligned on 4byte boundary. - -Signed-off-by: Ram Pai ---- - grub-core/kern/dl.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index ce2ff38..ee69c3c 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -304,7 +304,12 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) - { - void *addr; - -+#ifdef __powerpc64le__ -+ ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, -+ (s->sh_addralign < 4 ? 4 : s->sh_addralign)); -+#else - ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, s->sh_addralign); -+#endif - addr = ptr; - ptr += s->sh_size; - --- -1.8.3.1 diff --git a/grub2-ppc64le-22-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch b/grub2-ppc64le-22-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch deleted file mode 100644 index 7fb2fe7..0000000 --- a/grub2-ppc64le-22-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch +++ /dev/null @@ -1,704 +0,0 @@ -From 4d0c5500be3cb776345e417c542d6d1fea1a3314 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Tue, 25 Feb 2014 22:43:25 +0000 -Subject: [PATCH 22/23] fix parameter to firmware calls - - all parameter to firmware calls should be BigEndian - and the results should be CPU endian. - -Signed-off-by: Ram Pai ---- - grub-core/disk/ieee1275/nand.c | 41 +++++----- - grub-core/disk/ieee1275/ofdisk.c | 22 ++++-- - grub-core/kern/ieee1275/ieee1275.c | 134 +++++++++++++++++++-------------- - grub-core/kern/ieee1275/openfw.c | 19 ++--- - grub-core/lib/ieee1275/datetime.c | 32 ++++---- - grub-core/net/drivers/ieee1275/ofnet.c | 6 +- - include/grub/ieee1275/ieee1275.h | 8 +- - 7 files changed, 148 insertions(+), 114 deletions(-) - -diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c -index 576e9cc..1846c23 100644 ---- a/grub-core/disk/ieee1275/nand.c -+++ b/grub-core/disk/ieee1275/nand.c -@@ -102,32 +102,33 @@ grub_nand_open (const char *name, grub_disk_t disk) - data->handle = dev_ihandle; - - INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2); -- args.method = (grub_ieee1275_cell_t) "block-size"; -- args.ihandle = dev_ihandle; -- args.result = 1; -+ args.method = IEEE1275_ADDR("block-size"); -+ args.ihandle = IEEE1275_VALUE(dev_ihandle); -+ args.result = IEEE1275_VALUE(1); - -- if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) -+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result)) - { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get block size"); - goto fail; - } - -+ args.size1 = IEEE1275_VALUE(args.size1); - data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS); - - INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); -- args.method = (grub_ieee1275_cell_t) "size"; -- args.ihandle = dev_ihandle; -- args.result = 1; -+ args.method = IEEE1275_ADDR( "size"); -+ args.ihandle = IEEE1275_VALUE(dev_ihandle); -+ args.result = IEEE1275_VALUE(1); - -- if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) -+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result)) - { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get disk size"); - goto fail; - } - -- disk->total_sectors = args.size1; -+ disk->total_sectors = IEEE1275_VALUE(args.size1); - disk->total_sectors <<= 32; -- disk->total_sectors += args.size2; -+ disk->total_sectors += IEEE1275_VALUE(args.size2); - disk->total_sectors >>= GRUB_DISK_SECTOR_BITS; - - disk->id = dev_ihandle; -@@ -170,10 +171,10 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector, - } args; - - INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); -- args.method = (grub_ieee1275_cell_t) "pio-read"; -- args.ihandle = data->handle; -- args.buf = (grub_ieee1275_cell_t) buf; -- args.page = (grub_ieee1275_cell_t) ((grub_size_t) sector / data->block_size); -+ args.method = IEEE1275_ADDR("pio-read"); -+ args.ihandle = IEEE1275_VALUE(data->handle); -+ args.buf = buf; -+ args.page = (grub_size_t) sector / data->block_size; - - ofs = ((grub_size_t) sector % data->block_size) << GRUB_DISK_SECTOR_BITS; - size <<= GRUB_DISK_SECTOR_BITS; -@@ -185,16 +186,20 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector, - - len = (ofs + size > bsize) ? (bsize - ofs) : size; - -- args.len = (grub_ieee1275_cell_t) len; -- args.ofs = (grub_ieee1275_cell_t) ofs; -- args.result = 1; -+ args.len = IEEE1275_VALUE(len); -+ args.ofs = IEEE1275_VALUE(ofs); -+ args.result = IEEE1275_VALUE(1); -+ args.buf = IEEE1275_ADDR(args.buf); -+ args.page = IEEE1275_VALUE(args.page); - -- if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) -+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result)) - return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx " - "from `%s'"), - (unsigned long long) sector, - disk->name); - -+ args.buf = IEEE1275_ADDR(args.buf); -+ args.page = IEEE1275_VALUE(args.page); - ofs = 0; - size -= len; - args.buf += len; -diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c -index d785d6a..72b36c5 100644 ---- a/grub-core/disk/ieee1275/ofdisk.c -+++ b/grub-core/disk/ieee1275/ofdisk.c -@@ -225,16 +225,19 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) - - INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); - args.method = IEEE1275_ADDR("vscsi-report-luns"); -- args.ihandle = ihandle; -- args.table = 0; -- args.nentries = 0; -+ args.ihandle = IEEE1275_VALUE(ihandle); -+ args.table = IEEE1275_ADDR(0); -+ args.nentries = IEEE1275_VALUE(0); - -- if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch_result) -+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || IEEE1275_VALUE(args.catch_result)) - { - grub_ieee1275_close (ihandle); - return; - } - -+ args.table = IEEE1275_ADDR(args.table); -+ args.nentries = IEEE1275_VALUE(args.nentries); -+ - buf = grub_malloc (grub_strlen (alias->path) + 32); - if (!buf) - return; -@@ -245,6 +248,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) - grub_uint64_t *ptr; - - ptr = *(grub_uint64_t **) ((grub_addr_t)args.table + 4 + 8 * i); -+ ptr = (grub_uint64_t *) (grub_addr_t) IEEE1275_ADDR(ptr); - while (*ptr) - { - grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++); -@@ -614,18 +618,20 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size) - - INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2); - args_ieee1275.method = IEEE1275_ADDR("block-size"); -- args_ieee1275.ihandle = last_ihandle; -- args_ieee1275.result = 1; -+ args_ieee1275.ihandle = IEEE1275_VALUE(last_ihandle); -+ args_ieee1275.result = IEEE1275_VALUE(1); - - *block_size = GRUB_DISK_SECTOR_SIZE; - -- if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result)) -+ if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || IEEE1275_VALUE(args_ieee1275.result)) - grub_dprintf ("disk", "can't get block size\n"); -- else -+ else { -+ args_ieee1275.size1 = IEEE1275_VALUE(args_ieee1275.size1); - if (args_ieee1275.size1 - && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1)) - && args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384) - *block_size = args_ieee1275.size1; -+ } - - return 0; - } -diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c -index f933c89..df8943c 100644 ---- a/grub-core/kern/ieee1275/ieee1275.c -+++ b/grub-core/kern/ieee1275/ieee1275.c -@@ -42,7 +42,7 @@ grub_ieee1275_finddevice (const char *name, grub_ieee1275_phandle_t *phandlep) - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *phandlep = args.phandle; -+ *phandlep = args.phandle = IEEE1275_VALUE(args.phandle); - if (args.phandle == IEEE1275_PHANDLE_INVALID) - return -1; - return 0; -@@ -65,13 +65,15 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, - args; - - INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1); -- args.phandle = phandle; -+ args.phandle = IEEE1275_VALUE(phandle); - args.prop = IEEE1275_ADDR(property); - args.buf = IEEE1275_ADDR(buf); -- args.buflen = (grub_ieee1275_cell_t) size; -+ args.buflen = IEEE1275_VALUE(size); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -+ -+ args.size = IEEE1275_VALUE(args.size); - if (actual) - *actual = (grub_ssize_t) args.size; - if (args.size == IEEE1275_CELL_INVALID) -@@ -79,6 +81,18 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle, - return 0; - } - -+#ifdef __powerpc64le__ -+static void -+grub_swap_bytes(grub_uint32_t *buf, grub_size_t len) -+{ -+ /* Integer properties are always in big endian. */ -+ unsigned int i; -+ len /= sizeof (grub_uint32_t); -+ for (i = 0; i < len; i++) -+ buf[i] = IEEE1275_VALUE(buf[i]); -+} -+#endif -+ - int - grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle, - const char *property, grub_uint32_t *buf, -@@ -86,16 +100,13 @@ grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle, - { - int ret; - ret = grub_ieee1275_get_property (phandle, property, (void *) buf, size, actual); --#ifndef GRUB_CPU_WORDS_BIGENDIAN -+ -+#ifdef __powerpc64le__ - /* Integer properties are always in big endian. */ - if (ret == 0) -- { -- unsigned int i; -- size /= sizeof (grub_uint32_t); -- for (i = 0; i < size; i++) -- buf[i] = grub_be_to_cpu32 (buf[i]); -- } -+ grub_swap_bytes(buf, size); - #endif -+ - return ret; - } - -@@ -114,14 +125,14 @@ grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop, - args; - - INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1); -- args.phandle = phandle; -+ args.phandle = IEEE1275_VALUE(phandle); - args.prev_prop = IEEE1275_ADDR(prev_prop); - args.next_prop = IEEE1275_ADDR(prop); -- args.flags = (grub_ieee1275_cell_t) -1; -+ args.flags = IEEE1275_VALUE(-1); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- return (int) args.flags; -+ return (int) IEEE1275_VALUE(args.flags); - } - - int -@@ -138,13 +149,13 @@ grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle, - args; - - INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); -- args.phandle = phandle; -+ args.phandle = IEEE1275_VALUE(phandle); - args.prop = IEEE1275_ADDR(prop); -- args.length = (grub_ieee1275_cell_t) -1; -+ args.length = IEEE1275_VALUE(-1); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *length = args.length; -+ *length = args.length = IEEE1275_VALUE(args.length); - if (args.length == IEEE1275_CELL_INVALID) - return -1; - return 0; -@@ -163,11 +174,11 @@ grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle, - args; - - INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1); -- args.ihandle = ihandle; -+ args.ihandle = IEEE1275_VALUE(ihandle); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *phandlep = args.phandle; -+ *phandlep = args.phandle = IEEE1275_VALUE(args.phandle); - if (args.phandle == IEEE1275_PHANDLE_INVALID) - return -1; - return 0; -@@ -189,12 +200,14 @@ grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle, - args; - - INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1); -- args.phandle = phandle; -+ args.phandle = IEEE1275_VALUE(phandle); - args.buf = IEEE1275_ADDR(path); -- args.buflen = (grub_ieee1275_cell_t) len; -+ args.buflen = IEEE1275_VALUE(len); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -+ -+ args.actual = IEEE1275_VALUE(args.actual); - if (actual) - *actual = args.actual; - if (args.actual == IEEE1275_CELL_INVALID) -@@ -218,12 +231,14 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle, - args; - - INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1); -- args.ihandle = ihandle; -+ args.ihandle = IEEE1275_VALUE(ihandle); - args.buf = IEEE1275_ADDR(path); -- args.buflen = (grub_ieee1275_cell_t) len; -+ args.buflen = IEEE1275_VALUE(len); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -+ -+ args.actual = IEEE1275_VALUE(args.actual); - if (actual) - *actual = args.actual; - if (args.actual == IEEE1275_CELL_INVALID) -@@ -231,6 +246,7 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle, - return 0; - } - -+ - int - grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer, - grub_size_t len, grub_ssize_t *actualp) -@@ -246,12 +262,13 @@ grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer, - args; - - INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); -- args.ihandle = ihandle; -+ args.ihandle = IEEE1275_VALUE(ihandle); - args.buf = IEEE1275_ADDR(buffer); -- args.len = (grub_ieee1275_cell_t) len; -+ args.len = IEEE1275_VALUE(len); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -+ args.actual = IEEE1275_VALUE(args.actual); - if (actualp) - *actualp = args.actual; - return 0; -@@ -272,14 +289,16 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer, - args; - - INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); -- args.ihandle = ihandle; -+ args.ihandle = IEEE1275_VALUE(ihandle); - args.buf = IEEE1275_ADDR(buffer); -- args.len = (grub_ieee1275_cell_t) len; -+ args.len = IEEE1275_VALUE(len); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -+ args.actual = IEEE1275_VALUE(args.actual); - if (actualp) - *actualp = args.actual; -+ - return 0; - } - -@@ -298,20 +317,20 @@ grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, grub_disk_addr_t pos, - args; - - INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1); -- args.ihandle = ihandle; -+ args.ihandle = IEEE1275_VALUE(ihandle); - /* To prevent stupid gcc warning. */ - #if GRUB_IEEE1275_CELL_SIZEOF >= 8 - args.pos_hi = 0; -- args.pos_lo = pos; -+ args.pos_lo = IEEE1275_VALUE(pos); - #else -- args.pos_hi = (grub_ieee1275_cell_t) (pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF)); -- args.pos_lo = (grub_ieee1275_cell_t) -- (pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1)); -+ args.pos_hi = IEEE1275_VALUE((pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF))); -+ args.pos_lo = IEEE1275_VALUE((pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1))); - #endif - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - -+ args.result = IEEE1275_VALUE(args.result); - if (result) - *result = args.result; - return 0; -@@ -330,11 +349,11 @@ grub_ieee1275_peer (grub_ieee1275_phandle_t node, - args; - - INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1); -- args.node = node; -+ args.node = IEEE1275_VALUE(node); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *result = args.result; -+ *result = args.result = IEEE1275_VALUE(args.result); - if (args.result == 0) - return -1; - return 0; -@@ -353,12 +372,12 @@ grub_ieee1275_child (grub_ieee1275_phandle_t node, - args; - - INIT_IEEE1275_COMMON (&args.common, "child", 1, 1); -- args.node = node; -- args.result = IEEE1275_PHANDLE_INVALID; -+ args.node = IEEE1275_VALUE(node); -+ args.result = IEEE1275_VALUE(IEEE1275_PHANDLE_INVALID); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *result = args.result; -+ *result = args.result = IEEE1275_VALUE(args.result); - if (args.result == 0) - return -1; - return 0; -@@ -377,12 +396,12 @@ grub_ieee1275_parent (grub_ieee1275_phandle_t node, - args; - - INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1); -- args.node = node; -- args.result = IEEE1275_PHANDLE_INVALID; -+ args.node = IEEE1275_VALUE(node); -+ args.result = IEEE1275_VALUE(IEEE1275_PHANDLE_INVALID); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *result = args.result; -+ *result = IEEE1275_VALUE(args.result); - return 0; - } - -@@ -405,6 +424,7 @@ grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch) - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -+ args.catch = IEEE1275_VALUE(args.catch); - if (catch) - *catch = args.catch; - return 0; -@@ -457,7 +477,7 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result) - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *result = args.result; -+ *result = args.result = IEEE1275_VALUE(args.result); - if (args.result == IEEE1275_IHANDLE_INVALID) - return -1; - return 0; -@@ -474,7 +494,7 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) - args; - - INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); -- args.ihandle = ihandle; -+ args.ihandle = IEEE1275_VALUE(ihandle); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -@@ -497,12 +517,14 @@ grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, - args; - - INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1); -- args.addr = (grub_ieee1275_cell_t) addr; -- args.size = (grub_ieee1275_cell_t) size; -- args.align = (grub_ieee1275_cell_t) align; -+ args.addr = IEEE1275_VALUE(addr); -+ args.size = IEEE1275_VALUE(size); -+ args.align = IEEE1275_VALUE(align); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -+ -+ args.base = IEEE1275_VALUE(args.base); - if (result) - *result = args.base; - if (args.base == IEEE1275_CELL_INVALID) -@@ -522,8 +544,8 @@ grub_ieee1275_release (grub_addr_t addr, grub_size_t size) - args; - - INIT_IEEE1275_COMMON (&args.common, "release", 2, 0); -- args.addr = addr; -- args.size = size; -+ args.addr = IEEE1275_VALUE(addr); -+ args.size = IEEE1275_VALUE(size); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -@@ -547,14 +569,14 @@ grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle, - args; - - INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); -- args.size = (grub_ieee1275_cell_t) size; -+ args.size = IEEE1275_VALUE(size); - args.buf = IEEE1275_ADDR(buf); - args.propname = IEEE1275_ADDR(propname); -- args.phandle = (grub_ieee1275_cell_t) phandle; -+ args.phandle = IEEE1275_VALUE(phandle); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *actual = args.actual; -+ *actual = args.actual = IEEE1275_VALUE(args.actual); - if ((args.actual == IEEE1275_CELL_INVALID) || (args.actual != args.size)) - return -1; - return 0; -@@ -579,15 +601,15 @@ grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle, - - INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); - args.method = IEEE1275_ADDR("color!"); -- args.ihandle = ihandle; -- args.index = index; -- args.r = r; -- args.g = g; -- args.b = b; -+ args.ihandle = IEEE1275_VALUE(ihandle); -+ args.index = IEEE1275_VALUE(index); -+ args.r = IEEE1275_VALUE(r); -+ args.g = IEEE1275_VALUE(g); -+ args.b = IEEE1275_VALUE(b); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- return args.catch_result; -+ return IEEE1275_VALUE(args.catch_result); - } - - int -@@ -604,6 +626,6 @@ grub_ieee1275_milliseconds (grub_uint32_t *msecs) - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; -- *msecs = args.msecs; -+ *msecs = IEEE1275_VALUE(args.msecs); - return 0; - } -diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c -index a8bbc71..ced8e3f 100644 ---- a/grub-core/kern/ieee1275/openfw.c -+++ b/grub-core/kern/ieee1275/openfw.c -@@ -286,20 +286,20 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size, - #endif - 1); - args.method = IEEE1275_ADDR("map"); -- args.ihandle = grub_ieee1275_mmu; -+ args.ihandle = IEEE1275_VALUE(grub_ieee1275_mmu); - #ifdef __sparc__ - args.phys_high = 0; - #endif -- args.phys_low = phys; -- args.virt = virt; -- args.size = size; -- args.mode = mode; /* Format is WIMG0PP. */ -- args.catch_result = (grub_ieee1275_cell_t) -1; -+ args.phys_low = IEEE1275_ADDR(phys); -+ args.virt = IEEE1275_ADDR(virt); -+ args.size = IEEE1275_VALUE(size); -+ args.mode = IEEE1275_VALUE(mode); /* Format is WIMG0PP. */ -+ args.catch_result = IEEE1275_VALUE((grub_ieee1275_cell_t) -1); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return -1; - -- return args.catch_result; -+ return IEEE1275_VALUE(args.catch_result); - } - - grub_err_t -@@ -545,10 +545,12 @@ grub_ieee1275_canonicalise_devname (const char *path) - INIT_IEEE1275_COMMON (&args.common, "canon", 3, 1); - args.path = IEEE1275_ADDR(path); - args.buf = IEEE1275_ADDR(buf); -- args.inlen = (grub_ieee1275_cell_t) (bufsize - 1); -+ args.inlen = IEEE1275_VALUE(bufsize - 1); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1) - return 0; -+ -+ args.outlen = IEEE1275_VALUE(args.outlen); - if (args.outlen > bufsize - 1) - { - bufsize = args.outlen + 2; -@@ -560,4 +562,3 @@ grub_ieee1275_canonicalise_devname (const char *path) - grub_free (buf); - return NULL; - } -- -diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c -index fa0d3b6..7ee1ae2 100644 ---- a/grub-core/lib/ieee1275/datetime.c -+++ b/grub-core/lib/ieee1275/datetime.c -@@ -83,22 +83,22 @@ grub_get_datetime (struct grub_datetime *datetime) - return grub_error (GRUB_ERR_IO, "couldn't open RTC"); - - INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 7); -- args.device = (grub_ieee1275_cell_t) ihandle; -+ args.device = IEEE1275_VALUE((grub_ieee1275_cell_t) ihandle); - args.method = IEEE1275_ADDR("get-time"); - - status = IEEE1275_CALL_ENTRY_FN (&args); - - grub_ieee1275_close (ihandle); - -- if (status == -1 || args.catch_result) -+ if (status == -1 || IEEE1275_VALUE(args.catch_result)) - return grub_error (GRUB_ERR_IO, "get-time failed"); - -- datetime->year = args.year; -- datetime->month = args.month; -- datetime->day = args.day; -- datetime->hour = args.hour; -- datetime->minute = args.minute; -- datetime->second = args.second; -+ datetime->year = IEEE1275_VALUE(args.year); -+ datetime->month = IEEE1275_VALUE(args.month); -+ datetime->day = IEEE1275_VALUE(args.day); -+ datetime->hour = IEEE1275_VALUE(args.hour); -+ datetime->minute = IEEE1275_VALUE(args.minute); -+ datetime->second = IEEE1275_VALUE(args.second); - - return GRUB_ERR_NONE; - } -@@ -135,21 +135,21 @@ grub_set_datetime (struct grub_datetime *datetime) - return grub_error (GRUB_ERR_IO, "couldn't open RTC"); - - INIT_IEEE1275_COMMON (&args.common, "call-method", 8, 1); -- args.device = (grub_ieee1275_cell_t) ihandle; -+ args.device = IEEE1275_VALUE(ihandle); - args.method = IEEE1275_ADDR("set-time"); - -- args.year = datetime->year; -- args.month = datetime->month; -- args.day = datetime->day; -- args.hour = datetime->hour; -- args.minute = datetime->minute; -- args.second = datetime->second; -+ args.year = IEEE1275_VALUE(datetime->year); -+ args.month = IEEE1275_VALUE(datetime->month); -+ args.day = IEEE1275_VALUE(datetime->day); -+ args.hour = IEEE1275_VALUE(datetime->hour); -+ args.minute = IEEE1275_VALUE(datetime->minute); -+ args.second = IEEE1275_VALUE(datetime->second); - - status = IEEE1275_CALL_ENTRY_FN (&args); - - grub_ieee1275_close (ihandle); - -- if (status == -1 || args.catch_result) -+ if (status == -1 || IEEE1275_VALUE(args.catch_result)) - return grub_error (GRUB_ERR_IO, "set-time failed"); - - return GRUB_ERR_NONE; -diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index 07c8446..01dfe85 100644 ---- a/grub-core/net/drivers/ieee1275/ofnet.c -+++ b/grub-core/net/drivers/ieee1275/ofnet.c -@@ -385,17 +385,17 @@ search_net_devices (struct grub_ieee1275_devalias *alias) - } - args; - INIT_IEEE1275_COMMON (&args.common, "interpret", 2, 2); -- args.len = card->txbufsize; -+ args.len = IEEE1275_VALUE(card->txbufsize); - args.method = IEEE1275_ADDR("alloc-mem"); - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1 -- || args.catch) -+ || IEEE1275_VALUE(args.catch)) - { - card->txbuf = 0; - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); - } - else -- card->txbuf = (void *) (grub_addr_t) args.result; -+ card->txbuf = (void *) (grub_addr_t) IEEE1275_VALUE(args.result); - } - else - card->txbuf = grub_zalloc (card->txbufsize); -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 2e5270c..be0c235 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -49,12 +49,12 @@ struct grub_ieee1275_common_hdr - grub_ieee1275_cell_t nr_outs; - }; - --#define IEEE1275_ADDR(x) (grub_uint32_t)(grub_addr_t)(x) -- -+#define IEEE1275_ADDR(x) (grub_uint32_t)grub_cpu_to_be32((grub_addr_t)(x)) -+#define IEEE1275_VALUE(x) (grub_uint32_t)grub_cpu_to_be32(x) - #define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \ - (p)->name = (grub_ieee1275_cell_t) IEEE1275_ADDR(xname); \ -- (p)->nr_ins = (grub_ieee1275_cell_t) xins; \ -- (p)->nr_outs = (grub_ieee1275_cell_t) xouts -+ (p)->nr_ins = (grub_ieee1275_cell_t) IEEE1275_VALUE(xins); \ -+ (p)->nr_outs = (grub_ieee1275_cell_t) IEEE1275_VALUE(xouts) - - typedef grub_uint32_t grub_ieee1275_ihandle_t; - typedef grub_uint32_t grub_ieee1275_phandle_t; --- -1.8.3.1 diff --git a/grub2-ppc64le-23-grub-segfaults-if-initrd-is-specified-before-specify.patch b/grub2-ppc64le-23-grub-segfaults-if-initrd-is-specified-before-specify.patch deleted file mode 100644 index aa2b564..0000000 --- a/grub2-ppc64le-23-grub-segfaults-if-initrd-is-specified-before-specify.patch +++ /dev/null @@ -1,35 +0,0 @@ -From c7fbe6c1ae22ac9853b03a3d4d742712f31e69b9 Mon Sep 17 00:00:00 2001 -From: Ram Pai -Date: Tue, 25 Feb 2014 23:31:06 +0000 -Subject: [PATCH 23/23] grub segfaults if initrd is specified before specifying - - grub segfaults if initrd is specified before specifying - the kernel. The problem is the initrd module sees that kernel is not - specified and takes the fail path. In the fail path it checks if anything has - be malloc'ed. Unfortunately the variable that it looks to check for is a - uninitialized stack variable. The stack variable can incorrectly indicate - something is malloced, which leads the module to free some unallocated - memory. This patch fixes the problem by initializing the stack variable. - -Signed-off-by: Ram Pai ---- - grub-core/loader/powerpc/ieee1275/linux.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c -index 9dde053..0d94433 100644 ---- a/grub-core/loader/powerpc/ieee1275/linux.c -+++ b/grub-core/loader/powerpc/ieee1275/linux.c -@@ -335,6 +335,10 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - grub_addr_t addr; - struct grub_linux_initrd_context initrd_ctx; - -+ // initialize, otherwise the fail path will try to -+ // free up data and segfault -+ initrd_ctx.components = NULL; -+ - if (argc == 0) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); --- -1.8.3.1 diff --git a/grub2-ppc64le-core-bigendian.patch b/grub2-ppc64le-core-bigendian.patch new file mode 100644 index 0000000..9c22165 --- /dev/null +++ b/grub2-ppc64le-core-bigendian.patch @@ -0,0 +1,31 @@ +Index: grub-2.02~beta2/conf/Makefile.common +=================================================================== +--- grub-2.02~beta2.orig/conf/Makefile.common ++++ grub-2.02~beta2/conf/Makefile.common +@@ -41,20 +41,20 @@ BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT) + + LDADD_KERNEL = $(TARGET_LIBGCC) + +-CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding ++CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -mbig-endian + LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) +-CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 ++CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 -mbig-endian + CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version + +-CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding ++CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -mbig-endian + LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +-CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) ++CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -mbig-endian + CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + +-CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin ++CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin -mbig-endian + LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S +-CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) ++CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -mbig-endian + CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + + CFLAGS_PROGRAM = diff --git a/grub2-ppc64le-platform.patch b/grub2-ppc64le-platform.patch new file mode 100644 index 0000000..e0d1b0f --- /dev/null +++ b/grub2-ppc64le-platform.patch @@ -0,0 +1,13 @@ +Index: grub-2.02~beta2/configure.ac +=================================================================== +--- grub-2.02~beta2.orig/configure.ac ++++ grub-2.02~beta2/configure.ac +@@ -137,6 +137,7 @@ case "$target_cpu"-"$platform" in + x86_64-xen) ;; + x86_64-*) target_cpu=i386 ;; + powerpc64-ieee1275) target_cpu=powerpc ;; ++ powerpc64le-ieee1275) target_cpu=powerpc ;; + esac + + # Check if the platform is supported, make final adjustments. + diff --git a/grub2-s390x-02-kexec-module-added-to-emu.patch b/grub2-s390x-02-kexec-module-added-to-emu.patch deleted file mode 100644 index 7fc6ce4..0000000 --- a/grub2-s390x-02-kexec-module-added-to-emu.patch +++ /dev/null @@ -1,326 +0,0 @@ ---- - grub-core/Makefile.am | 1 - grub-core/Makefile.core.def | 2 - grub-core/kern/emu/main.c | 4 - grub-core/kern/emu/misc.c | 18 ++++ - grub-core/loader/emu/linux.c | 173 +++++++++++++++++++++++++++++++++++++++++++ - include/grub/emu/exec.h | 4 - include/grub/emu/hostfile.h | 3 - include/grub/emu/misc.h | 3 - 8 files changed, 204 insertions(+), 4 deletions(-) - ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1674,9 +1674,9 @@ module = { - arm = loader/arm/linux.c; - arm64 = loader/arm64/linux.c; - fdt = lib/fdt.c; -+ emu = loader/emu/linux.c; - common = loader/linux.c; - common = lib/cmdline.c; -- enable = noemu; - }; - - module = { ---- /dev/null -+++ b/grub-core/loader/emu/linux.c -@@ -0,0 +1,173 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+GRUB_MOD_LICENSE ("GPLv3+"); -+ -+static grub_dl_t my_mod; -+ -+static char *kernel_path; -+static char *initrd_path; -+static char *boot_cmdline; -+ -+static grub_err_t -+grub_linux_boot (void) -+{ -+ grub_err_t rc = GRUB_ERR_NONE; -+ char *initrd_param; -+ const char *kexec[] = { "kexec", "-l", kernel_path, boot_cmdline, NULL, NULL }; -+ const char *systemctl[] = { "systemctl", "kexec", NULL }; -+ int kexecute = grub_util_get_kexecute(); -+ -+ if (initrd_path) { -+ initrd_param = grub_xasprintf("--initrd=%s", initrd_path); -+ kexec[3] = initrd_param; -+ kexec[4] = boot_cmdline; -+ } else { -+ initrd_param = grub_xasprintf("%s", ""); -+ //return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("initrd required!")); -+ } -+ -+ grub_printf("%serforming 'kexec -l %s %s %s'\n", -+ (kexecute) ? "P" : "Not p", -+ kernel_path, initrd_param, boot_cmdline); -+ -+ if (kexecute) -+ rc = grub_util_exec(kexec); -+ -+ grub_free(initrd_param); -+ -+ if (rc != GRUB_ERR_NONE) { -+ grub_error (rc, N_("Error trying to perform kexec load operation.")); -+ grub_sleep (3); -+ return rc; -+ } -+ if (kexecute < 1) -+ grub_fatal (N_("Use '"PACKAGE"-emu --kexec' to force a system restart.")); -+ -+ grub_printf("Performing 'systemctl kexec' (%s) ", -+ (kexecute==1) ? "do-or-die" : "just-in-case"); -+ rc = grub_util_exec (systemctl); -+ -+ if (kexecute == 1) -+ grub_fatal (N_("Error trying to perform 'systemctl kexec'")); -+ -+ /* need to check read-only root before resetting hard!? */ -+ grub_printf("Performing 'kexec -e'"); -+ kexec[1] = "-e"; -+ kexec[2] = NULL; -+ rc = grub_util_exec(kexec); -+ if ( rc != GRUB_ERR_NONE ) -+ grub_fatal (N_("Error trying to directly perform 'kexec -e'.")); -+ -+ return rc; -+} -+ -+static grub_err_t -+grub_linux_unload (void) -+{ -+ grub_dl_unref (my_mod); -+ if ( boot_cmdline != NULL ) -+ grub_free (boot_cmdline); -+ boot_cmdline = NULL; -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) -+{ -+ int i; -+ char *tempstr; -+ -+ grub_dl_ref (my_mod); -+ -+ if (argc == 0) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -+ -+ if ( !grub_util_is_regular(argv[0]) ) -+ return grub_error(GRUB_ERR_FILE_NOT_FOUND, N_("Cannot find kernel file %s"), argv[0]); -+ -+ if ( kernel_path != NULL ) -+ grub_free(kernel_path); -+ -+ kernel_path = grub_xasprintf("%s", argv[0]); -+ -+ if ( boot_cmdline != NULL ) { -+ grub_free(boot_cmdline); -+ boot_cmdline = NULL; -+ } -+ -+ if ( argc > 1 ) -+ { -+ boot_cmdline = grub_xasprintf("--command-line=%s", argv[1]); -+ for ( i = 2; i < argc; i++ ) { -+ tempstr = grub_xasprintf("%s %s", boot_cmdline, argv[i]); -+ grub_free(boot_cmdline); -+ boot_cmdline = tempstr; -+ } -+ } -+ -+ grub_loader_set (grub_linux_boot, grub_linux_unload, 0); -+ -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) -+{ -+ if (argc == 0) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -+ -+ if ( !grub_util_is_regular(argv[0]) ) -+ return grub_error(GRUB_ERR_FILE_NOT_FOUND, N_("Cannot find initrd file %s"), argv[0]); -+ -+ if ( initrd_path != NULL ) -+ grub_free(initrd_path); -+ -+ initrd_path = grub_xasprintf("%s", argv[0]); -+ -+ grub_dl_unref (my_mod); -+ -+ return GRUB_ERR_NONE; -+} -+ -+static grub_command_t cmd_linux, cmd_initrd; -+ -+GRUB_MOD_INIT(linux) -+{ -+ cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, N_("Load Linux.")); -+ cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, N_("Load initrd.")); -+ my_mod = mod; -+ kernel_path = NULL; -+ initrd_path = NULL; -+ boot_cmdline = NULL; -+} -+ -+GRUB_MOD_FINI(linux) -+{ -+ grub_unregister_command (cmd_linux); -+ grub_unregister_command (cmd_initrd); -+} ---- a/include/grub/emu/hostfile.h -+++ b/include/grub/emu/hostfile.h -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - #include - - int -@@ -29,7 +30,7 @@ grub_util_is_directory (const char *path - int - grub_util_is_special_file (const char *path); - int --grub_util_is_regular (const char *path); -+EXPORT_FUNC(grub_util_is_regular) (const char *path); - - char * - grub_util_path_concat (size_t n, ...); ---- a/include/grub/emu/exec.h -+++ b/include/grub/emu/exec.h -@@ -23,6 +23,8 @@ - #include - - #include -+#include -+ - pid_t - grub_util_exec_pipe (const char *const *argv, int *fd); - pid_t -@@ -32,7 +34,7 @@ int - grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, - const char *stdout_file, const char *stderr_file); - int --grub_util_exec (const char *const *argv); -+EXPORT_FUNC(grub_util_exec) (const char *const *argv); - int - grub_util_exec_redirect (const char *const *argv, const char *stdin_file, - const char *stdout_file); ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -243,6 +243,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/inc - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostfile.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/exec.h - if COND_GRUB_EMU_SDL - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h - endif ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -95,6 +95,7 @@ static struct argp_option options[] = { - N_("use GRUB files in the directory DIR [default=%s]"), 0}, - {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, - {"hold", 'H', N_("SECS"), OPTION_ARG_OPTIONAL, N_("wait until a debugger will attach"), 0}, -+ {"kexec", 'X', 0, 0, N_("try the untryable."), 0}, - { 0, 0, 0, 0, 0, 0 } - }; - -@@ -148,6 +149,9 @@ argp_parser (int key, char *arg, struct - case 'v': - verbosity++; - break; -+ case 'X': -+ grub_util_set_kexecute(); -+ break; - - case ARGP_KEY_ARG: - { ---- a/grub-core/kern/emu/misc.c -+++ b/grub-core/kern/emu/misc.c -@@ -38,6 +38,7 @@ - #include - - int verbosity; -+int kexecute; - - void - grub_util_warn (const char *fmt, ...) -@@ -81,7 +82,7 @@ grub_util_error (const char *fmt, ...) - vfprintf (stderr, fmt, ap); - va_end (ap); - fprintf (stderr, ".\n"); -- exit (1); -+ grub_exit (); - } - - void * -@@ -138,6 +139,9 @@ xasprintf (const char *fmt, ...) - void - grub_exit (void) - { -+#if defined (GRUB_KERNEL) -+ grub_reboot(); -+#endif - exit (1); - } - -@@ -150,3 +154,15 @@ grub_get_time_ms (void) - - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); - } -+ -+void -+grub_util_set_kexecute(void) -+{ -+ kexecute++; -+} -+ -+int -+grub_util_get_kexecute(void) -+{ -+ return kexecute; -+} ---- a/include/grub/emu/misc.h -+++ b/include/grub/emu/misc.h -@@ -59,6 +59,9 @@ void EXPORT_FUNC(grub_util_warn) (const - void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); - void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2), noreturn)); - -+void EXPORT_FUNC(grub_util_set_kexecute) (void); -+int EXPORT_FUNC(grub_util_get_kexecute) (void) WARN_UNUSED_RESULT; -+ - grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void); - - extern char * canonicalize_file_name (const char *path); diff --git a/grub2-s390x-03-output-7-bit-ascii.patch b/grub2-s390x-03-output-7-bit-ascii.patch deleted file mode 100644 index dbe4cda..0000000 --- a/grub2-s390x-03-output-7-bit-ascii.patch +++ /dev/null @@ -1,516 +0,0 @@ ---- - grub-core/kern/emu/main.c | 8 + - grub-core/normal/menu_text.c | 54 ++++++++ - grub-core/normal/term.c | 2 - grub-core/osdep/unix/emuconsole.c | 231 +++++++++++++++++++++++++++++++++++++- - include/grub/term.h | 4 - 5 files changed, 287 insertions(+), 12 deletions(-) - ---- a/grub-core/osdep/unix/emuconsole.c -+++ b/grub-core/osdep/unix/emuconsole.c -@@ -39,17 +39,61 @@ - - #include - -+#include -+#include -+ - extern struct grub_terminfo_output_state grub_console_terminfo_output; - static int original_fl; - static int saved_orig; - static struct termios orig_tty; - static struct termios new_tty; -+static int console_mode = 0; -+ -+#define MAX_LEN 1023 -+#if defined(__s390x__) -+static int -+dummy (void) -+{ -+ return 0; -+} -+#endif -+#if 0 -+static char msg[MAX_LEN+1]; -+static void -+dprint (int len) -+{ -+ if (len < 0) -+ return; -+ if (len > MAX_LEN) -+ len = MAX_LEN; -+ write (2, msg, len); -+} -+#define dprintf(fmt, vargs...) dprint(snprintf(msg, MAX_LEN, fmt, ## vargs)) -+#else -+#define dprintf(fmt, vargs...) {} -+#endif - - static void --put (struct grub_term_output *term __attribute__ ((unused)), const int c) -+put (struct grub_term_output *term, const int c) - { - char chr = c; - ssize_t actual; -+ struct grub_terminfo_output_state *data -+ = (struct grub_terminfo_output_state *) term->data; -+ -+ if (term->flags & GRUB_TERM_DUMB) { -+ if (c == '\n') { -+ data->pos.y++; -+ data->pos.x = 0; -+ } else { -+ data->pos.x++; -+ } -+ if (0) { -+ if (c == ' ') chr = '_'; -+ if (c == GRUB_TERM_BACKSPACE) chr = '{'; -+ if (c == '\b') chr = '<'; -+ } -+ } - - actual = write (STDOUT_FILENO, &chr, 1); - if (actual < 1) -@@ -60,17 +104,147 @@ put (struct grub_term_output *term __att - } - - static int --readkey (struct grub_term_input *term __attribute__ ((unused))) -+readkey (struct grub_term_input *term) - { - grub_uint8_t c; - ssize_t actual; - -+ fd_set readfds; -+ struct timeval timeout; -+ int sel; -+ FD_SET (0, &readfds); -+ timeout.tv_sec = 0; -+ timeout.tv_usec = 500000; -+ if ((sel=select (1, &readfds, (fd_set *)0, (fd_set *)0, &timeout)) <= 0) -+ { -+ if (sel < 0 && errno == EINTR) -+ return 0x03; /* '^C' */ -+ return -1; -+ } -+ - actual = read (STDIN_FILENO, &c, 1); - if (actual > 0) - return c; - return -1; - } - -+static int -+readkey_dumb (struct grub_term_input *term) -+{ -+ grub_uint8_t c; -+ static grub_uint8_t p = 0; -+ -+ c = readkey (term); -+ if (c == (grub_uint8_t)-1) -+ return -1; -+ if (p == '^' && c == '\n') /* solitary '^': use it! */ -+ { -+ grub_uint8_t t = p; -+ p = c; -+ return t; -+ } -+ if ((c == '\n' || c == '^') && p != c) -+ { -+ p = c; -+ return -1; -+ } -+ if (p == '^' && c != '^') -+ c &= 0x1F; -+ p = c; -+ return c; -+} -+ -+static void -+grub_dumb_putchar (struct grub_term_output *term, -+ const struct grub_unicode_glyph *c) -+{ -+ unsigned i; -+ -+ /* For now, do not try to use a surrogate pair. */ -+ if (c->base > 0xffff) -+ put (term, '?'); -+ else -+ put (term, (c->base & 0xffff)); -+ -+ if (0) { -+ for (i = 0; i < c->ncomb; i++) -+ if (c->base < 0xffff) -+ put (term, grub_unicode_get_comb (c)[i].code); -+ } -+} -+ -+static struct grub_term_coordinate -+grub_dumb_getxy (struct grub_term_output *term) -+{ -+ struct grub_terminfo_output_state *data -+ = (struct grub_terminfo_output_state *) term->data; -+ -+ dprintf ("<%d,%d>", data->pos.x, data->pos.y); -+ return data->pos; -+} -+ -+static struct grub_term_coordinate -+grub_dumb_getwh (struct grub_term_output *term) -+{ -+ static int once = 0; -+ struct grub_terminfo_output_state *data -+ = (struct grub_terminfo_output_state *) term->data; -+ -+ if (!once++) -+ dprintf ("dumb_getwh: w=%d h=%d\n", data->size.x, data->size.y); -+ return data->size; -+} -+ -+static void -+grub_dumb_gotoxy (struct grub_term_output *term, -+ struct grub_term_coordinate pos) -+{ -+ struct grub_terminfo_output_state *data -+ = (struct grub_terminfo_output_state *) term->data; -+ -+ if (pos.x > grub_term_width (term) || pos.y > grub_term_height (term)) -+ { -+ grub_error (GRUB_ERR_BUG, "invalid point (%u,%u)", pos.x, pos.y); -+ return; -+ } -+ -+ dprintf("goto(%d,%d)", pos.x, pos.y); -+ if (pos.x > (grub_term_width (term) - 4)) { -+ dprintf (" really?"); -+ //return; -+ } -+ -+ if (data->gotoxy) -+ { -+ int i; -+ dprintf ("data-gotoxy"); -+ if (data->pos.y != pos.y) { -+ put (term, '\n'); -+ -+ for (i = 1; i < pos.x; i++ ) -+ put (term, ' '); -+ } -+ } -+ else -+ { -+ int i = 0; -+ if (data->pos.y != pos.y || data->pos.x > pos.x) { -+ if (data->pos.y >= pos.y) data->pos.y = pos.y - 1; -+ if (pos.y - data->pos.y > 3) data->pos.y = pos.y - 2; -+ dprintf (" <%dnl>+%d", (pos.y - data->pos.y), pos.x); -+ for (i = data->pos.y; i < pos.y; i++ ) -+ put (term, '\n'); -+ } -+ for (i = data->pos.x; i < pos.x; i++ ) -+ put (term, ' '); -+ dprintf ("#%d", i); -+ grub_dumb_getxy (term); -+ } -+ -+ dprintf ("\n"); -+ data->pos = pos; -+} -+ - static grub_err_t - grub_console_init_input (struct grub_term_input *term) - { -@@ -105,7 +279,8 @@ static grub_err_t - grub_console_init_output (struct grub_term_output *term) - { - struct winsize size; -- if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &size) >= 0) -+ if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &size) >= 0 && -+ size.ws_col > 0 && size.ws_row > 0) - { - grub_console_terminfo_output.size.x = size.ws_col; - grub_console_terminfo_output.size.y = size.ws_row; -@@ -115,6 +290,8 @@ grub_console_init_output (struct grub_te - grub_console_terminfo_output.size.x = 80; - grub_console_terminfo_output.size.y = 24; - } -+ if (console_mode == 3215) -+ grub_console_terminfo_output.size.x -= 1; - - grub_terminfo_output_init (term); - -@@ -161,24 +338,70 @@ static struct grub_term_output grub_cons - void - grub_console_init (void) - { -+#if ! defined(__s390x__) - const char *cs = nl_langinfo (CODESET); - if (cs && grub_strcasecmp (cs, "UTF-8")) - grub_console_term_output.flags = GRUB_TERM_CODE_TYPE_UTF8_LOGICAL; - else - grub_console_term_output.flags = GRUB_TERM_CODE_TYPE_ASCII; -+#else -+ char link[MAX_LEN+1]; -+ ssize_t len = readlink ("/proc/self/fd/0", link, MAX_LEN); -+ -+ if (len > 0) -+ link[len] = 0; -+ else -+ link[0] = 0; -+ if (grub_strncmp ("/dev/ttyS", link, 9) == 0 ) -+ console_mode = 3215; -+ if (grub_strncmp ("/dev/3270/tty", link, 13) == 0 ) -+ console_mode = 3270; -+ grub_console_term_output.flags = GRUB_TERM_CODE_TYPE_ASCII; -+ switch (console_mode) -+ { -+ case 3215: -+ grub_console_term_output.flags |= GRUB_TERM_DUMB; -+ /* FALLTHROUGH */ -+ case 3270: -+ grub_console_term_output.flags |= GRUB_TERM_LINE; -+ grub_console_term_output.flags |= GRUB_TERM_NO_ECHO; -+ grub_console_terminfo_input.readkey = readkey_dumb; -+ break; -+ default: -+ break; -+ } -+#endif -+ if (grub_console_term_output.flags & GRUB_TERM_DUMB) -+ { -+ grub_console_term_output.putchar = grub_dumb_putchar, -+ grub_console_term_output.getxy = grub_dumb_getxy; -+ grub_console_term_output.getwh = grub_dumb_getwh; -+ grub_console_term_output.gotoxy = grub_dumb_gotoxy; -+ grub_console_term_output.cls = (void *) dummy; -+ grub_console_term_output.setcolorstate = (void *) dummy; -+ grub_console_term_output.setcursor = (void *) dummy; -+ grub_console_term_output.progress_update_divisor = GRUB_PROGRESS_NO_UPDATE; -+ } - grub_term_register_input ("console", &grub_console_term_input); - grub_term_register_output ("console", &grub_console_term_output); - grub_terminfo_init (); -- grub_terminfo_output_register (&grub_console_term_output, "vt100-color"); -+ grub_terminfo_output_register (&grub_console_term_output, -+ (grub_console_term_output.flags & GRUB_TERM_DUMB) ? "dumb":"vt100-color"); - } - - void - grub_console_fini (void) - { -+ dprintf( "grub_console_fini: %d\n", grub_console_term_output.flags & GRUB_TERM_DUMB); - if (saved_orig) - { - fcntl (STDIN_FILENO, F_SETFL, original_fl); - tcsetattr(STDIN_FILENO, TCSANOW, &orig_tty); - } -+ if (!(grub_console_term_output.flags & GRUB_TERM_DUMB)) -+ { -+ const char clear[] = { 0x1b, 'c', 0 }; -+ write (STDOUT_FILENO, clear, 2); -+ } - saved_orig = 0; - } ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -113,6 +113,7 @@ draw_border (struct grub_term_output *te - { - int i; - -+ if (! (term->flags & GRUB_TERM_DUMB)) { - grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); - - grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1, -@@ -142,7 +143,7 @@ draw_border (struct grub_term_output *te - grub_putcode (GRUB_UNICODE_CORNER_LR, term); - - grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); -- -+ } - grub_term_gotoxy (term, - (struct grub_term_coordinate) { geo->first_entry_x - 1, - (geo->first_entry_y - 1 + geo->num_entries -@@ -155,6 +156,15 @@ print_message (int nested, int edit, str - int ret = 0; - grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); - -+ if (edit && (term->flags & GRUB_TERM_LINE)) -+ { -+ ret += grub_print_message_indented_real -+ (_("Minimum Emacs-like screen editing is supported. '^i' lists " -+ "completions. Type '^x' to boot, '^c' for a command-line " -+ "or '^[' to discard edits and return to the GRUB menu."), -+ STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); -+ } -+ else - if (edit) - { - ret += grub_print_message_indented_real (_("Minimum Emacs-like screen editing is \ -@@ -165,10 +175,15 @@ command-line or ESC to discard edits and - } - else - { -+#if defined(__s390x__hotkey) -+ ret += grub_print_message_indented_real -+ (_("Select a menu option by pressing the hotkey specified. "), -+ STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); -+#else - char *msg_translated; - - msg_translated = grub_xasprintf (_("Use the %C and %C keys to select which " -- "entry is highlighted."), -+ "entry is highlighted. "), - GRUB_UNICODE_UPARROW, - GRUB_UNICODE_DOWNARROW); - if (!msg_translated) -@@ -177,6 +192,7 @@ command-line or ESC to discard edits and - STANDARD_MARGIN, term, dry_run); - - grub_free (msg_translated); -+#endif - - if (nested) - { -@@ -211,6 +227,10 @@ print_entry (int y, int highlight, grub_ - - title = entry ? entry->title : ""; - title_len = grub_strlen (title); -+ -+ if ((data->term->flags & GRUB_TERM_DUMB) && title[0] == '\0') -+ return; -+ - unicode_title = grub_malloc (title_len * sizeof (*unicode_title)); - if (! unicode_title) - /* XXX How to show this error? */ -@@ -244,6 +264,14 @@ print_entry (int y, int highlight, grub_ - if (data->geo.num_entries > 1) - grub_putcode (highlight ? '*' : ' ', data->term); - -+ if ((data->term->flags & GRUB_TERM_DUMB) && title[0] != '\0') { -+ grub_putcode('(', data->term); -+ grub_putcode((entry && entry->hotkey >= '0' && entry->hotkey <= 'z') ? -+ entry->hotkey : ' ', data->term); -+ grub_putcode(')', data->term); -+ grub_putcode(' ', data->term); -+ } -+ - grub_print_ucs4_menu (unicode_title, - unicode_title + len, - 0, -@@ -413,6 +441,8 @@ grub_menu_init_page (int nested, int edi - grub_term_highlight_color = old_color_highlight; - geo->timeout_y = geo->first_entry_y + geo->num_entries - + geo->border + empty_lines; -+ if (term->flags & GRUB_TERM_DUMB) -+ geo->timeout_y = 1; - if (bottom_message) - { - grub_term_gotoxy (term, -@@ -422,6 +452,8 @@ grub_menu_init_page (int nested, int edi - print_message (nested, edit, term, 0); - geo->timeout_y += msg_num_lines; - } -+ if (term->flags & GRUB_TERM_DUMB) -+ geo->timeout_y = 1; - geo->right_margin = grub_term_width (term) - - geo->first_entry_x - - geo->entry_width - 1; -@@ -433,12 +465,19 @@ menu_text_print_timeout (int timeout, vo - struct menu_viewer_data *data = dataptr; - char *msg_translated = 0; - -- grub_term_gotoxy (data->term, -+ if (data->geo.timeout_y) -+ grub_term_gotoxy (data->term, - (struct grub_term_coordinate) { 0, data->geo.timeout_y }); - -+ if (data->term->flags & GRUB_TERM_DUMB) -+ { -+ if (! data->geo.timeout_y) -+ data->timeout_msg = TIMEOUT_TERSE; -+ data->geo.timeout_y = 0; -+ } - if (data->timeout_msg == TIMEOUT_TERSE - || data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN) -- msg_translated = grub_xasprintf (_("%ds"), timeout); -+ msg_translated = grub_xasprintf (_(" %ds"), timeout); - else - msg_translated = grub_xasprintf (_("The highlighted entry will be executed automatically in %ds."), timeout); - if (!msg_translated) -@@ -468,6 +507,8 @@ menu_text_print_timeout (int timeout, vo - data->term); - grub_free (msg_translated); - -+ if (data->term->flags & GRUB_TERM_DUMB) -+ return; - grub_term_gotoxy (data->term, - (struct grub_term_coordinate) { - grub_term_cursor_x (&data->geo), -@@ -495,7 +536,7 @@ menu_text_set_chosen_entry (int entry, v - data->first = entry; - complete_redraw = 1; - } -- if (complete_redraw) -+ if (complete_redraw || (data->term->flags & GRUB_TERM_DUMB)) - print_entries (data->menu, data); - else - { -@@ -525,6 +566,9 @@ menu_text_clear_timeout (void *dataptr) - struct menu_viewer_data *data = dataptr; - int i; - -+ if ((data->term->flags & GRUB_TERM_DUMB)) -+ return; -+ - for (i = 0; i < data->geo.timeout_lines;i++) - { - grub_term_gotoxy (data->term, (struct grub_term_coordinate) { ---- a/grub-core/normal/term.c -+++ b/grub-core/normal/term.c -@@ -981,7 +981,7 @@ grub_print_ucs4_menu (const grub_uint32_ - { - print_ucs4_real (str, last_position, margin_left, margin_right, - term, 0, 0, 1, skip_lines, max_lines, -- contchar, 1, pos); -+ contchar, (term->flags & GRUB_TERM_DUMB)? 0 : 1, pos); - } - - void ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -174,6 +174,12 @@ static struct argp argp = { - NULL, help_filter, NULL - }; - -+void -+ignore (int num __attribute__ ((unused))) -+{ -+ return; -+} -+ - - - #pragma GCC diagnostic ignored "-Wmissing-prototypes" -@@ -212,7 +218,7 @@ main (int argc, char *argv[]) - sleep (1); - } - -- signal (SIGINT, SIG_IGN); -+ signal (SIGINT, (sighandler_t) &ignore); - grub_console_init (); - grub_host_init (); - ---- a/include/grub/term.h -+++ b/include/grub/term.h -@@ -99,8 +99,10 @@ grub_term_color_state; - #define GRUB_TERM_NO_EDIT (1 << 1) - /* Set when the terminal cannot do fancy things. */ - #define GRUB_TERM_DUMB (1 << 2) -+/* Set when the terminal is line oriented. */ -+#define GRUB_TERM_LINE (1 << 3) - /* Which encoding does terminal expect stream to be. */ --#define GRUB_TERM_CODE_TYPE_SHIFT 3 -+#define GRUB_TERM_CODE_TYPE_SHIFT 4 - #define GRUB_TERM_CODE_TYPE_MASK (7 << GRUB_TERM_CODE_TYPE_SHIFT) - /* Only ASCII characters accepted. */ - #define GRUB_TERM_CODE_TYPE_ASCII (0 << GRUB_TERM_CODE_TYPE_SHIFT) diff --git a/grub2-s390x-04-grub2-install.patch b/grub2-s390x-04-grub2-install.patch deleted file mode 100644 index 7d54b9a..0000000 --- a/grub2-s390x-04-grub2-install.patch +++ /dev/null @@ -1,924 +0,0 @@ -From: Raymund Will -Subject: Allow s390x-emu to be "installed" -References: fate#314213, bnc#866867, bnc#868909 -Patch-Mainline: no - -V2: - * try harder to find root filesystem (incl. subvol-handling). - * read /etc/sysconfig/bootloader as final fallback. -V3: - * refresh initrd by default, prefer running kernel and - re-zipl despite minor issues. [bnc#866867, fate#314213] -V4: - * append 'quiet splash=silent' for 'initgrub'-boot. - * properly check for dracut script during 'grub2-install'. - * move 'zipl2grub.pl' to '/usr/sbin/grub2-zipl-setup'. -V5: - * actually call 'grub2-zipl-setup' from 'grub2-install'. - * handle 'GRUB{,_EMU}_CONMODE'. [bnc#868909] - ---- - Makefile.util.def | 39 +++ - configure.ac | 9 - grub-core/Makefile.core.def | 7 - grub-core/osdep/basic/no_platform.c | 7 - grub-core/osdep/unix/platform.c | 11 + - grub-core/osdep/windows/platform.c | 6 - include/grub/util/install.h | 4 - util/grub-install-common.c | 1 - util/grub-install.c | 43 +++ - util/s390x/dracut-grub2.sh.in | 69 ++++++ - util/s390x/dracut-module-setup.sh.in | 17 + - util/s390x/zipl2grub.conf.in | 26 ++ - util/s390x/zipl2grub.pl.in | 379 +++++++++++++++++++++++++++++++++++ - 13 files changed, 614 insertions(+), 4 deletions(-) - ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -350,6 +350,7 @@ program = { - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - cppflags = '-DGRUB_SETUP_FUNC=grub_util_bios_setup'; -+ emu_condition = COND_NOT_s390x; - }; - - program = { -@@ -370,6 +371,7 @@ program = { - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - cppflags = '-DGRUB_SETUP_FUNC=grub_util_sparc_setup'; -+ emu_condition = COND_NOT_s390x; - }; - - program = { -@@ -385,6 +387,7 @@ program = { - ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBGEOM)'; -+ emu_condition = COND_NOT_s390x; - }; - - program = { -@@ -415,6 +418,7 @@ program = { - ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; -+ emu_condition = COND_NOT_s390x; - }; - - data = { -@@ -620,7 +624,7 @@ program = { - common = grub-core/disk/host.c; - - common = util/resolve.c; -- enable = noemu; -+ emu_condition = COND_s390x; - common = grub-core/kern/emu/argp_common.c; - common = grub-core/osdep/init.c; - -@@ -688,6 +692,38 @@ script = { - }; - - script = { -+ name = grub-zipl-setup; -+ installdir = sbin; -+ common = util/s390x/zipl2grub.pl.in; -+ enable = emu; -+ emu_condition = COND_s390x; -+}; -+ -+data = { -+ name = zipl2grub.conf.in; -+ common = util/s390x/zipl2grub.conf.in; -+ installdir = grubconf; -+ enable = emu; -+ emu_condition = COND_s390x; -+}; -+ -+script = { -+ name = dracut-module-setup.sh; -+ common = util/s390x/dracut-module-setup.sh.in; -+ enable = emu; -+ emu_condition = COND_s390x; -+ installdir = platform; -+}; -+ -+script = { -+ name = dracut-grub.sh; -+ common = util/s390x/dracut-grub2.sh.in; -+ enable = emu; -+ emu_condition = COND_s390x; -+ installdir = platform; -+}; -+ -+script = { - name = grub-mkconfig_lib; - common = util/grub-mkconfig_lib.in; - installdir = noinst; -@@ -1281,6 +1317,7 @@ program = { - ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; -+ emu_condition = COND_NOT_s390x; - }; - - program = { ---- a/configure.ac -+++ b/configure.ac -@@ -177,9 +177,9 @@ if test x$platform != xemu ; then - esac - fi - --if test x"$target_cpu-$platform" = xsparc64-emu ; then -- target_m64=1 ; --fi -+case x"$target_cpu-$platform" in -+ xsparc64-emu | xs390x-emu) target_m64=1 ;; -+esac - - case "$target_os" in - windows* | mingw32*) target_os=cygwin ;; -@@ -1665,6 +1665,9 @@ AM_CONDITIONAL([COND_arm_uboot], [test x - AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi]) - AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) - AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) -+AM_CONDITIONAL([COND_s390x], [test x$target_cpu = xs390x ]) -+AM_CONDITIONAL([COND_NOT_s390x], [test x$target_cpu != xs390x ]) -+AM_CONDITIONAL([COND_s390x_emu], [test x$target_cpu = xs390x -a x$platform = xemu]) - - AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd]) - AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux]) ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1064,6 +1064,7 @@ module = { - module = { - name = videotest; - common = commands/videotest.c; -+ emu_condition = COND_NOT_s390x; - }; - - module = { -@@ -1477,6 +1478,7 @@ module = { - common = gfxmenu/gui_progress_bar.c; - common = gfxmenu/gui_util.c; - common = gfxmenu/gui_string_util.c; -+ emu_condition = COND_NOT_s390x; - }; - - module = { -@@ -1856,11 +1858,13 @@ module = { - name = gfxterm; - common = term/gfxterm.c; - enable = videomodules; -+ emu_condition = COND_NOT_s390x; - }; - - module = { - name = gfxterm_background; - common = term/gfxterm_background.c; -+ emu_condition = COND_NOT_s390x; - }; - - module = { -@@ -1975,6 +1979,7 @@ module = { - enable = x86_64_efi; - enable = emu; - enable = xen; -+ emu_condition = COND_NOT_s390x; - }; - - module = { -@@ -1990,6 +1995,7 @@ module = { - module = { - name = gfxterm_menu; - common = tests/gfxterm_menu.c; -+ emu_condition = COND_NOT_s390x; - }; - - module = { -@@ -2142,6 +2148,7 @@ module = { - enable = x86_64_efi; - enable = emu; - enable = xen; -+ emu_condition = COND_NOT_s390x; - }; - - module = { ---- a/grub-core/osdep/basic/no_platform.c -+++ b/grub-core/osdep/basic/no_platform.c -@@ -44,3 +44,10 @@ grub_install_sgi_setup (const char *inst - { - grub_util_error ("%s", _("no SGI routines are available for your platform")); - } -+ -+void -+grub_install_zipl (const char *d, int i, int f) -+{ -+ grub_util_error ("%s", _("no zIPL routines are available for your platform")); -+} -+ ---- a/grub-core/osdep/unix/platform.c -+++ b/grub-core/osdep/unix/platform.c -@@ -233,3 +233,14 @@ grub_install_sgi_setup (const char *inst - imgfile, destname, NULL }); - grub_util_warn ("%s", _("You will have to set `SystemPartition' and `OSLoader' manually.")); - } -+ -+void -+grub_install_zipl (const char *dest, int install, int force) -+{ -+ if (grub_util_exec ((const char * []){ PACKAGE"-zipl-setup", -+ verbosity ? "-v" : "", -+ install ? "" : "--debug", -+ !force ? "" : "--force", -+ "-z", dest, NULL })) -+ grub_util_error (_("`%s' failed.\n"), PACKAGE"-zipl-setup"); -+} ---- a/grub-core/osdep/windows/platform.c -+++ b/grub-core/osdep/windows/platform.c -@@ -422,3 +422,9 @@ grub_install_sgi_setup (const char *inst - { - grub_util_error ("%s", _("no SGI routines are available for your platform")); - } -+ -+void -+grub_install_zipl (const char *d, int i, int f) -+{ -+ grub_util_error ("%s", _("no zIPL routines are available for your platform")); -+} ---- a/include/grub/util/install.h -+++ b/include/grub/util/install.h -@@ -99,6 +99,7 @@ enum grub_install_plat - GRUB_INSTALL_PLATFORM_I386_XEN, - GRUB_INSTALL_PLATFORM_X86_64_XEN, - GRUB_INSTALL_PLATFORM_ARM64_EFI, -+ GRUB_INSTALL_PLATFORM_S390X_EMU, - GRUB_INSTALL_PLATFORM_MAX - }; - -@@ -217,6 +218,9 @@ void - grub_install_sgi_setup (const char *install_device, - const char *imgfile, const char *destname); - -+void -+grub_install_zipl (const char *d, int i, int f); -+ - int - grub_install_compress_gzip (const char *src, const char *dest); - int ---- a/util/grub-install-common.c -+++ b/util/grub-install-common.c -@@ -665,6 +665,7 @@ static struct - [GRUB_INSTALL_PLATFORM_ARM_EFI] = { "arm", "efi" }, - [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64", "efi" }, - [GRUB_INSTALL_PLATFORM_ARM_UBOOT] = { "arm", "uboot" }, -+ [GRUB_INSTALL_PLATFORM_S390X_EMU] = { "s390x", "emu" }, - }; - - char * ---- a/util/grub-install.c -+++ b/util/grub-install.c -@@ -66,6 +66,7 @@ static int force_file_id = 0; - static char *disk_module = NULL; - static char *efidir = NULL; - static char *macppcdir = NULL; -+static char *zipldir = NULL; - static int force = 0; - static int have_abstractions = 0; - static int have_cryptodisk = 0; -@@ -107,6 +108,7 @@ enum - OPTION_NO_BOOTSECTOR, - OPTION_NO_RS_CODES, - OPTION_MACPPC_DIRECTORY, -+ OPTION_ZIPL_DIRECTORY, - OPTION_LABEL_FONT, - OPTION_LABEL_COLOR, - OPTION_LABEL_BGCOLOR, -@@ -182,6 +184,11 @@ argp_parser (int key, char *arg, struct - efidir = xstrdup (arg); - return 0; - -+ case OPTION_ZIPL_DIRECTORY: -+ free (zipldir); -+ zipldir = xstrdup (arg); -+ return 0; -+ - case OPTION_DISK_MODULE: - free (disk_module); - disk_module = xstrdup (arg); -@@ -299,6 +306,8 @@ static struct argp_option options[] = { - N_("use DIR as the EFI System Partition root."), 2}, - {"macppc-directory", OPTION_MACPPC_DIRECTORY, N_("DIR"), 0, - N_("use DIR for PPC MAC install."), 2}, -+ {"zipl-directory", OPTION_ZIPL_DIRECTORY, N_("DIR"), 0, -+ N_("use DIR as the zIPL Boot Partition root."), 2}, - {"label-font", OPTION_LABEL_FONT, N_("FILE"), 0, N_("use FILE as font for label"), 2}, - {"label-color", OPTION_LABEL_COLOR, N_("COLOR"), 0, N_("use COLOR for label"), 2}, - {"label-bgcolor", OPTION_LABEL_BGCOLOR, N_("COLOR"), 0, N_("use COLOR for label background"), 2}, -@@ -325,6 +334,8 @@ get_default_platform (void) - return "arm64-efi"; - #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__) - return grub_install_get_default_x86_platform (); -+#elif defined (__s390x__) -+ return "s390x-emu"; - #else - return NULL; - #endif -@@ -484,6 +495,8 @@ have_bootdev (enum grub_install_plat pl) - - case GRUB_INSTALL_PLATFORM_I386_XEN: - case GRUB_INSTALL_PLATFORM_X86_64_XEN: -+ -+ case GRUB_INSTALL_PLATFORM_S390X_EMU: - return 0; - - /* pacify warning. */ -@@ -895,6 +908,7 @@ main (int argc, char *argv[]) - case GRUB_INSTALL_PLATFORM_ARM_UBOOT: - case GRUB_INSTALL_PLATFORM_I386_XEN: - case GRUB_INSTALL_PLATFORM_X86_64_XEN: -+ case GRUB_INSTALL_PLATFORM_S390X_EMU: - break; - - case GRUB_INSTALL_PLATFORM_I386_QEMU: -@@ -940,6 +954,7 @@ main (int argc, char *argv[]) - case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: - case GRUB_INSTALL_PLATFORM_I386_XEN: - case GRUB_INSTALL_PLATFORM_X86_64_XEN: -+ case GRUB_INSTALL_PLATFORM_S390X_EMU: - free (install_device); - install_device = NULL; - break; -@@ -1201,6 +1216,20 @@ main (int argc, char *argv[]) - } - } - -+ if (platform == GRUB_INSTALL_PLATFORM_S390X_EMU) -+ { -+ if (!zipldir) -+ { -+ char *d = grub_util_path_concat (2, bootdir, "zipl"); -+ if (!grub_util_is_directory (d)) -+ { -+ free (d); -+ grub_util_error ("%s", _("cannot find zIPL directory")); -+ } -+ zipldir = d; -+ } -+ } -+ - grub_install_copy_files (grub_install_source_directory, - grubdir, platform); - -@@ -1445,6 +1474,7 @@ main (int argc, char *argv[]) - case GRUB_INSTALL_PLATFORM_ARM_UBOOT: - case GRUB_INSTALL_PLATFORM_I386_XEN: - case GRUB_INSTALL_PLATFORM_X86_64_XEN: -+ case GRUB_INSTALL_PLATFORM_S390X_EMU: - grub_util_warn ("%s", _("no hints available for your platform. Expect reduced performance")); - break; - /* pacify warning. */ -@@ -1557,6 +1587,10 @@ main (int argc, char *argv[]) - strcpy (mkimage_target, "sparc64-ieee1275-raw"); - core_name = "core.img"; - break; -+ case GRUB_INSTALL_PLATFORM_S390X_EMU: -+ strcpy (mkimage_target, "grub2-emu"); -+ core_name = mkimage_target; -+ break; - /* pacify warning. */ - case GRUB_INSTALL_PLATFORM_MAX: - break; -@@ -1572,6 +1606,7 @@ main (int argc, char *argv[]) - core_name); - char *prefix = xasprintf ("%s%s", prefix_drive ? : "", - relative_grubdir); -+ if (core_name != mkimage_target) - grub_install_make_image_wrap (/* source dir */ grub_install_source_directory, - /*prefix */ prefix, - /* output */ imgfile, -@@ -1610,6 +1645,10 @@ main (int argc, char *argv[]) - /* image target */ mkimage_target, 0); - } - break; -+ -+ case GRUB_INSTALL_PLATFORM_S390X_EMU: -+ break; -+ - case GRUB_INSTALL_PLATFORM_ARM_EFI: - case GRUB_INSTALL_PLATFORM_ARM64_EFI: - case GRUB_INSTALL_PLATFORM_IA64_EFI: -@@ -1871,6 +1910,10 @@ main (int argc, char *argv[]) - } - break; - -+ case GRUB_INSTALL_PLATFORM_S390X_EMU: -+ grub_install_zipl (zipldir, install_bootsector, force); -+ break; -+ - case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON: - case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: - case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: ---- /dev/null -+++ b/util/s390x/dracut-grub2.sh.in -@@ -0,0 +1,69 @@ -+#!/bin/sh -+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -+# ex: ts=8 sw=4 sts=4 et filetype=sh -+#getargbool() { true; } -+ -+if getargbool 0 initgrub && [ ! -e /grub2skip ] || [ -e /grub2force ]; then -+ #type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh -+ checkro() { -+ local dev mp fs opts dc -+ local rofs=false -+ while read dev mp fs opts dc; do -+ [ "$mp" = "/sysroot" ] || continue -+ case ",$opts," in -+ (*,ro,*) rofs=true;; -+ esac -+ done < /proc/mounts -+ echo $rofs -+ } -+ checkd() { -+ [ -d $1 ] && echo true || echo false -+ } -+ getterm() { -+ local term="$(getarg TERM)" -+ [ -z "$term" ] && term=dumb -+ echo $term -+ } -+ -+ exec_prefix=@exec_prefix@ -+ bindir=@bindir@ -+ if [ -e /sysroot$bindir/grub2-emu ]; then -+ -+ -+ export TERM=$(getterm) -+ export grub2rofs=$(checkro) -+ export grub2sysfs=$(checkd /sysroot/sys/kernel) -+ export grub2procfs=$(checkd /sysroot/proc/slef) -+ export -p > /tmp/grub2env -+ cat /proc/mounts > /tmp/grub2mounts -+ -+ _ctty="$(RD_DEBUG= getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}" -+ if [ -z "$_ctty" ]; then -+ _ctty=console -+ while [ -f /sys/class/tty/$_ctty/active ]; do -+ _ctty=$(cat /sys/class/tty/$_ctty/active) -+ _ctty=${_ctty##* } # last one in the list -+ done -+ _ctty=/dev/$_ctty -+ fi -+ [ -c "$_ctty" ] || _ctty=/dev/tty1 -+ case "$(/usr/bin/setsid --help 2>&1)" in *--ctty*) CTTY="--ctty";; esac -+ -+ CTTY="$CTTY --wait" -+ $grub2rofs || mount -o remount,ro /sysroot -+ $grub2sysfs || mount --bind {,/sysroot}/sys -+ $grub2procfs || mount --bind {,/sysroot}/proc -+ -+ info "Trying grub2emu (ro=$grub2rofs, TERM=$TERM)..." -+ setsid $CTTY -- chroot /sysroot $bindir/grub2-emu -X -X 0<>$_ctty 1>&0 2>&0 -+ if [ -e /grub2force ] && [ $(cat /sys/kernel/kexec_loaded) = 1 ]; then -+ systemctl kexec -+ fi -+ $grub2procfs || umount /sysroot/proc -+ $grub2sysfs || umount /sysroot/sys -+ $grub2rofs || mount -o remount,rw /sysroot -+ else -+ info "No $bindir/grub2-emu in /sysroot--trying to proceed without kexec..." -+ fi -+fi -+ ---- /dev/null -+++ b/util/s390x/dracut-module-setup.sh.in -@@ -0,0 +1,17 @@ -+#!/bin/bash -+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -+# ex: ts=8 sw=4 sts=4 et filetype=sh -+ -+# called by dracut -+check() { -+ local _arch=$(uname -m) -+ [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 -+ return 0 -+} -+ -+# called by dracut -+install() { -+ inst_hook cleanup 99 "$moddir/grub2.sh" -+ #inst_multiple grub2-emu kexec -+} -+ ---- /dev/null -+++ b/util/s390x/zipl2grub.conf.in -@@ -0,0 +1,26 @@ -+## This is the template for '@zipldir@/config' and is subject to -+## rpm's %config file handling in case of grub2-s390x-emu package update. -+ -+[defaultboot] -+defaultmenu = menu -+ -+[grub2] -+ target = @zipldir@ -+ ramdisk = @zipldir@/initrd,0x2000000 -+ image = @zipldir@/image -+ parameters = "root=@GRUB_DEVICE@ @GRUB_EMU_CONMODE@ @GRUB_CMDLINE_LINUX@ @GRUB_CMDLINE_LINUX_DEFAULT@ initgrub quiet splash=silent " -+ -+[skip-grub2] -+ target = @zipldir@ -+ ramdisk = @zipldir@/initrd,0x2000000 -+ image = @zipldir@/image -+ parameters = "root=@GRUB_DEVICE@ @GRUB_CONMODE@ @GRUB_CMDLINE_LINUX@ @GRUB_CMDLINE_LINUX_DEFAULT@ " -+ -+:menu -+ target = @zipldir@ -+ timeout = 16 -+ default = 1 -+ prompt = 1 -+ 1 = grub2 -+ 2 = skip-grub2 -+ ---- /dev/null -+++ b/util/s390x/zipl2grub.pl.in -@@ -0,0 +1,379 @@ -+#!/usr/bin/perl -+use strict; -+ -+my $C = $0; $C =~ s{^.*/}{}; -+ -+my $in = '@sysconfdir@/default/zipl2grub.conf.in'; -+my $default = '@sysconfdir@/default/grub'; -+my $fallback = '@sysconfdir@/zipl.conf'; -+my $sysconfbl = '@sysconfdir@/sysconfig/bootloader'; -+my $zipldir = ""; -+my $running = ""; -+my $refresh = 1; # needs to default to "on" until most bugs are shaken out! -+my $force = 0; -+my $verbose = 0; -+my $debug = 0; -+my $miss = 0; -+my $cfg = ""; -+my %C; -+ -+my %Mandatory = ( -+ GRUB_CMDLINE_LINUX_DEFAULT => 1, -+ GRUB_DEVICE => 1, -+); -+ -+sub Panic($$) { -+ printf( STDERR "%s", $_[1]); -+ exit( $_[0]); -+} -+sub Info($$) { -+ printf( STDERR "%s", $_[1]) if ($_[0] <= $verbose); -+} -+sub System(@) { -+ my (@C) =@_; -+ Info( 1, "+ " . join( " ", @C) . "\n"); -+ return 0 if ($debug); -+ system( @C); -+ if ($? == -1) { -+ Panic( $?, "$C[0]: Failed to execute: $!\n"); -+ } elsif ($? & 127) { -+ Panic( $?, sprintf( "$C[0]: Died with signal %d with%s coredump\n", -+ ($? & 127), ($? & 128) ? '' : 'out')); -+ } elsif ( $? >> 8 != 0 ) { -+ Panic( $?, "$C[0]: Failed\n"); -+ } -+ return( 0); -+} -+sub cp($$) { -+ my @C = ( "cp", "-p", $_[0], $_[1]); -+ System( @C); -+} -+sub rm($) { -+ return( 0) unless ( -l $_[0] || -e $_[0]); -+ Info( 2, "+ rm $_[0]\n"); -+ return 0 if ($debug); -+ unlink( $_[0]) || Panic( 1, "$C: unlink: $!.\n"); -+} -+sub mv($$) { -+ Info( 1, "+ mv $_[0] $_[1]\n"); -+ return 0 if ($debug); -+ rename($_[0], $_[1]) || Panic( 1, "$C: rename: $!.\n"); -+} -+sub ln($$) { -+ Info( 1, "+ ln -sf $_[0] $_[1]\n"); -+ return 0 if ($debug); -+ rm( $_[1]); -+ symlink($_[0], $_[1]) || Panic( 1, "$C: symlink: $!.\n"); -+} -+sub BootCopy($$$) { -+ my( $file, $dir, $tgt) = @_; -+ my $curr = "$dir/$tgt"; -+ my $prev = "$dir/$tgt.prev"; -+ Info(4, "Copy /boot/$file $dir $tgt\n"); -+ if ( -l $curr ) { -+ my $curf = readlink( $curr); -+ if ( $curf ne $file ) { -+ if ( -l $prev ) { -+ my $pref = readlink( $prev); -+ rm( $pref); -+ } -+ mv( $curr, $prev); -+ } -+ } -+ cp( "/boot/$file", "$dir/$file"); -+ ln( $file, $curr); -+} -+sub MkInitrd($$$) { -+ my( $initrd, $dir, $version) = @_; -+ my @C = ( "dracut", "--hostonly", "--force", "$dir/$initrd", $version); -+ System( @C); -+ ln( $initrd, "$dir/initrd"); -+} -+sub ChkInitrd($$) { -+ my( $dir, $initrd) = @_; -+ my $found = 0; -+ my $d = $dir; -+ my $pattern = qr{lib/dracut/hooks/cleanup/99-grub2.sh}; -+ my $show = "cleanup/99-grub2.sh"; -+ -+ return $found unless (-r "$dir/$initrd"); -+ -+ my $modinst = "/usr/lib/dracut/modules.d/99grub2/module-setup.sh"; -+ if ( -r $modinst ) { -+ my( $hook, $ord, $script); -+ my $pat = qr{^\s*inst_hook\s+(\S+)\s+([0-9]+)\s+\"\$moddir/(grub2\.sh)\"}; -+ open( IN, "< $modinst") || die; -+ while ( ) { -+ next unless ($_ =~ $pat); -+ $show = "$1/$2-$3"; -+ $pattern = qr{lib/dracut/hooks/$show}o; -+ last; -+ } -+ close( IN); -+ } -+ -+ Info( 3, "+ zcat $d/$initrd | cpio -it | grep '$show'\n"); -+ open( IN, "zcat $d/$initrd | cpio -it 2>/dev/null |") || -+ Panic( 1, "$C: cpio: $!.\n"); -+ while ( ) { -+ $found = 1 if ($_ =~ $pattern); -+ } -+ close( IN); -+ return $found; -+} -+ -+sub Usage($) { -+ my @cat = ("", -+ "Parameter error.", -+ "zIPL directory missing.", -+ "Configuration template missing.", -+ "Configuration template unreadable.", -+ "zIPL directory not accesible.", -+ "" -+ ); -+ my $msg = ""; -+ -+ $msg .= sprintf( "%s: %s\n", $C, $cat[$_[0]]) if ($_[0] > 0); -+ $msg .= "Usage: $C [-v] [-d] [-f] [-T template] [-z ZIPLDIR]\n"; -+ Panic( $_[0], $msg . "\n"); -+} -+ -+die if ($[ != 0); -+while ( $#ARGV >= 0 ) { -+ $_ = shift; -+ next if /^$/; -+ last if /^--$/; -+ (/^--verbose$/ || /^-v$/) && ($verbose++, next); -+ (/^--quiet$/ || /^-q$/) && ($verbose = 0, next); -+ (/^--debug$/ || /^-d$/) && ($debug = 1, $verbose++, next); -+ (/^--force$/ || /^-f$/) && ($force = $refresh = 1, next); -+ (/^--refresh$/ || /^-r$/) && ($refresh = 1, next); -+ (/^--keep$/ || /^-k$/) && ($refresh = 0, next); -+ (/^--?help/ || /^-h/) && (Usage(0)); -+ (/^--zipldir$/ || /^-z$/) && ($zipldir = shift || Usage(2), next); -+ (/^--template$/ || /^-T$/) && ($in = shift || Usage(3), next); -+ (/^-/) && (Usage(1)); -+ Usage(1); -+} -+Usage(4) if (! -r $in); -+ -+if ($zipldir) { -+ $C{zipldir} = $zipldir; # command-line wins -+} elsif ( exists( $C{zipldir}) ) { -+ $zipldir = $C{zipldir}; # otherwise fall back to config -+} else { -+ $zipldir = $C{zipldir} = "/boot/zipl"; # but don't proceed without... -+} -+Usage(5) if (! -d $zipldir); -+if ( $zipldir eq "/boot" ) { -+ Panic( 5, "$C: zIPL directory '/boot' not supported!\n"); -+} -+ -+if ( ! -r $default && ! -r $fallback && ! -r $sysconfbl ) { -+ Panic( 0, "$C: No configuration files found. Retry later!\n"); -+} -+if ( -r $default ) { -+ open( IN, "< $default") || die; -+ while ( ) { -+ chomp; -+ s{^\s*#.*$}{}; -+ next if m{^\s*$}; -+ s{x}{\x01xx\x01}g; -+ s{\\\"}{\x01x1\x01}g; -+ s{\\\'}{\x01x2\x01}g; -+ Info( 5, "<$_>\n"); -+ if ( m{^([^\s=]+)='([^']*)'\s*(?:#.*)?$} || -+ m{^([^\s=]+)="([^"]*)"\s*(?:#.*)?$} || -+ m{^([^\s=]+)=(\S*)\s*(?:#.*)?$} ) { -+ my ( $k, $v) = ($1, $2); -+ $v =~ s{\x01x2\x01}{\\'}g; -+ $v =~ s{\x01x1\x01}{\\"}g; -+ $v =~ s{\x01xx\x01}{x}g; -+ $C{$k} = $v; -+ next; -+ } -+ print( STDERR "$default:$.: parse error ignored.\n"); -+ } -+ close( IN); -+} -+ -+if ( ! exists( $C{GRUB_DEVICE}) && -+ (! exists( $C{GRUB_CMDLINE_LINUX_DEFAULT}) || -+ $C{GRUB_CMDLINE_LINUX_DEFAULT} eq "quiet splash=silent") && -+ -r $fallback ) { -+ # configuration incomplete, let's try fallback -+ open( IN, "< $fallback") || die; -+ my $section = ""; -+ while( ){ -+ if ( m{^\[([^\]]+)\]\s*$} ) { -+ $section = $1; -+ } -+ if ( $section eq "ipl" && -+ m{^\s*parameters\s*=\s*\"root=(\S+)(?:\s*|\s+([^\"]+))\"} ) { -+ $C{GRUB_DEVICE} = $1; -+ $C{GRUB_CMDLINE_LINUX_DEFAULT} = $2 if (defined($2) && $2 !~ m{^\s*$}); -+ last; -+ } -+ } -+ close( IN); -+ $default = $fallback; -+} -+if ( ! exists( $C{GRUB_DEVICE}) ) { -+ my( $dev, $uuid, $type, $subvol) = ("", "", "", ""); -+ chomp( $dev = qx{grub2-probe --target=device /}); -+ chomp( $uuid = qx{grub2-probe --device $dev --target=fs_uuid}); -+ $subvol =~ s{^/}{}; -+ if ($dev && $uuid) { -+ $C{GRUB_DEVICE} = "UUID=$uuid"; -+ chomp( $type = qx{stat -f --printf='%T' /}); -+ chomp( $subvol = qx{grub2-mkrelpath /}) if ( $type eq "btrfs" ); -+ $C{GRUB_DEVICE} .= " rootflags=subvol=$subvol" if ($subvol); -+ } -+} -+if ( ! exists( $C{GRUB_DEVICE}) && -r "/etc/fstab" ) { -+ my( $dev, $type); -+ open( IN, "< /etc/fstab") || die; -+ while ( ) { -+ next if ( m{^\s*#} ); -+ ($dev, $type) = (m{^(\S+)\s+/\s+(\S+)\s+\S+\s+\S+\s+\S+\s*(?:#.*)?$}); -+ last if (defined( $dev)); -+ } -+ close( IN); -+ $C{GRUB_DEVICE} = $dev; -+ # ToDo: is static 'subvol=@' good enough? -+ $C{GRUB_DEVICE} .= ' rootflags=subvol=@' if ($type eq "btrfs"); -+} -+if ( (! exists( $C{GRUB_CMDLINE_LINUX_DEFAULT}) || -+ $C{GRUB_CMDLINE_LINUX_DEFAULT} eq "quiet splash=silent") && -+ -r $sysconfbl) { -+ open( IN, "< $sysconfbl") || die; -+ while ( ) { -+ next if ( m{^\s*#} ); -+ if ( m{^DEFAULT_APPEND=".*"(?:\s*|\s+#.*)$} ) { -+ $C{GRUB_CMDLINE_LINUX_DEFAULT} = $1; -+ } -+ } -+ close( IN); -+} -+ -+if ( ! exists( $C{GRUB_DEVICE})) { -+ Panic( 0, "$C: Default not ready and no fallback. Please retry later!\n"); -+} -+ -+if ( ! exists( $C{GRUB_EMU_CONMODE}) && exists( $C{GRUB_CONMODE}) ) { -+ # GRUB_CONMODE is used for 'grub2-emu' as well -+ $C{GRUB_EMU_CONMODE} = $C{GRUB_CONMODE}; -+} -+if ( exists( $C{GRUB_EMU_CONMODE}) && !exists( $C{GRUB_CONMODE}) ) { -+ # pick up 'conmode=' from CMDLINE -+ my $found = ""; -+ foreach ( "GRUB_CMDLINE_LINUX", "GRUB_CMDLINE_LINUX_DEFAULT" ) { -+ next unless ($C{$_} =~ m{ ?conmode=(\S+) ?}); -+ $C{GRUB_CONMODE} = $1; -+ last; -+ } -+ if ( !exists( $C{GRUB_CONMODE}) && $C{GRUB_EMU_CONMODE} eq "3270" ) { -+ # force GRUB_CONMODE to 3215 for least surprise -+ $C{GRUB_CONMODE}="3215"; -+ } -+} -+if ( exists( $C{GRUB_EMU_CONMODE}) && exists( $C{GRUB_CONMODE})) { -+ # strip "conmode=" from GRUB_CMDLINE{,_LINUX}_DEFAULT -+ foreach ( "GRUB_CMDLINE_LINUX", "GRUB_CMDLINE_LINUX_DEFAULT" ) { -+ $C{$_} =~ s{( ?)conmode=\S+ ?}{$1}g; -+ } -+} -+foreach ("GRUB_EMU_CONMODE", "GRUB_CONMODE") { -+ next unless( exists( $C{$_}) ); -+ $C{$_} = "conmode=" . $C{$_}; -+} -+ -+if ( $debug && $verbose > 2 ) { -+ foreach ( sort( keys( %C)) ) { -+ printf( "%s=\"%s\"\n", $_, $C{$_}); -+ } -+} -+ -+open( IN, "< $in") || -+ Panic( 1, "$C: Failed to open 'zipl.conf' template: $!.\n"); -+while ( ) { -+ Info( 3, "$.. <$_$.. >"); -+ if ( $. == 1 && m{^## This} ) { -+ $_ = "## This file was written by 'grub2-install/$C'\n" . -+ "## filling '$in' as template\n"; -+ } elsif ( $. == 2 && m{^## rpm's} ) { -+ $_ = "## with values from '$default'.\n" . -+ "## In-place modifications will eventually go missing!\n"; -+ } -+ while ( m{\@([^\@\s]+)\@} ) { -+ my $k = $1; -+ my $v; -+ if ( exists( $C{$k}) ) { -+ $v = $C{$k}; -+ } elsif ( exists( $Mandatory{$k}) ) { -+ $v = "$k"; -+ $miss++; -+ } else { -+ $v = ""; -+ } -+ s{\@$k\@}{$v}g; -+ } -+ Info( 2, $_); -+ $cfg .= $_; -+} -+if ( $miss ) { -+ Info( 1, "Partially filled config:\n===\n$cfg===\n"); -+ Panic( 1, "$C: 'zipl.conf' template could not be filled. \n"); -+} -+ -+my $ziplconf = "$zipldir/config"; -+if ( ! $debug ) { -+ open( OUT, "> $ziplconf") || die; -+ print( OUT $cfg) || die; -+ close( OUT); -+} -+ -+# copy out kernel and initrd -+my $defimage = "/boot/image"; -+my $definitrd = "/boot/initrd"; -+my $ziplimage = "$zipldir/image"; -+my $ziplinitrd = "$zipldir/initrd"; -+my $Image = "$defimage"; -+ -+if ( ! $running && ! $force ) { -+ chomp( $running = qx{uname -r}); -+ Info( 1, "preferred kernel: '$running'\n"); -+ $Image .= "-$running"; -+} -+if ( ! -r $Image ) { -+ $Image = $defimage; -+} -+Panic( 1, "$C: kernel '$Image' not readable!?\n") unless (-r $Image); -+ -+if ( -l $Image ) { -+ $Image = readlink( $Image); -+} -+my ($image, $version) = ($Image =~ m{^(?:/boot/)?([^-]+-(.+))$}); -+my $initrd = "initrd-$version"; -+ -+if ( !defined($image) || !defined($version) || ! -r "/boot/$image" ) { -+ Panic( 1, "$C: weird $Image. This should never happen!\n"); -+} -+ -+if ( ! -r $ziplimage || ! -r $ziplinitrd || $refresh ) { -+ BootCopy( $image, $zipldir, "image"); -+ BootCopy( $initrd, $zipldir, "initrd") if (-r "/boot/$initrd"); -+} -+if ( ! ChkInitrd( $zipldir, "initrd")) { -+ MkInitrd( $initrd, $zipldir, $version); -+} -+if ( ! ChkInitrd( $zipldir, "initrd")) { -+ Info( 0, "$C: dracut does not work as expected! Help needed!\n"); -+ $miss++; -+} -+ -+# now: go for it! -+my @C = ( "/sbin/zipl", (($verbose) ? "-Vnc" : "-nc"), "$ziplconf" ); -+System( @C); -+exit( $miss); -+ diff --git a/grub2-s390x-05-grub2-mkconfig.patch b/grub2-s390x-05-grub2-mkconfig.patch deleted file mode 100644 index fcac48c..0000000 --- a/grub2-s390x-05-grub2-mkconfig.patch +++ /dev/null @@ -1,144 +0,0 @@ -From: Raymund Will -Subject: Enable grub2-mkconfig for s390x-emu -References: fate#314213, bnc#868909 -Patch-Mainline: no - -V2: - * omit subvolume-prefix for platform "emu" -V3: - * add 'conmode=' to command-line if GRUB_CONMODE exists. [bnc#868909] - ---- - util/grub.d/10_linux.in | 63 ++++++++++++++++++++++++++++++++++++++---------- - 1 file changed, 51 insertions(+), 12 deletions(-) - ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -51,6 +51,10 @@ else - LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} - fi - -+if [ "x$GRUB_CONMODE" != "x" ]; then -+ GRUB_CMDLINE_LINUX="conmode=${GRUB_CONMODE} ${GRUB_CMDLINE_LINUX}" -+fi -+ - case x"$GRUB_FS" in - xbtrfs) - rootsubvol="`make_system_path_relative_to_its_root /`" -@@ -67,6 +71,21 @@ esac - - title_correction_code= - -+hotkey=1 -+incr_hotkey() -+{ -+ [ -z "$hotkey" ] && return -+ expr $hotkey + 1 -+} -+print_hotkey() -+{ -+ keys="123456789abdfgijklmnoprstuvwyz" -+ if [ -z "$hotkey" ]||[ $hotkey -eq 0 ]||[ $hotkey -gt 30 ]; then -+ return -+ fi -+ echo "--hotkey=$(expr substr $keys $hotkey 1)" -+} -+ - linux_entry () - { - os="$1" -@@ -90,9 +109,11 @@ linux_entry () - title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" - grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")" - fi -- echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -+ echo "menuentry '$(echo "$title" | grub_quote)' $(print_hotkey) ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -+ hotkey=$(incr_hotkey) - else -- echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -+ echo "menuentry '$(echo "$os" | grub_quote)' $(print_hotkey) ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -+ hotkey=$(incr_hotkey) - fi - if [ x$type != xrecovery ] ; then - save_default_entry | grub_add_tab -@@ -115,6 +136,7 @@ linux_entry () - - echo " insmod gzio" | sed "s/^/$submenu_indentation/" - -+ if [ $PLATFORM != emu ]; then # 'search' does not work for now - if [ x$dirname = x/ ]; then - if [ -z "${prepare_root_cache}" ]; then - prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)" -@@ -126,6 +148,7 @@ linux_entry () - fi - printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" - fi -+ fi - message="$(gettext_printf "Loading Linux %s ..." ${version})" - if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then - sed "s/^/$submenu_indentation/" << EOF -@@ -159,16 +182,17 @@ EOF - } - - machine=`uname -m` --case "x$machine" in -- xi?86 | xx86_64) -- list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do -- if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi -- done` ;; -- *) -- list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do -- if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi -- done` ;; -+case "$machine" in -+ i?86 | x86_64) klist="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*" ;; -+ s390 | s390x) klist="/boot/image-* /boot/kernel-*" ;; -+ *) klist="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* \ -+ /boot/kernel-*" ;; - esac -+list=`for i in $klist; do -+ if grub_file_is_not_garbage "$i" ; then -+ echo -n "$i " ; -+ fi -+ done` - - case "$machine" in - i?86) GENKERNEL_ARCH="x86" ;; -@@ -178,6 +202,15 @@ case "$machine" in - *) GENKERNEL_ARCH="$machine" ;; - esac - -+PLATFORM="native" -+if [ -d /sys/firmware/efi ]&&[ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then -+ PLATFORM="efi" -+else -+ case "$machine" in -+ s390*) PLATFORM="emu" ;; -+ esac -+fi -+ - prepare_boot_cache= - prepare_root_cache= - boot_device_id= -@@ -194,6 +227,11 @@ while [ "x$list" != "x" ] ; do - basename=`basename $linux` - dirname=`dirname $linux` - rel_dirname=`make_system_path_relative_to_its_root $dirname` -+ if [ $PLATFORM != "emu" ]; then -+ hotkey=0 -+ else -+ rel_dirname=$dirname -+ fi - version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` - alt_version=`echo $version | sed -e "s,\.old$,,g"` - linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" -@@ -278,7 +316,8 @@ while [ "x$list" != "x" ] ; do - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" - fi - # TRANSLATORS: %s is replaced with an OS name -- echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {" -+ echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' $(print_hotkey) \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {" -+ hotkey=$(incr_hotkey) - is_top_level=false - fi - diff --git a/grub2-snapper-plugin.sh b/grub2-snapper-plugin.sh index 2b6a08c..1fc7449 100644 --- a/grub2-snapper-plugin.sh +++ b/grub2-snapper-plugin.sh @@ -18,76 +18,32 @@ set -e grub_mkconfig="/usr/sbin/grub2-mkconfig" grub_mkrelpath="/usr/bin/grub2-mkrelpath" -grub_script_check="/usr/bin/grub2-script-check" grub_setting="/etc/default/grub" grub_cfg="/boot/grub2/grub.cfg" grub_snapshot_cfg="/boot/grub2/snapshot_submenu.cfg" -snapper_snapshot_path="/.snapshots" snapshot_submenu_name="snapshot_submenu.cfg" -snapper_snapshots_cfg="${snapper_snapshot_path}/snapshot_submenu.cfg" +snapshot_menuentry_name="snapshot_menuentry.cfg" +snapshot_menuentry_cfg="boot/grub2/${snapshot_menuentry_name}" -case x"`uname -m`" in - x"powerpc"* | x"ppc"*) - target="powerpc-ieee1275";; - x"sparc"*) - target="sparc64-ieee1275";; - x"mips"*"el") - target="mipsel-loongson";; - x"mips"*) - target="mips-arc";; - x"ia64"*) - target="ia64-efi";; - x"x86_64"* | x"amd64"*) - modprobe -q efivars 2>/dev/null || true - if [ -d /sys/firmware/efi ]; then - target="x86_64-efi" - else - target=i386-pc - fi - ;; - x"i"?"86"*) - modprobe -q efivars 2>/dev/null || true - if [ -d /sys/firmware/efi ]; then - target="i386-efi" - elif [ -e /proc/device-tree ]; then - target=i386-pc - for x in /proc/device-tree/*; do - if [ -e "$x" ]; then - target="i386-ieee1275" - fi - done - else - target=i386-pc - fi - ;; - *) - target="" - ;; -esac - -if [ "x${target}" != "xi386-pc" ] && - [ "x${target}" != "xx86_64-efi" ] && - [ "x${target}" != "xi386-efi" ]; then - exit 0; -fi +rel_root=`"$grub_mkrelpath" /` snapshot_submenu_refresh () { -for s_dir in ${snapper_snapshot_path}/*; do +for s_dir in /.snapshots/*; do snapshot="${s_dir}/snapshot" snapper_cfg="${s_dir}/${snapshot_submenu_name}" - num="`basename $s_dir`" if [ ! -d "$snapshot" ]; then rm -f "${snapper_cfg}" - rmdir "$s_dir" 2>/dev/null || true + rm -f "${s_dir}/${snapshot_menuentry_name}" continue fi # bnc#864842 Important snapshots are not marked as such in grub2 menu # the format is "important distribution version (kernel_version, timestamp, pre/post)" + cfgs="${s_dir}/${snapshot_menuentry_name} ${snapshot}/${snapshot_menuentry_cfg}" date=`xmllint --xpath '/snapshot/date/text()' "${s_dir}/info.xml" || echo ""` date=`echo $date | sed 's/\(.*\) \(.*\):.*/\1,\2/'` important=`xmllint --xpath "/snapshot/userdata[key='important']/value/text()" "${s_dir}/info.xml" || echo ""` @@ -104,21 +60,25 @@ for s_dir in ${snapper_snapshot_path}/*; do fi cat < "${snapper_cfg}.new" + + for x in $cfgs; do + snap="${rel_root}${snapshot}" + snap_cfg="${rel_root}\$x" - if [ -f "${snapper_snapshot_path}/$num/snapshot/boot/grub2/grub.cfg" ]; then - snapshot_found=true - saved_subvol=\$btrfs_subvol - menuentry "$title" "${snapper_snapshot_path}/$num/snapshot" "`$grub_mkrelpath ${snapper_snapshot_path}/${num}/snapshot`" { - btrfs_subvol="\$2" - extra_cmdline="rootflags=subvol=\$3" - configfile /boot/grub2/grub.cfg - btrfs_subvol=\$saved_subvol - } - fi + if [ -f "\$snap_cfg" ]; then + snapshot_found=true + submenu "$title" "\$snap" "\$snap_cfg" { + set subvol="\$2" + export subvol + source "\$3" + } + break + fi + done EOF - if ${grub_script_check} "${snapper_cfg}.new"; then + if grub2-script-check "${snapper_cfg}.new"; then mv -f "${snapper_cfg}.new" "${snapper_cfg}" fi @@ -126,65 +86,49 @@ done } -snapper_snapshots_cfg_refresh () { +grub_snapshot_cfg_refresh () { - if [ ! -d "$snapper_snapshot_path" ]; then - return +: > "${grub_snapshot_cfg}.tmp" +for s_dir in /.snapshots/*; do + + snapshot="${s_dir}/snapshot" + snapper_cfg="${s_dir}/${snapshot_submenu_name}" + + if [ -f "${snapper_cfg}" ]; then + echo "source ${rel_root}${snapper_cfg}" >>"${grub_snapshot_cfg}.tmp" + continue fi - for s_dir in ${snapper_snapshot_path}/*; do +done - snapshot="${s_dir}/snapshot" - snapper_cfg="${s_dir}/${snapshot_submenu_name}" - - if [ -f "${snapper_cfg}" ]; then - cs="${s_dir}\n${cs}" - continue - fi - - done - - for c in `echo -e "${cs}" | sort -V`; do - snapshot_cfg="\ - if [ -f "$c/snapshot_submenu.cfg" ]; then - source "$c/snapshot_submenu.cfg" - fi -${snapshot_cfg}" - done - - cat <"${snapper_snapshots_cfg}.new" +cat <"${grub_snapshot_cfg}.new" submenu "Bootable snapshots" { -${snapshot_cfg} +`sort -V "${grub_snapshot_cfg}.tmp"` if [ x\$snapshot_found != xtrue ]; then submenu "Not Found" {true} fi } EOF - if ${grub_script_check} "${snapper_snapshots_cfg}.new"; then - mv -f "${snapper_snapshots_cfg}.new" "${snapper_snapshots_cfg}" - fi +if grub2-script-check "${grub_snapshot_cfg}.new"; then + mv -f "${grub_snapshot_cfg}.new" "${grub_snapshot_cfg}" +fi } snapshot_submenu_clean () { - for s_dir in ${snapper_snapshot_path}/*; do + for s_dir in /.snapshots/*; do + snapshot="${s_dir}/snapshot" snapper_cfg="${s_dir}/${snapshot_submenu_name}" if [ -f "$snapper_cfg" ]; then rm -f "$snapper_cfg" - rmdir "$s_dir" 2>/dev/null || true fi done - - if [ -f "${snapper_snapshot_path}/${snapshot_submenu_name}" ]; then - rm -f "${snapper_snapshot_path}/${snapshot_submenu_name}" - fi - } set_grub_setting () { @@ -193,22 +137,15 @@ set_grub_setting () { val=$2 if grep -q "$name" "$grub_setting"; then - sed -i -e "s!.*\($name\)=.*!\1=\"$val\"!" "$grub_setting" + sed -i -e "s/.*\($name\)=.*/\1=$val/" "$grub_setting" else - echo "$name=\"$val\"" >> "$grub_setting" + echo "$name=$val" >> "$grub_setting" fi } -enable_grub_settings () { - set_grub_setting SUSE_BTRFS_SNAPSHOT_BOOTING "true" -} +update_grub_cfg () { -disable_grub_settings () { - set_grub_setting SUSE_BTRFS_SNAPSHOT_BOOTING "false" -} - -update_grub () { - "${grub_mkconfig}" -o "${grub_cfg}" + "$grub_mkconfig" -o "$grub_cfg" } # Check the arguments. @@ -236,22 +173,32 @@ do done if [ "x${opt_enable}" = "xtrue" ]; then - #enable_grub_settings - #update_grub + + set_grub_setting SUSE_DISABLE_BOOTING_SNAPSHOT false + set_grub_setting SUSE_ENABLE_CUSTOM_SNAPSHOT_SUBMENU true + update_grub_cfg snapshot_submenu_refresh - snapper_snapshots_cfg_refresh + grub_snapshot_cfg_refresh + elif [ "x${opt_enable}" = "xfalse" ]; then - #disable_grub_settings - update_grub + snapshot_submenu_clean + set_grub_setting SUSE_DISABLE_BOOTING_SNAPSHOT true + set_grub_setting SUSE_ENABLE_CUSTOM_SNAPSHOT_SUBMENU false + update_grub_cfg + fi if [ x${opt_refresh} = "xtrue" ]; then + snapshot_submenu_refresh - snapper_snapshots_cfg_refresh + grub_snapshot_cfg_refresh + fi if [ x${opt_clean} = "xtrue" ]; then - snapshot_submenu_clean -fi + snapshot_submenu_clean + grub_snapshot_cfg_refresh + +fi diff --git a/grub2.changes b/grub2.changes index de678e6..e1d0f67 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,325 +1,3 @@ -------------------------------------------------------------------- -Tue Apr 1 04:52:53 UTC 2014 - mchang@suse.com - -- add Recommends to libburnia-tools (bnc#812681) - -------------------------------------------------------------------- -Mon Mar 31 12:42:00 UTC 2014 - rw@suse.de - -- Document peculiarities of s390 terminals in 'README.ibm3215'. -- grub2-s390x-02-kexec-module-added-to-emu.patch: - * Improve exit message for dry-run (and cleanup). -- grub2-s390x-03-output-7-bit-ascii.patch: - * Fix handling of '^C' and solitary '^'. (bnc#867258) - * Exit properly with mode-reset. -- grub2-s390x-04-grub2-install.patch: - * Install helper script as '/usr/sbin/grub2-zipl-setup'. - * Console mode may be controlled from config file. (bnc#868909) -- grub2-s390x-05-grub2-mkconfig.patch: - * Add 'conmode=' to command-line, if configured. (bnc#868909) - -------------------------------------------------------------------- -Mon Mar 31 10:48:39 UTC 2014 - mchang@suse.com - -- snapper rollback support (fate#317062) - * add btrfs_follow_default.patch - * add suse_btrfs_grub2_install.sh - * add 80_suse_btrfs_snapshot - * add SUSE_BTRFS_SNAPSHOT_BOOTING.patch - * refresh grub2-snapper-plugin.sh - -------------------------------------------------------------------- -Fri Mar 28 02:38:07 UTC 2014 - mchang@suse.com - -- add grub2-x86_64-xen subpackage (bnc#863821) - -------------------------------------------------------------------- -Wed Mar 26 14:37:18 UTC 2014 - dvaleev@suse.com - -- ieee1275: check for IBM pseries emulated machine (bnc#869964) - -- added patches: - * grub2-ppc64-build-ppc64-32bit.patch -------------------------------------------------------------------- -Wed Mar 26 12:21:55 UTC 2014 - dvaleev@suse.com - -- Build ppc64 as 32bit - -- added patches: - * grub2-ppc64-build-ppc64-32bit.patch -------------------------------------------------------------------- -Wed Mar 26 12:03:21 UTC 2014 - dvaleev@suse.com - -- Rename PowerPC patches so it will have architecture in it's name - -- added patches: - * grub2-ppc64le-01-Add-Little-Endian-support-for-Power64-to-the-build.patch - * grub2-ppc64le-02-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch - * grub2-ppc64le-03-disable-creation-of-vsx-and-altivec-instructions.patch - * grub2-ppc64le-04-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch - * grub2-ppc64le-05-grub-install-can-now-recognize-and-install-a-LE-grub.patch - * grub2-ppc64le-06-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch - * grub2-ppc64le-07-Add-IEEE1275_ADDR-helper.patch - * grub2-ppc64le-08-Fix-some-more-warnings-when-casting.patch - * grub2-ppc64le-09-Add-powerpc64-types.patch - * grub2-ppc64le-10-powerpc64-is-not-necessarily-BigEndian-anymore.patch - * grub2-ppc64le-11-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch - * grub2-ppc64le-12-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch - * grub2-ppc64le-13-Fix-powerpc-setjmp-longjmp-64bit-issues.patch - * grub2-ppc64le-14-Add-powerpc64-ieee1275-trampoline.patch - * grub2-ppc64le-15-Add-64bit-support-to-powerpc-startup-code.patch - * grub2-ppc64le-16-Add-grub_dl_find_section_addr.patch - * grub2-ppc64le-17-Add-ppc64-relocations.patch - * grub2-ppc64le-18-ppc64-doesn-t-need-libgcc-routines.patch - * grub2-ppc64le-19-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch - * grub2-ppc64le-20-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch - * grub2-ppc64le-21-the-.toc-section-in-powerpc64le-modules-are-sometime.patch - * grub2-ppc64le-22-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch - * grub2-ppc64le-23-grub-segfaults-if-initrd-is-specified-before-specify.patch -- removed patches: - * 0001-Add-Little-Endian-support-for-Power64-to-the-build.patch - * 0002-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch - * 0003-disable-creation-of-vsx-and-altivec-instructions.patch - * 0004-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch - * 0005-grub-install-can-now-recognize-and-install-a-LE-grub.patch - * 0006-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch - * 0007-Add-IEEE1275_ADDR-helper.patch - * 0008-Fix-some-more-warnings-when-casting.patch - * 0009-Add-powerpc64-types.patch - * 0010-powerpc64-is-not-necessarily-BigEndian-anymore.patch - * 0011-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch - * 0012-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch - * 0013-Fix-powerpc-setjmp-longjmp-64bit-issues.patch - * 0014-Add-powerpc64-ieee1275-trampoline.patch - * 0015-Add-64bit-support-to-powerpc-startup-code.patch - * 0016-Add-grub_dl_find_section_addr.patch - * 0017-Add-ppc64-relocations.patch - * 0018-ppc64-doesn-t-need-libgcc-routines.patch - * 0019-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch - * 0020-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch - * 0020-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch - * 0021-the-.toc-section-in-powerpc64le-modules-are-sometime.patch - * 0022-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch - * 0023-grub-segfaults-if-initrd-is-specified-before-specify.patch -------------------------------------------------------------------- -Wed Mar 26 11:51:42 UTC 2014 - dvaleev@suse.com - -- Require powerpc-utils for grub2-powerpc-ieee1275 package - (grub2-install calls nvram from it) - -------------------------------------------------------------------- -Tue Mar 18 21:10:59 UTC 2014 - rw@suse.de - -- grub2-s390x-03-output-7-bit-ascii.patch: - * first usable interface on 3215 from initrd. (bnc#867258) - -------------------------------------------------------------------- -Tue Mar 18 06:01:46 UTC 2014 - rw@suse.de - -- reflect s390x-specifics in '/etc/default/grub'. (fate#314213) -- grub2-s390x-02-kexec-module-added-to-emu.patch: - * boot-attempts are final, except if 'kexec -l' fails. - * try to restore terminal on exit (via grub_reboot()). -- grub2-s390x-03-output-7-bit-ascii.patch: - * use less CPU cycles waiting for user. (bnc#868650) - * first usable interface on 3215. (bnc#867258) - * strip newlines on input for 3270 and 3215. -- grub2-s390x-04-grub2-install.patch: - * append 'quiet splash=silent' for 'initgrub'-boot. - * properly check for dracut script during 'grub2-install'. - -------------------------------------------------------------------- -Wed Mar 5 20:44:56 UTC 2014 - rw@suse.com - -- grub2-s390x-04-grub2-install.patch: - * refresh initrd by default, prefer running kernel and - re-zipl despite minor issues. (bnc#866867, fate#314213) - -------------------------------------------------------------------- -Tue Mar 4 22:35:25 UTC 2014 - rw@suse.com - -- grub2-s390x-03-output-7-bit-ascii.patch: - * force terminfo to ASCII. -- grub2-s390x-04-grub2-install.patch: - * try harder to find root filesystem (incl. subvol-handling) - * read /etc/sysconfig/bootloader as final fallback -- grub2-s390x-05-grub2-mkconfig.patch: - * omit subvolume-prefix for platform "emu" -- refresh 0001-script-provide-overridable-root-by-subvol.patch. - -------------------------------------------------------------------- -Mon Mar 3 11:41:56 UTC 2014 - rw@suse.com - -- build grub2-emu for s390 non-static, with device-mapper support, - but without grub2-mount and start to move arch-specific parts - to appropriate sub-packages. (fate#314213) -- grub2-s390x-02-kexec-module-added-to-emu.patch: - * introduce '--kexec/-X' to grub2-emu command-line to prevent - inadvertent system interruption. - * first give 'systemctl kexec' a chance on '-X' and - fall back to 'kexec -e' only '-X' is present twice. -- disable grub2-s390x-03-output-7-bit-ascii.patch for now. -- grub2-s390x-04-grub2-install.patch: - * add 's390x-emu' platform-support to grub2-install. - * provide all parts to zIPL into a grub2-emu shell, - including 'zipl.conf'-generator and 'dracut'-scriptlets. -- grub2-s390x-05-grub2-mkconfig.patch: - * allow 's390x' "image"-files to '10_linux' kernel enumeration. -- refresh 0001-script-provide-overridable-root-by-subvol.patch to - resolve conflict in util/grub.d/10_linux.in. -- refresh powerpc64le-as-powerpc.patch to resolve conflict - in configure.ac. - -------------------------------------------------------------------- -Mon Mar 3 11:40:21 UTC 2014 - dvaleev@suse.com - -- Refresh PowerLE patches - -- added patches: - * 0001-Add-Little-Endian-support-for-Power64-to-the-build.patch - * 0003-disable-creation-of-vsx-and-altivec-instructions.patch - * 0004-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch - * 0005-grub-install-can-now-recognize-and-install-a-LE-grub.patch - * 0006-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch - * 0007-Add-IEEE1275_ADDR-helper.patch - * 0008-Fix-some-more-warnings-when-casting.patch - * 0009-Add-powerpc64-types.patch - * 0010-powerpc64-is-not-necessarily-BigEndian-anymore.patch - * 0011-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch - * 0012-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch - * 0013-Fix-powerpc-setjmp-longjmp-64bit-issues.patch - * 0014-Add-powerpc64-ieee1275-trampoline.patch - * 0015-Add-64bit-support-to-powerpc-startup-code.patch - * 0016-Add-grub_dl_find_section_addr.patch - * 0017-Add-ppc64-relocations.patch - * 0018-ppc64-doesn-t-need-libgcc-routines.patch - * 0019-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch - * 0020-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch - * 0021-the-.toc-section-in-powerpc64le-modules-are-sometime.patch - * 0022-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch - * 0023-grub-segfaults-if-initrd-is-specified-before-specify.patch -- removed patches: - * 0001-Add-a-new-architecture-to-the-build-process.patch - * 0003-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch - * 0004-grub-install-can-now-recognize-and-install-a-LE-grub.patch - * 0005-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch - * 0006-Add-IEEE1275_ADDR-helper.patch - * 0007-Fix-some-more-warnings-when-casting.patch - * 0008-Add-powerpc64-types.patch - * 0009-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch - * 0010-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch - * 0011-Fix-powerpc-setjmp-longjmp-64bit-issues.patch - * 0012-Add-powerpc64-ieee1275-trampoline.patch - * 0013-Add-64bit-support-to-powerpc-startup-code.patch - * 0014-Add-grub_dl_find_section_addr.patch - * 0015-Add-ppc64-relocations.patch - * 0016-ppc64-doesn-t-need-libgcc-routines.patch - * 0017-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch - * 0018-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch - * 0019-the-.toc-section-in-powerpc64le-modules-are-sometime.patch - * 0021-powerpc64-is-not-necessarily-BigEndian-anymore.patch - * 0022-grub-segfaults-if-initrd-is-specified-before-specify.patch - * 0023-Power7-cannot-handle-VSX-instructions-correctly.-It-.patch - * powerpc-novsx-noaltivec.patch - * powerpc64le-as-powerpc.patch -- modified patches: - * 0002-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch - -------------------------------------------------------------------- -Fri Feb 28 01:14:10 UTC 2014 - dvaleev@suse.com - -- build with -mno-vsx and -mno-altivec on powerpc - -- added patches: - * powerpc-novsx-noaltivec.patch - -------------------------------------------------------------------- -Thu Feb 27 10:42:25 UTC 2014 - dvaleev@suse.com - -- The following patches enable grub to support -64bit Little Endian Power architecture. (bnc#865913) - -Anton Blanchard (12): - Add IEEE1275_ADDR helper - Fix some more warnings when casting. - Add powerpc64 types - Fix warnings when building powerpc linux loader 64bit - Fix powerpc setjmp/longjmp 64bit issues - Add powerpc64 ieee1275 trampoline - Add 64bit support to powerpc startup code - Add grub_dl_find_section_addr - Add ppc64 relocations - ppc64 doesn't need libgcc routines - Use FUNC_START/FUNC_END for powerpc function definitions - powerpc64 is not necessarily BigEndian anymore! :) - -Ram Pai (11): - Add a new architecture to the build process - Build grub as O1 until we add savegpr and restgpr routines - powerpc64 LE's linker knows how to handle the undefined symbol .TOC. - in grub modules. So just ignore that symbol during build. - grub-install can now recognize and install a LE grub boot loader - set the ABI version to 0x02 in the e_flag of the PPC64LE ELF image. - GRUB_ELF_R_PPC_* processing is applicable only for 32 bit bootloader. - .TOC. symbol is special in ppc64le . It maps to the address of the - .toc section. - the .toc section in powerpc64le modules are sometimes not aligned on a - four byte boundary. This fails the module linker especially when - processing R_PPC64_TOC16_LO_DS, since the addresses are expected - to be aligned on 4byte boundary. - all parameter to firmware calls should to be BigEndian and the results - should be CPU endian. - grub segfaults if initrd is specified before specifying the kernel. - The problem is the initrd module sees that kernel is not specified - and takes the fail path. In the fail path it checks if anything - has be malloc'ed. Unfortunately the variable that it looks to - check for is a uninitialized stack variable. The stack variable - can incorrectly indicate something is malloced, which leads the - module to free some unallocated memory. This patch fixes the - problem by initializing the stack variable. - Power7 cannot handle VSX instructions correctly. It segfaults. - This patch is applicable only for power7 systems. - -Thomas Falcon (1): - Add a new architecture to the build process - -Tomohiro B Berry (1): - Add a new architecture to the build process - -- added patches: - * 0001-Add-a-new-architecture-to-the-build-process.patch - * 0002-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch - * 0003-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch - * 0004-grub-install-can-now-recognize-and-install-a-LE-grub.patch - * 0005-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch - * 0006-Add-IEEE1275_ADDR-helper.patch - * 0007-Fix-some-more-warnings-when-casting.patch - * 0008-Add-powerpc64-types.patch - * 0009-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch - * 0010-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch - * 0011-Fix-powerpc-setjmp-longjmp-64bit-issues.patch - * 0012-Add-powerpc64-ieee1275-trampoline.patch - * 0013-Add-64bit-support-to-powerpc-startup-code.patch - * 0014-Add-grub_dl_find_section_addr.patch - * 0015-Add-ppc64-relocations.patch - * 0016-ppc64-doesn-t-need-libgcc-routines.patch - * 0017-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch - * 0018-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch - * 0019-the-.toc-section-in-powerpc64le-modules-are-sometime.patch - * 0020-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch - * 0021-powerpc64-is-not-necessarily-BigEndian-anymore.patch - * 0022-grub-segfaults-if-initrd-is-specified-before-specify.patch - * 0023-Power7-cannot-handle-VSX-instructions-correctly.-It-.patch -- removed patches: - * grub2-powerpc-libgcc.patch - * grub2-ppc64le-core-bigendian.patch - * grub2-ppc64le-platform.patch - -------------------------------------------------------------------- -Thu Feb 27 09:26:49 UTC 2014 - jjolly@suse.com - -- kexec performed as linux/initrd/boot under emu environment - ------------------------------------------------------------------- Thu Feb 27 04:30:07 UTC 2014 - mchang@suse.com @@ -328,12 +6,6 @@ Thu Feb 27 04:30:07 UTC 2014 - mchang@suse.com "important distribution version (kernel_version, timestamp, pre/post)" (bnc#864842) -------------------------------------------------------------------- -Tue Feb 25 06:41:41 UTC 2014 - jjolly@suse.com - -- Fixed output on s390 3270 terminal. Strictly serial on s390 now -- kexec command added for emu platform - ------------------------------------------------------------------- Mon Feb 24 07:28:42 UTC 2014 - mchang@suse.com diff --git a/grub2.rpmlintrc b/grub2.rpmlintrc index dcf9e35..40e1ac6 100644 --- a/grub2.rpmlintrc +++ b/grub2.rpmlintrc @@ -1,10 +1,10 @@ addFilter("zero-length /boot/grub2/grub.cfg") +addFilter("zero-length /boot/grub2-efi/grub.cfg") addFilter("non-etc-or-var-file-marked-as-conffile /boot/grub2/grub.cfg") +addFilter("non-etc-or-var-file-marked-as-conffile /boot/grub2-efi/grub.cfg") addFilter("non-conffile-in-etc /etc/bash_completion.d/grub") addFilter("non-conffile-in-etc /etc/grub.d/README") -addFilter("statically-linked-binary .*/grub2/*/kernel.img") -addFilter("patch-not-applied") +addFilter("statically-linked-binary .*/grub2/i386-pc/kernel.img") # We need to supply unstripped files for grub -addFilter("unstripped-binary-or-object .*/grub2/*/.*.mod") -# TODO: s390 Experts: is this sensible?! -addFilter("s390x: W: executable-stack") +addFilter("unstripped-binary-or-object .*/grub2/i386-pc/.*.mod") +addFilter("unstripped-binary-or-object .*/grub2-efi/.*/.*.mod") diff --git a/grub2.spec b/grub2.spec index 8ce6fda..ab73bc5 100644 --- a/grub2.spec +++ b/grub2.spec @@ -26,6 +26,9 @@ BuildRequires: glibc-devel-32bit %else BuildRequires: gcc BuildRequires: glibc-devel +%ifarch s390x +BuildRequires: glibc-static +%endif %endif BuildRequires: automake BuildRequires: bison @@ -52,7 +55,6 @@ BuildRequires: xz-devel BuildRequires: openssl >= 0.9.8 BuildRequires: pesign-obs-integration %endif -BuildRequires: xen-devel %endif # Modules code is dynamically loaded and collected from a _fixed_ path. @@ -109,12 +111,9 @@ Source4: grub2.rpmlintrc Source5: translations-20130626.tar.xz Source6: grub2-once Source7: 20_memtest86+ -Source8: README.ibm3215 Source10: openSUSE-UEFI-CA-Certificate.crt Source11: SLES-UEFI-CA-Certificate.crt Source12: grub2-snapper-plugin.sh -Source13: suse_btrfs_grub2_install.sh -Source14: 80_suse_btrfs_snapshot Source1000: PATCH_POLICY Patch1: rename-grub-info-file-to-grub2.patch Patch2: grub2-linux.patch @@ -139,51 +138,19 @@ Patch35: grub2-linguas.sh-no-rsync.patch Patch36: 0001-look-for-DejaVu-also-in-usr-share-fonts-truetype.patch Patch37: grub2-use-DejaVuSansMono-for-starfield-theme.patch Patch38: grub2-s390x-01-Changes-made-and-files-added-in-order-to-allow-s390x.patch -Patch39: grub2-s390x-02-kexec-module-added-to-emu.patch -Patch40: grub2-s390x-03-output-7-bit-ascii.patch -Patch41: grub2-s390x-04-grub2-install.patch -Patch42: grub2-s390x-05-grub2-mkconfig.patch # Btrfs snapshot booting related patches Patch101: 0002-btrfs-add-ability-to-boot-from-subvolumes.patch Patch102: 0003-cmdline-add-envvar-loader_cmdline_append.patch Patch103: 0004-btrfs-export-subvolume-envvars.patch -Patch104: btrfs_follow_default.patch -Patch105: SUSE_BTRFS_SNAPSHOT_BOOTING.patch Patch110: 0001-script-provide-overridable-root-by-subvol.patch Patch111: 0002-script-create-menus-for-btrfs-snapshot.patch -# PowerPC LE support -Patch201: grub2-ppc64le-01-Add-Little-Endian-support-for-Power64-to-the-build.patch -Patch202: grub2-ppc64le-02-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch -Patch203: grub2-ppc64le-03-disable-creation-of-vsx-and-altivec-instructions.patch -Patch204: grub2-ppc64le-04-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch -Patch205: grub2-ppc64le-05-grub-install-can-now-recognize-and-install-a-LE-grub.patch -Patch206: grub2-ppc64le-06-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch -Patch207: grub2-ppc64le-07-Add-IEEE1275_ADDR-helper.patch -Patch208: grub2-ppc64le-08-Fix-some-more-warnings-when-casting.patch -Patch209: grub2-ppc64le-09-Add-powerpc64-types.patch -Patch210: grub2-ppc64le-10-powerpc64-is-not-necessarily-BigEndian-anymore.patch -Patch211: grub2-ppc64le-11-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch -Patch212: grub2-ppc64le-12-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch -Patch213: grub2-ppc64le-13-Fix-powerpc-setjmp-longjmp-64bit-issues.patch -Patch214: grub2-ppc64le-14-Add-powerpc64-ieee1275-trampoline.patch -Patch215: grub2-ppc64le-15-Add-64bit-support-to-powerpc-startup-code.patch -Patch216: grub2-ppc64le-16-Add-grub_dl_find_section_addr.patch -Patch217: grub2-ppc64le-17-Add-ppc64-relocations.patch -Patch218: grub2-ppc64le-18-ppc64-doesn-t-need-libgcc-routines.patch -Patch219: grub2-ppc64le-19-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch -Patch220: grub2-ppc64le-20-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch -Patch221: grub2-ppc64le-21-the-.toc-section-in-powerpc64le-modules-are-sometime.patch -Patch222: grub2-ppc64le-22-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch -Patch223: grub2-ppc64le-23-grub-segfaults-if-initrd-is-specified-before-specify.patch -Patch224: grub2-ppc64-build-ppc64-32bit.patch -Patch225: grub2-ppc64-qemu.patch +Patch200: grub2-ppc64le-platform.patch +Patch201: grub2-powerpc-libgcc.patch +Patch202: grub2-ppc64le-core-bigendian.patch Requires: gettext-runtime %if 0%{?suse_version} >= 1140 -%ifnarch s390x Requires: os-prober %endif -Recommends: libburnia-tools -%endif Requires(post): /sbin/install-info Requires(preun):/sbin/install-info %if ! 0%{?only_efi:1} @@ -234,9 +201,6 @@ Requires: %{name} = %{version}-%{release} Requires(post): %{name} = %{version}-%{release} Requires: perl-Bootloader Requires(post): perl-Bootloader -%ifarch s390x -Requires: s390-tools -%endif %description %{grubarch} The GRand Unified Bootloader (GRUB) is a highly configurable and customizable @@ -255,9 +219,6 @@ Group: System/Boot Requires: efibootmgr Requires(post): efibootmgr %endif -%ifarch ppc ppc64 ppc64le -Requires: powerpc-utils -%endif Requires: %{name} = %{version}-%{release} Requires(post): %{name} = %{version}-%{release} Requires: perl-Bootloader >= 0.706 @@ -273,23 +234,6 @@ provides support for EFI systems. %endif -%ifarch x86_64 - -%package %{_target_cpu}-xen - -Summary: Bootloader with support for Linux, Multiboot and more -Group: System/Boot -Provides: %{name}-xen = %{version}-%{release} -Obsoletes: %{name}-xen < %{version}-%{release} - -%description %{_target_cpu}-xen -The GRand Unified Bootloader (GRUB) is a highly configurable and customizable -bootloader with modular architecture. It supports rich variety of kernel formats, -file systems, computer architectures and hardware devices. This subpackage -provides support for XEN systems. - -%endif - %package snapper-plugin Summary: Grub2's snapper plugin @@ -324,7 +268,7 @@ mv po/grub.pot po/%{name}.pot # we could enable it when # 1 we have background with better contrast to the font's color # 2 we confirm it's eligible to set the terminal background this way -#patch13 -p1 +#%patch13 -p1 %patch15 -p1 %patch16 -p1 %patch17 -p1 @@ -339,42 +283,17 @@ mv po/grub.pot po/%{name}.pot %patch36 -p1 %patch37 -p1 %patch38 -p1 -%patch39 -p1 -%patch40 -p1 -%patch41 -p1 -%patch42 -p1 %patch101 -p1 %patch102 -p1 %patch103 -p1 -%patch104 -p1 -%patch105 -p1 -#patch110 -p1 -#patch111 -p1 +%patch110 -p1 +%patch111 -p1 +%patch200 -p1 %patch201 -p1 +#We want to override endianess on Power LE only +%ifarch ppc64le %patch202 -p1 -%patch203 -p1 -%patch204 -p1 -%patch205 -p1 -%patch206 -p1 -%patch207 -p1 -%patch208 -p1 -%patch209 -p1 -%patch210 -p1 -%patch211 -p1 -%patch212 -p1 -%patch213 -p1 -%patch214 -p1 -%patch215 -p1 -%patch216 -p1 -%patch217 -p1 -%patch218 -p1 -%patch219 -p1 -%patch220 -p1 -%patch221 -p1 -%patch222 -p1 -%patch223 -p1 -%patch224 -p1 -%patch225 -p1 +%endif # Generate po/LINGUAS for message catalogs ... ./linguas.sh @@ -383,14 +302,10 @@ rm -f po/stamp-po # README.openSUSE cp %{SOURCE3} . -cp %{SOURCE8} . mkdir build %ifarch %{efi} mkdir build-efi %endif -%ifarch x86_64 -mkdir build-xen -%endif %build # autogen calls autoreconf -vi @@ -406,37 +321,6 @@ CXXFLAGS=" " FFLAGS=" " export CFLAGS CXXFLAGS FFLAGS -%ifarch x86_64 -cd build-xen -../configure \ - TARGET_LDFLAGS=-static \ - --prefix=%{_prefix} \ - --sysconfdir=%{_sysconfdir} \ - --target=%{_target_platform} \ - --libdir=%{_libdir} \ - --with-platform=xen \ - --program-transform-name=s,grub,%{name}, -make %{?_smp_mflags} - -cat > ./grub.cfg <&2 - exit 1; -fi - -make_grubcfg () { - -prefix="$1" -descriptive_config="snapshot_submenu.cfg" - -if [ "x${platform}" = "xpc" ]; then -cat </dev/null || true - if [ -d /sys/firmware/efi ]; then - target="x86_64-efi" - else - target=i386-pc - fi - ;; - x"i"?"86"*) - modprobe -q efivars 2>/dev/null || true - if [ -d /sys/firmware/efi ]; then - target="i386-efi" - elif [ -e /proc/device-tree ]; then - target=i386-pc - for x in /proc/device-tree/*; do - if [ -e "$x" ]; then - target="i386-ieee1275" - fi - done - else - target=i386-pc - fi - ;; - *) - target="" - ;; -esac - -if [ "x${target}" = "xi386-pc" ]; then - platform="pc" -elif [ "x${target}" = "xx86_64-efi" ] || - [ "x${target}" = "xi386-efi" ]; then - platform="efi" -else - exit 0 -fi - -if [ "x${platform}" = "xefi" ]; then - bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr 'A-Z' 'a-z' | cut -d' ' -f1)" - if test -z "$bootloader_id"; then - bootloader_id=grub - fi - boot_directory="/boot/efi/EFI/${bootloader_id}" - - if echo "$@" | grep -q '--boot-directory='; then - ${grub_install} $@ - else - ${grub_install} --boot-directory="${boot_directory}" --efi-directory="/boot/efi" $@ - make_grubcfg "/EFI/${bootloader_id}/grub2" >"${boot_directory}/grub2/grub.cfg.new" - fi -elif [ "x${platform}" = "xpc" ]; then - boot_directory="/.boot" - if [ ! -d "$boot_directory" ]; then - ${btrfs_util} subvolume create "$boot_directory" - echo "UUID=`$grub_probe -t fs_uuid /` /.boot btrfs subvol=@/.boot 0 0" >>/etc/fstab - fi - if echo "$@" | grep -q '--boot-directory='; then - ${grub_install} $@ - else - ${grub_install} --boot-directory="${boot_directory}" $@ - make_grubcfg "${boot_directory}/grub2" >"${boot_directory}/grub2/grub.cfg.new" - fi -fi - -if $grub_script_check "${boot_directory}/grub2/grub.cfg.new"; then - mv -f "${boot_directory}/grub2/grub.cfg.new" "${boot_directory}/grub2/grub.cfg" -fi -