forked from pool/grub2
eafb269f9e
- 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 OBS-URL: https://build.opensuse.org/request/show/356507 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=202
171 lines
6.1 KiB
Diff
171 lines
6.1 KiB
Diff
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));)
|
|
|