Accepting request 357598 from Base:System

1

OBS-URL: https://build.opensuse.org/request/show/357598
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=132
This commit is contained in:
Dominique Leuenberger 2016-02-09 12:31:01 +00:00 committed by Git OBS Bridge
commit c611ab24f0
37 changed files with 1287 additions and 2660 deletions

201
biendian.patch Normal file
View File

@ -0,0 +1,201 @@
From 9facac630985467ee1ad40beaed07d50ee18062c Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Fri, 15 Aug 2014 14:39:53 -0300
Subject: [PATCH 143/143] Suport for bi-endianess in elf file
* grub-core/kern/elf.c: check and switch endianess with grub_{be,le}_to
cpu functions.
* grub-core/kern/elfXX.c: Likewise.
Also-by: Tomohiro B Berry <tbberry@us.ibm.com>
---
grub-core/kern/elf.c | 60 +++++++++++++++++++++++++++++++++++++++--
grub-core/kern/elfXX.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 131 insertions(+), 2 deletions(-)
diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c
index 5f99c43..de90811 100644
--- a/grub-core/kern/elf.c
+++ b/grub-core/kern/elf.c
@@ -28,6 +28,11 @@
GRUB_MOD_LICENSE ("GPLv3+");
+void grub_elf32_check_endianess (grub_elf_t elf);
+void grub_elf64_check_endianess (grub_elf_t elf);
+grub_err_t grub_elf32_check_version (grub_elf_t elf);
+grub_err_t grub_elf64_check_version (grub_elf_t elf);
+
/* Check if EHDR is a valid ELF header. */
static grub_err_t
grub_elf_check_header (grub_elf_t elf)
@@ -38,10 +43,22 @@ grub_elf_check_header (grub_elf_t elf)
|| e->e_ident[EI_MAG1] != ELFMAG1
|| e->e_ident[EI_MAG2] != ELFMAG2
|| e->e_ident[EI_MAG3] != ELFMAG3
- || e->e_ident[EI_VERSION] != EV_CURRENT
- || e->e_version != EV_CURRENT)
+ || e->e_ident[EI_VERSION] != EV_CURRENT)
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic"));
+ if (grub_elf_is_elf32 (elf))
+ {
+ grub_elf32_check_endianess (elf);
+ grub_elf32_check_version (elf);
+ }
+ else if (grub_elf_is_elf64 (elf))
+ {
+ grub_elf64_check_endianess (elf);
+ grub_elf64_check_version (elf);
+ }
+ else
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
return GRUB_ERR_NONE;
}
@@ -127,7 +144,20 @@ grub_elf_open (const char *name)
#define grub_elf_is_elfXX grub_elf_is_elf32
#define grub_elfXX_load_phdrs grub_elf32_load_phdrs
#define ElfXX_Phdr Elf32_Phdr
+#define ElfXX_Ehdr Elf32_Ehdr
#define grub_uintXX_t grub_uint32_t
+#define grub_be_to_halfXX grub_be_to_cpu16
+#define grub_be_to_wordXX grub_be_to_cpu32
+#define grub_be_to_addrXX grub_be_to_cpu32
+#define grub_be_to_offXX grub_be_to_cpu32
+#define grub_be_to_XwordXX grub_be_to_wordXX
+#define grub_le_to_halfXX grub_le_to_cpu16
+#define grub_le_to_wordXX grub_le_to_cpu32
+#define grub_le_to_addrXX grub_le_to_cpu32
+#define grub_le_to_offXX grub_le_to_cpu32
+#define grub_le_to_XwordXX grub_le_to_wordXX
+#define grub_elfXX_check_endianess grub_elf32_check_endianess
+#define grub_elfXX_check_version grub_elf32_check_version
#include "elfXX.c"
@@ -140,7 +170,20 @@ grub_elf_open (const char *name)
#undef grub_elf_is_elfXX
#undef grub_elfXX_load_phdrs
#undef ElfXX_Phdr
+#undef ElfXX_Ehdr
#undef grub_uintXX_t
+#undef grub_be_to_halfXX
+#undef grub_be_to_wordXX
+#undef grub_be_to_addrXX
+#undef grub_be_to_offXX
+#undef grub_be_to_XwordXX
+#undef grub_le_to_halfXX
+#undef grub_le_to_wordXX
+#undef grub_le_to_addrXX
+#undef grub_le_to_offXX
+#undef grub_le_to_XwordXX
+#undef grub_elfXX_check_endianess
+#undef grub_elfXX_check_version
/* 64-bit */
@@ -153,6 +196,19 @@ grub_elf_open (const char *name)
#define grub_elf_is_elfXX grub_elf_is_elf64
#define grub_elfXX_load_phdrs grub_elf64_load_phdrs
#define ElfXX_Phdr Elf64_Phdr
+#define ElfXX_Ehdr Elf64_Ehdr
#define grub_uintXX_t grub_uint64_t
+#define grub_be_to_halfXX grub_be_to_cpu16
+#define grub_be_to_wordXX grub_be_to_cpu32
+#define grub_be_to_addrXX grub_be_to_cpu64
+#define grub_be_to_offXX grub_be_to_cpu64
+#define grub_be_to_XwordXX grub_be_to_cpu64
+#define grub_le_to_halfXX grub_le_to_cpu16
+#define grub_le_to_wordXX grub_le_to_cpu32
+#define grub_le_to_addrXX grub_le_to_cpu64
+#define grub_le_to_offXX grub_le_to_cpu64
+#define grub_le_to_XwordXX grub_le_to_cpu64
+#define grub_elfXX_check_endianess grub_elf64_check_endianess
+#define grub_elfXX_check_version grub_elf64_check_version
#include "elfXX.c"
diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c
index 1d09971..ecf9df6 100644
--- a/grub-core/kern/elfXX.c
+++ b/grub-core/kern/elfXX.c
@@ -154,3 +154,76 @@ grub_elfXX_load (grub_elf_t elf, const char *filename,
return grub_errno;
}
+
+void
+grub_elfXX_check_endianess (grub_elf_t elf)
+{
+ ElfXX_Ehdr *e = &(elf->ehdr.ehdrXX);
+ ElfXX_Phdr *phdr;
+
+ if (e->e_ident[EI_DATA] == ELFDATA2MSB)
+ {
+ e->e_type = grub_be_to_halfXX (e->e_type);
+ e->e_machine = grub_be_to_halfXX (e->e_machine);
+ e->e_version = grub_be_to_wordXX (e->e_version);
+ e->e_entry = grub_be_to_addrXX (e->e_entry);
+ e->e_phoff = grub_be_to_offXX (e->e_phoff);
+ e->e_shoff = grub_be_to_offXX (e->e_shoff);
+ e->e_flags = grub_be_to_wordXX (e->e_flags);
+ e->e_ehsize = grub_be_to_halfXX (e->e_ehsize);
+ e->e_phentsize = grub_be_to_halfXX (e->e_phentsize);
+ e->e_phnum = grub_be_to_halfXX (e->e_phnum);
+ e->e_shentsize = grub_be_to_halfXX (e->e_shentsize);
+ e->e_shnum = grub_be_to_halfXX (e->e_shnum);
+ e->e_shstrndx = grub_be_to_halfXX (e->e_shstrndx);
+
+ FOR_ELFXX_PHDRS (elf,phdr)
+ {
+ phdr->p_type = grub_be_to_wordXX (phdr->p_type);
+ phdr->p_flags = grub_be_to_wordXX (phdr->p_flags);
+ phdr->p_offset = grub_be_to_offXX (phdr->p_offset);
+ phdr->p_vaddr = grub_be_to_addrXX (phdr->p_vaddr);
+ phdr->p_paddr = grub_be_to_addrXX (phdr->p_paddr);
+ phdr->p_filesz = grub_be_to_XwordXX (phdr->p_filesz);
+ phdr->p_memsz = grub_be_to_XwordXX (phdr->p_memsz);
+ phdr->p_align = grub_be_to_XwordXX (phdr->p_align);
+ }
+ }
+ else if (e->e_ident[EI_DATA] == ELFDATA2LSB)
+ {
+ e->e_type = grub_le_to_halfXX (e->e_type);
+ e->e_machine = grub_le_to_halfXX (e->e_machine);
+ e->e_version = grub_le_to_wordXX (e->e_version);
+ e->e_entry = grub_le_to_addrXX (e->e_entry);
+ e->e_phoff = grub_le_to_offXX (e->e_phoff);
+ e->e_shoff = grub_le_to_offXX (e->e_shoff);
+ e->e_flags = grub_le_to_wordXX (e->e_flags);
+ e->e_ehsize = grub_le_to_halfXX (e->e_ehsize);
+ e->e_phentsize = grub_le_to_halfXX (e->e_phentsize);
+ e->e_phnum = grub_le_to_halfXX (e->e_phnum);
+ e->e_shentsize = grub_le_to_halfXX (e->e_shentsize);
+ e->e_shnum = grub_le_to_halfXX (e->e_shnum);
+ e->e_shstrndx = grub_le_to_halfXX (e->e_shstrndx);
+
+ FOR_ELFXX_PHDRS (elf,phdr)
+ {
+ phdr->p_type = grub_le_to_wordXX (phdr->p_type);
+ phdr->p_flags = grub_le_to_wordXX (phdr->p_flags);
+ phdr->p_offset = grub_le_to_offXX (phdr->p_offset);
+ phdr->p_vaddr = grub_le_to_addrXX (phdr->p_vaddr);
+ phdr->p_paddr = grub_le_to_addrXX (phdr->p_paddr);
+ phdr->p_filesz = grub_le_to_XwordXX (phdr->p_filesz);
+ phdr->p_memsz = grub_le_to_XwordXX (phdr->p_memsz);
+ phdr->p_align = grub_le_to_XwordXX (phdr->p_align);
+ }
+ }
+}
+
+grub_err_t
+grub_elfXX_check_version (grub_elf_t elf)
+{
+ if (elf->ehdr.ehdrXX.e_version != EV_CURRENT)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
--
1.9.3

View File

@ -50,7 +50,7 @@ Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
@@ -81,6 +85,31 @@ esac
@@ -85,6 +89,31 @@ esac
title_correction_code=
@ -82,7 +82,7 @@ Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
linux_entry ()
{
os="$1"
@@ -118,6 +147,40 @@ linux_entry ()
@@ -122,6 +151,40 @@ linux_entry ()
save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/"
fi
@ -123,7 +123,7 @@ Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
fi
@@ -225,6 +288,24 @@ while [ "x${xen_list}" != "x" ] ; do
@@ -219,6 +282,24 @@ while [ "x${xen_list}" != "x" ] ; do
xen_dirname=`dirname ${current_xen}`
rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
xen_version=`echo $xen_basename | sed -e "s,.gz$,,g;s,^xen-,,g"`
@ -148,7 +148,7 @@ Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
@@ -289,7 +370,6 @@ while [ "x${xen_list}" != "x" ] ; do
@@ -283,7 +364,6 @@ while [ "x${xen_list}" != "x" ] ; do
if [ x"$is_top_level" != xtrue ]; then
echo ' }'
fi
@ -156,7 +156,7 @@ Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
done
# If at least one kernel was found, then we need to
@@ -299,3 +379,7 @@ if [ x"$is_top_level" != xtrue ]; then
@@ -293,3 +373,7 @@ if [ x"$is_top_level" != xtrue ]; then
fi
echo "$title_correction_code"

View File

@ -0,0 +1,27 @@
Index: grub-2.02~beta2/util/grub-mkconfig.in
===================================================================
--- grub-2.02~beta2.orig/util/grub-mkconfig.in
+++ grub-2.02~beta2/util/grub-mkconfig.in
@@ -260,7 +260,8 @@ export GRUB_DEFAULT \
GRUB_DISABLE_SUBMENU \
GRUB_CMDLINE_LINUX_RECOVERY \
GRUB_USE_LINUXEFI \
- SUSE_BTRFS_SNAPSHOT_BOOTING
+ SUSE_BTRFS_SNAPSHOT_BOOTING \
+ SUSE_CMDLINE_XENEFI
if test "x${grub_cfg}" != "x"; then
rm -f "${grub_cfg}.new"
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
@@ -176,7 +176,7 @@ linux_entry ()
message="$(gettext_printf "Loading Xen %s with Linux %s ..." ${xen_version} ${version})"
sed "s/^/$submenu_indentation/" <<-EOF
echo '$(echo "$message" | grub_quote)'
- chainloader \$cmdpath/${xen_basename} ${xen_basename} $section
+ chainloader \$cmdpath/${xen_basename} ${xen_basename} ${SUSE_CMDLINE_XENEFI} $section
}
EOF
for f in ${grub_dir}/$xen_cfg ${xen_dir}/${xen_basename} ${dirname}/${basename} ${dirname}/${initrd}; do

View File

@ -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

View File

@ -0,0 +1,170 @@
From 9d1411ffa7290c1cbdc9ee95bb5fcc5506e63e0f Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Date: Thu, 20 Sep 2012 18:07:39 -0300
Subject: [PATCH 096/152] IBM client architecture (CAS) reboot support
This is an implementation of IBM client architecture (CAS) reboot for GRUB.
There are cases where the POWER firmware must reboot in order to support
specific features requested by a kernel. The kernel calls
ibm,client-architecture-support and it may either return or reboot with the new
feature set. eg:
Calling ibm,client-architecture-support.../
Elapsed time since release of system processors: 70959 mins 50 secs
Welcome to GRUB!
Instead of return to the GRUB menu, it will check if the flag for CAS reboot is
set. If so, grub will automatically boot the last booted kernel using the same
parameters
---
grub-core/kern/ieee1275/openfw.c | 62 ++++++++++++++++++++++++++++++++++++++++
grub-core/normal/main.c | 19 ++++++++++++
grub-core/script/execute.c | 7 +++++
include/grub/ieee1275/ieee1275.h | 2 ++
4 files changed, 90 insertions(+)
Index: grub-2.02~beta2/grub-core/kern/ieee1275/openfw.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/kern/ieee1275/openfw.c
+++ grub-2.02~beta2/grub-core/kern/ieee1275/openfw.c
@@ -561,3 +561,65 @@ grub_ieee1275_canonicalise_devname (cons
return NULL;
}
+/* Check if it's a CAS reboot. If so, set the script to be executed. */
+int
+grub_ieee1275_cas_reboot (char *script)
+{
+ grub_uint32_t ibm_ca_support_reboot;
+ grub_uint32_t ibm_fw_nbr_reboots;
+ char property_value[10];
+ grub_ssize_t actual;
+ grub_ieee1275_ihandle_t options;
+
+ if (grub_ieee1275_finddevice ("/options", &options) < 0)
+ return -1;
+
+ /* Check two properties, one is enough to get cas reboot value */
+ ibm_ca_support_reboot = 0;
+ if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen,
+ "ibm,client-architecture-support-reboot",
+ &ibm_ca_support_reboot,
+ sizeof (ibm_ca_support_reboot),
+ &actual) >= 0)
+ grub_dprintf("ieee1275", "ibm,client-architecture-support-reboot: %u\n",
+ ibm_ca_support_reboot);
+
+ ibm_fw_nbr_reboots = 0;
+ if (grub_ieee1275_get_property (options, "ibm,fw-nbr-reboots",
+ property_value, sizeof (property_value),
+ &actual) >= 0)
+ {
+ property_value[sizeof (property_value) - 1] = 0;
+ ibm_fw_nbr_reboots = (grub_uint8_t) grub_strtoul (property_value, 0, 10);
+ grub_dprintf("ieee1275", "ibm,fw-nbr-reboots: %u\n", ibm_fw_nbr_reboots);
+ }
+
+ if (ibm_ca_support_reboot || ibm_fw_nbr_reboots)
+ {
+ if (! grub_ieee1275_get_property_length (options, "boot-last-label", &actual))
+ {
+ if (actual > 1024)
+ script = grub_realloc (script, actual + 1);
+ grub_ieee1275_get_property (options, "boot-last-label", script, actual,
+ &actual);
+ return 0;
+ }
+ }
+
+ grub_ieee1275_set_boot_last_label ("");
+
+ return -1;
+}
+
+int grub_ieee1275_set_boot_last_label (const char *text)
+{
+ grub_ieee1275_ihandle_t options;
+ grub_ssize_t actual;
+
+ grub_dprintf("ieee1275", "set boot_last_label (size: %" PRIxGRUB_SIZE ")\n", grub_strlen(text));
+ if (! grub_ieee1275_finddevice ("/options", &options) &&
+ options != (grub_ieee1275_ihandle_t) -1)
+ grub_ieee1275_set_property (options, "boot-last-label", text,
+ grub_strlen (text), &actual);
+ return 0;
+}
Index: grub-2.02~beta2/grub-core/normal/main.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/normal/main.c
+++ grub-2.02~beta2/grub-core/normal/main.c
@@ -32,6 +32,9 @@
#include <grub/i18n.h>
#include <grub/charset.h>
#include <grub/script_sh.h>
+#ifdef GRUB_MACHINE_IEEE1275
+#include <grub/ieee1275/ieee1275.h>
+#endif
GRUB_MOD_LICENSE ("GPLv3+");
@@ -267,6 +270,21 @@ grub_normal_execute (const char *config,
{
menu = read_config_file (config);
+#ifdef GRUB_MACHINE_IEEE1275
+ int boot;
+ boot = 0;
+ char *script;
+ script = grub_malloc (1024);
+ if (! grub_ieee1275_cas_reboot (script))
+ {
+ if (! grub_script_execute_sourcecode (script))
+ boot = 1;
+ }
+ grub_free (script);
+ if (boot)
+ grub_command_execute ("boot", 0, 0);
+#endif
+
/* Ignore any error. */
grub_errno = GRUB_ERR_NONE;
}
Index: grub-2.02~beta2/grub-core/script/execute.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/script/execute.c
+++ grub-2.02~beta2/grub-core/script/execute.c
@@ -27,6 +27,9 @@
#include <grub/normal.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
+#ifdef GRUB_MACHINE_IEEE1275
+#include <grub/ieee1275/ieee1275.h>
+#endif
/* Max digits for a char is 3 (0xFF is 255), similarly for an int it
is sizeof (int) * 3, and one extra for a possible -ve sign. */
@@ -861,6 +864,10 @@ grub_script_execute_sourcecode (const ch
grub_err_t ret = 0;
struct grub_script *parsed_script;
+#ifdef GRUB_MACHINE_IEEE1275
+ grub_ieee1275_set_boot_last_label (source);
+#endif
+
while (source)
{
char *line;
Index: grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
===================================================================
--- grub-2.02~beta2.orig/include/grub/ieee1275/ieee1275.h
+++ grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
@@ -234,6 +234,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_n
void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *alias);
void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath,
struct grub_ieee1275_devalias *alias);
+int EXPORT_FUNC(grub_ieee1275_cas_reboot) (char *script);
+int EXPORT_FUNC(grub_ieee1275_set_boot_last_label) (const char *text);
#define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));)

View File

@ -1,52 +0,0 @@
From aae96031c1d54796334d5e49f8fbf7144ead1883 Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
Signed-off-by: Tomohiro B Berry <tbberry@us.ibm.com>
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
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"

View File

@ -1,32 +0,0 @@
e5d79c82de59b004d65399e Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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

View File

@ -1,27 +0,0 @@
From f3b10c3a7e098f22a6f3863c3b56a483e3fe96a7 Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
---
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

View File

@ -1,30 +0,0 @@
From ccd71bef390c23fa2e513d6144d16d591279d0a2 Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
---
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

View File

@ -1,48 +0,0 @@
From 36ac10e085ecf53e9c76685e05a1ebe7b5221ca3 Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
---
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

View File

@ -1,47 +0,0 @@
From 12d83a4bded734551415df888bd80b97fdb3d4ad Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
---
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

View File

@ -1,236 +0,0 @@
From c3718600e10e985fe770d13e0110f086256b984f Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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

View File

@ -1,67 +0,0 @@
From ab7a0d7323fd2f6eb4f55da50386378d6a7a7af0 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
Date: Wed, 29 Jan 2014 10:36:41 +1100
Subject: [PATCH 08/23] Fix some more warnings when casting.
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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

View File

@ -1,37 +0,0 @@
From 71a44537c3293d14184901a39f87e2b9d748c8ce Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
Date: Wed, 29 Jan 2014 10:37:54 +1100
Subject: [PATCH 09/23] Add powerpc64 types
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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

View File

@ -1,42 +0,0 @@
From 258ae455c8fdcee9884fa9e4cf432a4d22694ce2 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <linuxram@us.ibm.com>
---
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

View File

@ -1,42 +0,0 @@
From 65dc046ba1f73ae2454ed6495145d645ad452596 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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

View File

@ -1,45 +0,0 @@
From b94389e81084af714c6e6ad71d50e64174018c39 Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
---
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

View File

@ -1,134 +0,0 @@
From 653e20ad39923aace0117fb7b51df27784587652 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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

View File

@ -1,201 +0,0 @@
From dc0b31e8fe09b4143488e85a7aeb7c532e48f81d Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <ppc-asm.h>
+
+#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

View File

@ -1,72 +0,0 @@
From 303109b36a45f53400cbcdaf2ad90ca5790ce1d6 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <anton@samba.org>
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
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 <grub/symbol.h>
#include <grub/offsets.h>
+#include <ppc-asm.h>
.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

View File

@ -1,77 +0,0 @@
From ca7d011e65c6dc1b633c85b7105c807b929598f1 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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

View File

@ -1,310 +0,0 @@
From 96d6b8d370e653386982b808f10a2a67849f73f1 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
Date: Wed, 29 Jan 2014 10:44:46 +1100
Subject: [PATCH 17/23] Add ppc64 relocations
Add ppc64 relocations
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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 <grub/err.h>
#include <grub/i18n.h>
+#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

View File

@ -1,28 +0,0 @@
From 8dc2290890dc8e1cf534b6e44ab44bab4d694da5 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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 <config-util.h>
/* 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

View File

@ -1,76 +0,0 @@
From d63aa12f89bfd5e0cc11983601323694e9a24be7 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
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 <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
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 <http://www.gnu.org/licenses/>.
*/
+#include <ppc-asm.h>
+
.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 <grub/symbol.h>
#include <grub/dl.h>
+#include <ppc-asm.h>
.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

View File

@ -1,67 +0,0 @@
From 8212195e18301ed18a060722e2b5933d2052b2c1 Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
---
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

View File

@ -1,35 +0,0 @@
From 584206ed234f18aab8c9e41e869b539003c56c44 Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
---
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

View File

@ -1,704 +0,0 @@
From 4d0c5500be3cb776345e417c542d6d1fea1a3314 Mon Sep 17 00:00:00 2001
From: Ram Pai <linuxram@us.ibm.com>
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 <linuxram@us.ibm.com>
---
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

View File

@ -38,7 +38,7 @@ Index: grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
===================================================================
--- grub-2.02~beta2.orig/include/grub/ieee1275/ieee1275.h
+++ grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
@@ -147,6 +147,8 @@ enum grub_ieee1275_flag
@@ -145,6 +145,8 @@ enum grub_ieee1275_flag
GRUB_IEEE1275_FLAG_BROKEN_REPEAT,
GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN,

View File

@ -1,20 +0,0 @@
Index: grub-2.02~beta2/grub-core/kern/powerpc/dl.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/kern/powerpc/dl.c
+++ grub-2.02~beta2/grub-core/kern/powerpc/dl.c
@@ -61,6 +61,7 @@ struct trampoline
grub_uint32_t std;
grub_uint32_t addis;
grub_uint32_t addi;
+ grub_uint32_t clrldi;
grub_uint32_t mtctr;
grub_uint32_t bctr;
};
@@ -70,6 +71,7 @@ static const struct trampoline trampolin
0xf8410018, /* std r2,24(r1) */
0x3d800000, /* addis r12,0,0 */
0x398c0000, /* addi r12,r12,0 */
+ 0x798c0020, /* clrldi r12,r12,32 */
0x7d8903a6, /* mtctr r12 */
0x4e800420, /* bctr */
};

View File

@ -3,7 +3,7 @@ Index: grub-2.02~beta2/grub-core/kern/ieee1275/openfw.c
--- grub-2.02~beta2.orig/grub-core/kern/ieee1275/openfw.c
+++ grub-2.02~beta2/grub-core/kern/ieee1275/openfw.c
@@ -302,6 +302,34 @@ grub_ieee1275_map (grub_addr_t phys, gru
return IEEE1275_VALUE(args.catch_result);
return args.catch_result;
}
+/* Preallocate IEEE1275_MAX_MAP_RESOURCE map tracks to track the
@ -62,7 +62,7 @@ Index: grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
#define IEEE1275_MAX_PROP_LEN 8192
#define IEEE1275_MAX_PATH_LEN 256
@@ -216,6 +222,7 @@ int EXPORT_FUNC(grub_ieee1275_millisecon
@@ -214,6 +220,7 @@ int EXPORT_FUNC(grub_ieee1275_millisecon
grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);

View File

@ -1,129 +0,0 @@
diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
index df8943c..896b728 100644
--- a/grub-core/kern/ieee1275/ieee1275.c
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -24,7 +24,15 @@
#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0)
#define IEEE1275_CELL_INVALID ((grub_ieee1275_cell_t) -1)
-
+static grub_ssize_t
+grub_ieee1275_cell2ssize(grub_ieee1275_cell_t value)
+{
+#if GRUB_IEEE1275_CELL_SIZEOF == 4
+ return (grub_ssize_t)(int) value;
+#else
+ return (grub_ssize_t)(long) value;
+#endif
+}
int
grub_ieee1275_finddevice (const char *name, grub_ieee1275_phandle_t *phandlep)
@@ -75,7 +83,7 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
args.size = IEEE1275_VALUE(args.size);
if (actual)
- *actual = (grub_ssize_t) args.size;
+ *actual = grub_ieee1275_cell2ssize(args.size);
if (args.size == IEEE1275_CELL_INVALID)
return -1;
return 0;
@@ -155,7 +163,9 @@ grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle,
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
return -1;
- *length = args.length = IEEE1275_VALUE(args.length);
+
+ args.length = IEEE1275_VALUE(args.length);
+ *length = grub_ieee1275_cell2ssize(args.length);
if (args.length == IEEE1275_CELL_INVALID)
return -1;
return 0;
@@ -209,7 +219,7 @@ grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
args.actual = IEEE1275_VALUE(args.actual);
if (actual)
- *actual = args.actual;
+ *actual = grub_ieee1275_cell2ssize(args.actual);
if (args.actual == IEEE1275_CELL_INVALID)
return -1;
return 0;
@@ -240,7 +250,7 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
args.actual = IEEE1275_VALUE(args.actual);
if (actual)
- *actual = args.actual;
+ *actual = grub_ieee1275_cell2ssize(args.actual);
if (args.actual == IEEE1275_CELL_INVALID)
return -1;
return 0;
@@ -270,10 +280,11 @@ grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer,
return -1;
args.actual = IEEE1275_VALUE(args.actual);
if (actualp)
- *actualp = args.actual;
+ *actualp = grub_ieee1275_cell2ssize(args.actual);
return 0;
}
+
int
grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
grub_size_t len, grub_ssize_t *actualp)
@@ -297,8 +308,7 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
return -1;
args.actual = IEEE1275_VALUE(args.actual);
if (actualp)
- *actualp = args.actual;
-
+ *actualp = grub_ieee1275_cell2ssize(args.actual);
return 0;
}
@@ -332,7 +342,7 @@ grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, grub_disk_addr_t pos,
args.result = IEEE1275_VALUE(args.result);
if (result)
- *result = args.result;
+ *result = grub_ieee1275_cell2ssize(args.result);
return 0;
}
@@ -353,7 +363,8 @@ grub_ieee1275_peer (grub_ieee1275_phandle_t node,
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
return -1;
- *result = args.result = IEEE1275_VALUE(args.result);
+ args.result = IEEE1275_VALUE(args.result);
+ *result = grub_ieee1275_cell2ssize(args.result);
if (args.result == 0)
return -1;
return 0;
@@ -426,7 +437,7 @@ grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch)
return -1;
args.catch = IEEE1275_VALUE(args.catch);
if (catch)
- *catch = args.catch;
+ *catch = grub_ieee1275_cell2ssize(args.catch);
return 0;
}
@@ -576,7 +587,8 @@ grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
return -1;
- *actual = args.actual = IEEE1275_VALUE(args.actual);
+ args.actual = IEEE1275_VALUE(args.actual);
+ *actual = grub_ieee1275_cell2ssize(args.actual);
if ((args.actual == IEEE1275_CELL_INVALID) || (args.actual != args.size))
return -1;
return 0;
@@ -609,7 +621,7 @@ grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
return -1;
- return IEEE1275_VALUE(args.catch_result);
+ return (int) IEEE1275_VALUE(args.catch_result);
}
int

View File

@ -1,3 +1,47 @@
-------------------------------------------------------------------
Fri Jan 29 03:54:15 UTC 2016 - mchang@suse.com
- Add config option to set efi xen loader command line option (bsc#957383)
* added grub2-efi-xen-cmdline.patch
-------------------------------------------------------------------
Thu Jan 28 12:27:27 UTC 2016 - dvaleev@suse.com
- Drop ppc64le patches. Build stage1 as BE for Power
Droped 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-fix-64bit-trampoline-in-dyn-linker.patch
- grub2-ppc64le-timeout.patch
- grub2-ppc64-build-ppc64-32bit.patch
- Added patches:
- biendian.patch
- grub2-ppc64-cas-reboot-support.patch
- libgcc-prereq.patch
- libgcc.patch
- ppc64_opt.patch
- ppc64le.patch
-------------------------------------------------------------------
Wed Jan 20 11:44:27 UTC 2016 - mchang@suse.com

View File

@ -186,8 +186,6 @@ Patch48: 0001-efinet-enable-hardware-filters-when-opening-interfac.patch
Patch51: grub2-xen-legacy-config-device-name.patch
Patch52: grub2-getroot-support-NVMe-device-names.patch
Patch53: grub2-getroot-treat-mdadm-ddf-as-simple-device.patch
Patch54: grub2-efi-xen-chainload.patch
Patch55: grub2-efi-chainloader-root.patch
Patch56: grub2-setup-try-fs-embed-if-mbr-gap-too-small.patch
Patch57: grub2-netboot-hang.patch
Patch58: grub2-xen-linux16.patch
@ -214,34 +212,17 @@ Patch103: grub2-btrfs-03-follow_default.patch
Patch104: grub2-btrfs-04-grub2-install.patch
Patch105: grub2-btrfs-05-grub2-mkconfig.patch
Patch106: grub2-btrfs-06-subvol-mount.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
Patch224: grub2-ppc64-build-ppc64-32bit.patch
Patch225: grub2-ppc64-qemu.patch
Patch226: grub2-ppc64le-timeout.patch
Patch227: grub2-ppc64le-disable-video.patch
Patch228: grub2-ppc64le-memory-map.patch
# Support EFI xen loader
Patch120: grub2-efi-xen-chainload.patch
Patch121: grub2-efi-chainloader-root.patch
Patch122: grub2-efi-xen-cmdline.patch
# PPC64 LE support
Patch201: ppc64le.patch
Patch202: libgcc-prereq.patch
Patch203: libgcc.patch
Patch204: grub2-ppc64-qemu.patch
Patch205: grub2-ppc64le-disable-video.patch
Patch207: grub2-ppc64le-memory-map.patch
Patch229: grub2-xfs-Add-helper-for-inode-size.patch
Patch230: grub2-xfs-Fix-termination-loop-for-directory-iteration.patch
Patch231: grub2-xfs-Convert-inode-numbers-to-cpu-endianity-immediate.patch
@ -250,7 +231,6 @@ Patch233: grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch
Patch234: 0001-Add-bootargs-parser-for-open-firmware.patch
Patch235: 0002-Add-Virtual-LAN-support.patch
Patch236: grub2-efi_gop-avoid-low-resolution.patch
Patch237: grub2-ppc64le-fix-64bit-trampoline-in-dyn-linker.patch
Patch238: grub2-arm64-Reduce-timer-event-frequency-by-10.patch
Patch239: grub2-arm64-set-correct-length.patch
Patch240: grub2-arm64-setjmp-Add-missing-license-macro.patch
@ -269,6 +249,9 @@ Patch271: 0002-i386-tsc-Fix-unused-function-warning-on-xen.patch
Patch272: 0003-acpi-do-not-skip-BIOS-scan-if-EBDA-length-is-zero.patch
Patch273: 0004-tsc-Use-alternative-delay-sources-whenever-appropria.patch
Patch274: 0005-i386-fix-TSC-calibration-using-PIT.patch
Patch275: biendian.patch
Patch276: ppc64_opt.patch
Patch277: grub2-ppc64-cas-reboot-support.patch
Requires: gettext-runtime
%if 0%{?suse_version} >= 1140
@ -469,8 +452,6 @@ mv po/grub.pot po/%{name}.pot
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
@ -495,33 +476,15 @@ mv po/grub.pot po/%{name}.pot
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch120 -p1
%patch121 -p1
%patch122 -p1
%patch201 -p1
%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
%patch224 -p1
%patch225 -p1
%patch226 -p1
%patch227 -p1
%patch228 -p1
%patch229 -p1
%patch230 -p1
%patch231 -p1
@ -530,7 +493,6 @@ mv po/grub.pot po/%{name}.pot
%patch234 -p1
%patch235 -p1
%patch236 -p1
%patch237 -p1
%patch238 -p1
%patch239 -p1
%patch240 -p1
@ -546,6 +508,9 @@ mv po/grub.pot po/%{name}.pot
%patch272 -p1
%patch273 -p1
%patch274 -p1
%patch275 -p1
%patch276 -p1
%patch277 -p1
# Generate po/LINGUAS for message catalogs ...
./linguas.sh

256
libgcc-prereq.patch Normal file
View File

@ -0,0 +1,256 @@
From f371dd5da81701f7bc3d28c67cb4c2c289728691 Mon Sep 17 00:00:00 2001
From: Andrey Borzenkov <arvidjaar@gmail.com>
Date: Sat, 18 Jan 2014 21:22:57 +0400
Subject: [PATCH] fix include loop on MinGW due to libintl.h pulling stdio.h
In file included from ./include/grub/dl.h:23:0,
from grub-core/lib/libgcrypt-grub/cipher/rfc2268.c:3:
./include/grub/list.h:34:18: warning: conflicting types for 'grub_list_push' [en
abled by default]
void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
^
./include/grub/symbol.h:68:25: note: in definition of macro 'EXPORT_FUNC'
# define EXPORT_FUNC(x) x
^
In file included from ./include/grub/fs.h:30:0,
from ./include/grub/file.h:25,
from ./grub-core/lib/posix_wrap/stdio.h:23,
from c:\mingw\include\libintl.h:314,
from ./include/grub/i18n.h:33,
from ./include/grub/misc.h:27,
from ./include/grub/list.h:25,
from ./include/grub/dl.h:28,
from grub-core/lib/libgcrypt-grub/cipher/rfc2268.c:3:
./include/grub/partition.h:106:3: note: previous implicit declaration of 'grub_l
ist_push' was here
grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
^
list.h needs just ATTRIBUTE_ERROR from misc.h; split compiler features
into separate file grub/compiler.h and include it instead.
---
ChangeLog | 14 +++++++++++
grub-core/commands/fileXX.c | 1 +
grub-core/efiemu/prepare.c | 1 +
grub-core/loader/i386/xen_file.c | 1 +
grub-core/loader/i386/xen_fileXX.c | 1 +
grub-core/video/capture.c | 1 +
include/grub/command.h | 1 +
include/grub/compiler.h | 51 ++++++++++++++++++++++++++++++++++++++
include/grub/dl.h | 1 +
include/grub/list.h | 4 +--
include/grub/misc.h | 29 +---------------------
include/grub/procfs.h | 1 +
12 files changed, 76 insertions(+), 30 deletions(-)
create mode 100644 include/grub/compiler.h
diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c
index c9857ff..58e1094 100644
--- a/grub-core/commands/fileXX.c
+++ b/grub-core/commands/fileXX.c
@@ -18,6 +18,7 @@
#include <grub/fileid.h>
#include <grub/elfload.h>
+#include <grub/misc.h>
#pragma GCC diagnostic ignored "-Wcast-align"
diff --git a/grub-core/efiemu/prepare.c b/grub-core/efiemu/prepare.c
index fb1b25d..84c3368 100644
--- a/grub-core/efiemu/prepare.c
+++ b/grub-core/efiemu/prepare.c
@@ -21,6 +21,7 @@
#include <grub/err.h>
#include <grub/mm.h>
#include <grub/types.h>
+#include <grub/misc.h>
#include <grub/efiemu/efiemu.h>
#include <grub/crypto.h>
diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c
index ebbf6aa..ff23235 100644
--- a/grub-core/loader/i386/xen_file.c
+++ b/grub-core/loader/i386/xen_file.c
@@ -18,6 +18,7 @@
#include <grub/xen_file.h>
#include <grub/i386/linux.h>
+#include <grub/misc.h>
grub_elf_t
grub_xen_file (grub_file_t file)
diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c
index 6df0015..73a5f90 100644
--- a/grub-core/loader/i386/xen_fileXX.c
+++ b/grub-core/loader/i386/xen_fileXX.c
@@ -17,6 +17,7 @@
*/
#include <grub/xen_file.h>
+#include <grub/misc.h>
static grub_err_t
parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi,
diff --git a/grub-core/video/capture.c b/grub-core/video/capture.c
index 67c8edd..4f83c74 100644
--- a/grub-core/video/capture.c
+++ b/grub-core/video/capture.c
@@ -4,6 +4,7 @@
#include <grub/video.h>
#include <grub/video_fb.h>
#include <grub/mm.h>
+#include <grub/misc.h>
static struct
{
diff --git a/include/grub/command.h b/include/grub/command.h
index 8705a63..eee4e84 100644
--- a/include/grub/command.h
+++ b/include/grub/command.h
@@ -22,6 +22,7 @@
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/list.h>
+#include <grub/misc.h>
typedef enum grub_command_flags
{
diff --git a/include/grub/compiler.h b/include/grub/compiler.h
new file mode 100644
index 0000000..c9e1d7a
--- /dev/null
+++ b/include/grub/compiler.h
@@ -0,0 +1,51 @@
+/* compiler.h - macros for various compiler features */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_COMPILER_HEADER
+#define GRUB_COMPILER_HEADER 1
+
+/* GCC version checking borrowed from glibc. */
+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
+# define GNUC_PREREQ(maj,min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define GNUC_PREREQ(maj,min) 0
+#endif
+
+/* Does this compiler support compile-time error attributes? */
+#if GNUC_PREREQ(4,3)
+# define ATTRIBUTE_ERROR(msg) \
+ __attribute__ ((__error__ (msg)))
+#else
+# define ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn))
+#endif
+
+#if GNUC_PREREQ(4,4)
+# define GNU_PRINTF gnu_printf
+#else
+# define GNU_PRINTF printf
+#endif
+
+#if GNUC_PREREQ(3,4)
+# define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
+#else
+# define WARN_UNUSED_RESULT
+#endif
+
+#endif /* ! GRUB_COMPILER_HEADER */
diff --git a/include/grub/dl.h b/include/grub/dl.h
index d29a899..9562fa6 100644
--- a/include/grub/dl.h
+++ b/include/grub/dl.h
@@ -26,6 +26,7 @@
#include <grub/types.h>
#include <grub/elf.h>
#include <grub/list.h>
+#include <grub/misc.h>
#endif
/*
diff --git a/include/grub/list.h b/include/grub/list.h
index edd20ad..d170ff6 100644
--- a/include/grub/list.h
+++ b/include/grub/list.h
@@ -21,8 +21,8 @@
#define GRUB_LIST_HEADER 1
#include <grub/symbol.h>
-#include <grub/types.h>
-#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/compiler.h>
struct grub_list
{
diff --git a/include/grub/misc.h b/include/grub/misc.h
index 2cf74b5..c6cd456 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -25,34 +25,7 @@
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/i18n.h>
-
-/* GCC version checking borrowed from glibc. */
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-# define GNUC_PREREQ(maj,min) \
- ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else
-# define GNUC_PREREQ(maj,min) 0
-#endif
-
-/* Does this compiler support compile-time error attributes? */
-#if GNUC_PREREQ(4,3)
-# define ATTRIBUTE_ERROR(msg) \
- __attribute__ ((__error__ (msg)))
-#else
-# define ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn))
-#endif
-
-#if GNUC_PREREQ(4,4)
-# define GNU_PRINTF gnu_printf
-#else
-# define GNU_PRINTF printf
-#endif
-
-#if GNUC_PREREQ(3,4)
-# define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
-#else
-# define WARN_UNUSED_RESULT
-#endif
+#include <grub/compiler.h>
#define ALIGN_UP(addr, align) \
((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
diff --git a/include/grub/procfs.h b/include/grub/procfs.h
index d393da7..8cc331d 100644
--- a/include/grub/procfs.h
+++ b/include/grub/procfs.h
@@ -20,6 +20,7 @@
#define GRUB_PROCFS_HEADER 1
#include <grub/list.h>
+#include <grub/types.h>
struct grub_procfs_entry
{
--
2.1.4

440
libgcc.patch Normal file
View File

@ -0,0 +1,440 @@
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Wed, 13 Aug 2014 19:00:19 +0000
Subject: [PATCH 142/143] Files reorganization and include some libgcc fuctions
As we avoid libgcc dependency for powerpc64el, we moved some functions
to other files and add the necessary ones.
* Makefile.core.def: Include compiler-rt.S.
* misc.c: Add the necessary libgcc functions.
* compiler-rt.S: New file.
* libgcc.h: Move some content from here ...
* compiler.h: ... to here.
Also-By: Brent Baude <bbaude@redhat.com>
Also-By: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
---
grub-core/Makefile.core.def | 1 +
grub-core/kern/misc.c | 107 ++++++++++++++++++++++++++++
grub-core/kern/powerpc/compiler-rt.S | 130 +++++++++++++++++++++++++++++++++++
include/grub/compiler.h | 61 ++++++++++++++++
include/grub/libgcc.h | 67 ------------------
5 files changed, 299 insertions(+), 67 deletions(-)
create mode 100644 grub-core/kern/powerpc/compiler-rt.S
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
@@ -252,6 +252,7 @@ kernel = {
powerpc_ieee1275 = kern/powerpc/cache.S;
powerpc_ieee1275 = kern/powerpc/dl.c;
+ powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
sparc64_ieee1275 = kern/sparc64/cache.S;
sparc64_ieee1275 = kern/sparc64/dl.c;
Index: grub-2.02~beta2/grub-core/kern/misc.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/kern/misc.c
+++ grub-2.02~beta2/grub-core/kern/misc.c
@@ -1339,3 +1339,110 @@ grub_real_boot_time (const char *file,
grub_error_pop ();
}
#endif
+
+#if defined (NO_LIBGCC)
+
+/* Based on libgcc2.c from gcc suite. */
+int
+__ucmpdi2 (grub_uint64_t a, grub_uint64_t b)
+{
+ union component64 ac, bc;
+ ac.full = a;
+ bc.full = b;
+
+ if (ac.high < bc.high)
+ return 0;
+ else if (ac.high > bc.high)
+ return 2;
+
+ if (ac.low < bc.low)
+ return 0;
+ else if (ac.low > bc.low)
+ return 2;
+ return 1;
+}
+
+
+/* Based on libgcc2.c from gcc suite. */
+grub_uint64_t
+__lshrdi3 (grub_uint64_t u, int b)
+{
+ if (b == 0)
+ return u;
+
+ const union component64 uu = {.full = u};
+ const int bm = 32 - b;
+ union component64 w;
+
+ if (bm <= 0)
+ {
+ w.high = 0;
+ w.low = (grub_uint32_t) uu.high >> -bm;
+ }
+ else
+ {
+ const grub_uint32_t carries = (grub_uint32_t) uu.high << bm;
+
+ w.high = (grub_uint32_t) uu.high >> b;
+ w.low = ((grub_uint32_t) uu.low >> b) | carries;
+ }
+
+ return w.full;
+}
+
+/* Based on libgcc2.c from gcc suite. */
+grub_uint64_t
+__ashrdi3 (grub_uint64_t u, int b)
+{
+ if (b == 0)
+ return u;
+
+ const union component64 uu = {.full = u};
+ const int bm = 32 - b;
+ union component64 w;
+
+ if (bm <= 0)
+ {
+ /* w.high = 1..1 or 0..0 */
+ w.high = uu.high >> (32 - 1);
+ w.low = uu.high >> -bm;
+ }
+ else
+ {
+ const grub_uint32_t carries = (grub_uint32_t) uu.high << bm;
+
+ w.high = uu.high >> b;
+ w.low = ((grub_uint32_t) uu.low >> b) | carries;
+ }
+
+ return w.full;
+}
+
+/* Based on libgcc2.c from gcc suite. */
+grub_uint64_t
+__ashldi3 (grub_uint64_t u, int b)
+{
+ if (b == 0)
+ return u;
+
+ const union component64 uu = {.full = u};
+ const int bm = 32 - b;
+ union component64 w;
+
+ if (bm <= 0)
+ {
+ w.low = 0;
+ w.high = (grub_uint32_t) uu.low << -bm;
+ }
+ else
+ {
+ const grub_uint32_t carries = (grub_uint32_t) uu.low >> bm;
+
+ w.low = (grub_uint32_t) uu.low << b;
+ w.high = ((grub_uint32_t) uu.high << b) | carries;
+ }
+
+ return w.full;
+}
+
+#endif
Index: grub-2.02~beta2/grub-core/kern/powerpc/compiler-rt.S
===================================================================
--- /dev/null
+++ grub-2.02~beta2/grub-core/kern/powerpc/compiler-rt.S
@@ -0,0 +1,130 @@
+/*
+ * Special support for eabi and SVR4
+ *
+ * Copyright (C) 1995-2014 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 3, or (at your option) any
+ * later version.
+ *
+ * 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.
+ *
+ * Under Section 7 of GPL version 3, you are granted additional
+ * permissions described in the GCC Runtime Library Exception, version
+ * 3.1, as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License and
+ * a copy of the GCC Runtime Library Exception along with this program;
+ * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/* Do any initializations needed for the eabi environment */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+
+ .section ".text"
+
+#define CFI_RESTORE(reg) .cfi_restore reg
+#define CFI_OFFSET(reg, off) .cfi_offset reg, off
+#define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg
+#define CFI_STARTPROC .cfi_startproc
+#define CFI_ENDPROC .cfi_endproc
+
+/* 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. */
+
+CFI_STARTPROC
+CFI_DEF_CFA_REGISTER (11)
+CFI_OFFSET (65, 4)
+CFI_OFFSET (14, -72)
+CFI_OFFSET (15, -68)
+CFI_OFFSET (16, -64)
+CFI_OFFSET (17, -60)
+CFI_OFFSET (18, -56)
+CFI_OFFSET (19, -52)
+CFI_OFFSET (20, -48)
+CFI_OFFSET (21, -44)
+CFI_OFFSET (22, -40)
+CFI_OFFSET (23, -36)
+CFI_OFFSET (24, -32)
+CFI_OFFSET (25, -28)
+CFI_OFFSET (26, -24)
+CFI_OFFSET (27, -20)
+CFI_OFFSET (28, -16)
+CFI_OFFSET (29, -12)
+CFI_OFFSET (30, -8)
+CFI_OFFSET (31, -4)
+FUNCTION(_restgpr_14_x) lwz 14,-72(11) /* restore gp registers */
+CFI_RESTORE (14)
+FUNCTION(_restgpr_15_x) lwz 15,-68(11)
+CFI_RESTORE (15)
+FUNCTION(_restgpr_16_x) lwz 16,-64(11)
+CFI_RESTORE (16)
+FUNCTION(_restgpr_17_x) lwz 17,-60(11)
+CFI_RESTORE (17)
+FUNCTION(_restgpr_18_x) lwz 18,-56(11)
+CFI_RESTORE (18)
+FUNCTION(_restgpr_19_x) lwz 19,-52(11)
+CFI_RESTORE (19)
+FUNCTION(_restgpr_20_x) lwz 20,-48(11)
+CFI_RESTORE (20)
+FUNCTION(_restgpr_21_x) lwz 21,-44(11)
+CFI_RESTORE (21)
+FUNCTION(_restgpr_22_x) lwz 22,-40(11)
+CFI_RESTORE (22)
+FUNCTION(_restgpr_23_x) lwz 23,-36(11)
+CFI_RESTORE (23)
+FUNCTION(_restgpr_24_x) lwz 24,-32(11)
+CFI_RESTORE (24)
+FUNCTION(_restgpr_25_x) lwz 25,-28(11)
+CFI_RESTORE (25)
+FUNCTION(_restgpr_26_x) lwz 26,-24(11)
+CFI_RESTORE (26)
+FUNCTION(_restgpr_27_x) lwz 27,-20(11)
+CFI_RESTORE (27)
+FUNCTION(_restgpr_28_x) lwz 28,-16(11)
+CFI_RESTORE (28)
+FUNCTION(_restgpr_29_x) lwz 29,-12(11)
+CFI_RESTORE (29)
+FUNCTION(_restgpr_30_x) lwz 30,-8(11)
+CFI_RESTORE (30)
+FUNCTION(_restgpr_31_x) lwz 0,4(11)
+ lwz 31,-4(11)
+CFI_RESTORE (31)
+ mtlr 0
+CFI_RESTORE (65)
+ mr 1,11
+CFI_DEF_CFA_REGISTER (1)
+ blr
+CFI_ENDPROC
+
+CFI_STARTPROC
+FUNCTION(_savegpr_14) stw 14,-72(11) /* save gp registers */
+FUNCTION(_savegpr_15) stw 15,-68(11)
+FUNCTION(_savegpr_16) stw 16,-64(11)
+FUNCTION(_savegpr_17) stw 17,-60(11)
+FUNCTION(_savegpr_18) stw 18,-56(11)
+FUNCTION(_savegpr_19) stw 19,-52(11)
+FUNCTION(_savegpr_20) stw 20,-48(11)
+FUNCTION(_savegpr_21) stw 21,-44(11)
+FUNCTION(_savegpr_22) stw 22,-40(11)
+FUNCTION(_savegpr_23) stw 23,-36(11)
+FUNCTION(_savegpr_24) stw 24,-32(11)
+FUNCTION(_savegpr_25) stw 25,-28(11)
+FUNCTION(_savegpr_26) stw 26,-24(11)
+FUNCTION(_savegpr_27) stw 27,-20(11)
+FUNCTION(_savegpr_28) stw 28,-16(11)
+FUNCTION(_savegpr_29) stw 29,-12(11)
+FUNCTION(_savegpr_30) stw 30,-8(11)
+FUNCTION(_savegpr_31) stw 31,-4(11)
+ blr
+CFI_ENDPROC
Index: grub-2.02~beta2/include/grub/compiler.h
===================================================================
--- grub-2.02~beta2.orig/include/grub/compiler.h
+++ grub-2.02~beta2/include/grub/compiler.h
@@ -48,4 +48,65 @@
# define WARN_UNUSED_RESULT
#endif
+#include "types.h"
+
+union component64
+{
+ grub_uint64_t full;
+ struct
+ {
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ grub_uint32_t high;
+ grub_uint32_t low;
+#else
+ grub_uint32_t low;
+ grub_uint32_t high;
+#endif
+ };
+};
+
+#if defined (__powerpc__)
+grub_uint64_t EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b);
+grub_uint64_t EXPORT_FUNC (__ashrdi3) (grub_uint64_t u, int b);
+grub_uint64_t EXPORT_FUNC (__ashldi3) (grub_uint64_t u, int b);
+int EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b);
+void EXPORT_FUNC (_restgpr_14_x) (void);
+void EXPORT_FUNC (_restgpr_15_x) (void);
+void EXPORT_FUNC (_restgpr_16_x) (void);
+void EXPORT_FUNC (_restgpr_17_x) (void);
+void EXPORT_FUNC (_restgpr_18_x) (void);
+void EXPORT_FUNC (_restgpr_19_x) (void);
+void EXPORT_FUNC (_restgpr_20_x) (void);
+void EXPORT_FUNC (_restgpr_21_x) (void);
+void EXPORT_FUNC (_restgpr_22_x) (void);
+void EXPORT_FUNC (_restgpr_23_x) (void);
+void EXPORT_FUNC (_restgpr_24_x) (void);
+void EXPORT_FUNC (_restgpr_25_x) (void);
+void EXPORT_FUNC (_restgpr_26_x) (void);
+void EXPORT_FUNC (_restgpr_27_x) (void);
+void EXPORT_FUNC (_restgpr_28_x) (void);
+void EXPORT_FUNC (_restgpr_29_x) (void);
+void EXPORT_FUNC (_restgpr_30_x) (void);
+void EXPORT_FUNC (_restgpr_31_x) (void);
+void EXPORT_FUNC (_savegpr_14) (void);
+void EXPORT_FUNC (_savegpr_15) (void);
+void EXPORT_FUNC (_savegpr_16) (void);
+void EXPORT_FUNC (_savegpr_17) (void);
+void EXPORT_FUNC (_savegpr_18) (void);
+void EXPORT_FUNC (_savegpr_19) (void);
+void EXPORT_FUNC (_savegpr_20) (void);
+void EXPORT_FUNC (_savegpr_21) (void);
+void EXPORT_FUNC (_savegpr_22) (void);
+void EXPORT_FUNC (_savegpr_23) (void);
+void EXPORT_FUNC (_savegpr_24) (void);
+void EXPORT_FUNC (_savegpr_25) (void);
+void EXPORT_FUNC (_savegpr_26) (void);
+void EXPORT_FUNC (_savegpr_27) (void);
+void EXPORT_FUNC (_savegpr_28) (void);
+void EXPORT_FUNC (_savegpr_29) (void);
+void EXPORT_FUNC (_savegpr_30) (void);
+void EXPORT_FUNC (_savegpr_31) (void);
+
+#endif
+
#endif /* ! GRUB_COMPILER_HEADER */
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
@@ -16,79 +16,6 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
-/* We need to include config-util.h.in for HAVE_*. */
-#ifndef __STDC_VERSION__
-#define __STDC_VERSION__ 0
-#endif
-#include <config-util.h>
-
-/* On x86 these functions aren't really needed. Save some space. */
-#if !defined (__i386__) && !defined (__x86_64__)
-# ifdef HAVE___ASHLDI3
-void EXPORT_FUNC (__ashldi3) (void);
-# endif
-# ifdef HAVE___ASHRDI3
-void EXPORT_FUNC (__ashrdi3) (void);
-# endif
-# ifdef HAVE___LSHRDI3
-void EXPORT_FUNC (__lshrdi3) (void);
-# endif
-# ifdef HAVE___UCMPDI2
-void EXPORT_FUNC (__ucmpdi2) (void);
-# endif
-# ifdef HAVE___BSWAPSI2
-void EXPORT_FUNC (__bswapsi2) (void);
-# endif
-# ifdef HAVE___BSWAPDI2
-void EXPORT_FUNC (__bswapdi2) (void);
-# endif
-# ifdef HAVE___CTZDI2
-void EXPORT_FUNC (__ctzdi2) (void);
-# endif
-# ifdef HAVE___CTZSI2
-void EXPORT_FUNC (__ctzsi2) (void);
-# endif
-#endif
-
-#ifdef HAVE__RESTGPR_14_X
-void EXPORT_FUNC (_restgpr_14_x) (void);
-void EXPORT_FUNC (_restgpr_15_x) (void);
-void EXPORT_FUNC (_restgpr_16_x) (void);
-void EXPORT_FUNC (_restgpr_17_x) (void);
-void EXPORT_FUNC (_restgpr_18_x) (void);
-void EXPORT_FUNC (_restgpr_19_x) (void);
-void EXPORT_FUNC (_restgpr_20_x) (void);
-void EXPORT_FUNC (_restgpr_21_x) (void);
-void EXPORT_FUNC (_restgpr_22_x) (void);
-void EXPORT_FUNC (_restgpr_23_x) (void);
-void EXPORT_FUNC (_restgpr_24_x) (void);
-void EXPORT_FUNC (_restgpr_25_x) (void);
-void EXPORT_FUNC (_restgpr_26_x) (void);
-void EXPORT_FUNC (_restgpr_27_x) (void);
-void EXPORT_FUNC (_restgpr_28_x) (void);
-void EXPORT_FUNC (_restgpr_29_x) (void);
-void EXPORT_FUNC (_restgpr_30_x) (void);
-void EXPORT_FUNC (_restgpr_31_x) (void);
-void EXPORT_FUNC (_savegpr_14) (void);
-void EXPORT_FUNC (_savegpr_15) (void);
-void EXPORT_FUNC (_savegpr_16) (void);
-void EXPORT_FUNC (_savegpr_17) (void);
-void EXPORT_FUNC (_savegpr_18) (void);
-void EXPORT_FUNC (_savegpr_19) (void);
-void EXPORT_FUNC (_savegpr_20) (void);
-void EXPORT_FUNC (_savegpr_21) (void);
-void EXPORT_FUNC (_savegpr_22) (void);
-void EXPORT_FUNC (_savegpr_23) (void);
-void EXPORT_FUNC (_savegpr_24) (void);
-void EXPORT_FUNC (_savegpr_25) (void);
-void EXPORT_FUNC (_savegpr_26) (void);
-void EXPORT_FUNC (_savegpr_27) (void);
-void EXPORT_FUNC (_savegpr_28) (void);
-void EXPORT_FUNC (_savegpr_29) (void);
-void EXPORT_FUNC (_savegpr_30) (void);
-void EXPORT_FUNC (_savegpr_31) (void);
-#endif
-
#if defined (__arm__)
void EXPORT_FUNC (__aeabi_lasr) (void);
void EXPORT_FUNC (__aeabi_llsl) (void);

26
ppc64_opt.patch Normal file
View File

@ -0,0 +1,26 @@
From afd0f21b2027310fda52b00ac1b964041d39a363 Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Mon, 15 Jun 2015 09:10:19 -0300
Subject: [PATCH] Add flag for powerpc ieee1275 to avoid unneeded optimizations
---
conf/Makefile.common | 3 +++
1 file changed, 3 insertions(+)
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 96e58c9..fcb8d2e 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -17,6 +17,9 @@ endif
if COND_arm64
CFLAGS_PLATFORM += -mcmodel=large
endif
+if COND_powerpc_ieee1275
+ CFLAGS_PLATFORM += -mcpu=powerpc
+endif
#FIXME: discover and check XEN headers
CPPFLAGS_XEN = -I/usr/include
--
2.1.4

95
ppc64le.patch Normal file
View File

@ -0,0 +1,95 @@
From 8014cad21bb2cc986f10f0a927036851f490a8ec Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Wed, 13 Aug 2014 18:59:58 +0000
Subject: [PATCH 141/143] Add powerpc little-endian (ppc64le) flags
libgcc dependency was removed *just* for this target because
the distros that use ppc64el doesn't have 32-bit support on it.
* configure.ac: Add targets for powerpc64el and skip libgcc.
* Makefile.am: Likewise.
---
configure.ac | 17 +++++++++++++++--
grub-core/Makefile.am | 2 ++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2632e2d..53fd7c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,6 +142,7 @@ if test "x$with_platform" = x; then
x86_64-*) platform=pc ;;
powerpc-*) platform=ieee1275 ;;
powerpc64-*) platform=ieee1275 ;;
+ powerpc64le-*) platform=ieee1275 ;;
sparc64-*) platform=ieee1275 ;;
mipsel-*) platform=loongson ;;
mips-*) platform=arc ;;
@@ -160,6 +161,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.
@@ -604,6 +606,13 @@ if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
fi
+if test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno; then
+ LD_FORCE_LE=1
+ TARGET_CFLAGS="$TARGET_CFLAGS -mbig-endian -DNO_LIBGCC=1"
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mbig-endian"
+ TARGET_LDFLAGS="$TARGET_LDFLAGS -static -mbig-endian"
+fi
+
if test "x$target_m32" = x1; then
# Force 32-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
@@ -1047,7 +1056,8 @@ 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$grub_cv_cc_target_clang" = xyes \
+ || ( test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno ); then
TARGET_LIBGCC=
else
TARGET_LIBGCC=-lgcc
@@ -1631,7 +1641,9 @@ if test x"$enable_werror" != xno ; then
HOST_CFLAGS="$HOST_CFLAGS -Werror"
fi
-if test "x$grub_cv_cc_target_clang" = xno; then
+# if not clang or power LE, use static libgcc
+if test "x$grub_cv_cc_target_clang" = xno \
+ || ! ( test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno ); then
TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
else
TARGET_LDFLAGS_STATIC_LIBGCC=
@@ -1694,6 +1706,7 @@ AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu =
AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
+AM_CONDITIONAL([COND_powerpc_le], [test x$target_cpu = xpowerpc -a x$ac_cv_c_bigendian = xno])
AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
index 5c087c8..cb7fd9f 100644
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -84,8 +84,10 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
if !COND_clang
+if !COND_powerpc_le
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
endif
+endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
if COND_i386_pc
--
1.9.3