forked from pool/grub2
8ee92f5194
- Implement NV index mode for TPM 2.0 key protector 0001-protectors-Implement-NV-index.patch - Fall back to passphrase mode when the key protector fails to unlock the disk 0002-cryptodisk-Fallback-to-passphrase.patch - Wipe out the cached key cleanly 0003-cryptodisk-wipe-out-the-cached-keys-from-protectors.patch - Make diskfiler to look up cryptodisk devices first 0004-diskfilter-look-up-cryptodisk-devices-first.patch - Version bump to 2.12~rc1 * Added: - grub-2.12~rc1.tar.xz * Removed: - grub-2.06.tar.xz * Patch dropped merged by new version: - grub2-GRUB_CMDLINE_LINUX_RECOVERY-for-recovery-mode.patch - grub2-s390x-02-kexec-module-added-to-emu.patch - grub2-efi-chainloader-root.patch - grub2-Fix-incorrect-netmask-on-ppc64.patch - 0001-osdep-Introduce-include-grub-osdep-major.h-and-use-i.patch - 0002-osdep-linux-hostdisk-Use-stat-instead-of-udevadm-for.patch - 0002-net-read-bracketed-ipv6-addrs-and-port-numbers.patch - grub2-s390x-10-keep-network-at-kexec.patch - 0001-Fix-build-error-in-binutils-2.36.patch - 0001-emu-fix-executable-stack-marking.patch - 0046-squash-verifiers-Move-verifiers-API-to-kernel-image.patch - 0001-30_uefi-firmware-fix-printf-format-with-null-byte.patch - 0001-tpm-Pass-unknown-error-as-non-fatal-but-debug-print-.patch - 0001-Filter-out-POSIX-locale-for-translation.patch OBS-URL: https://build.opensuse.org/request/show/1105405 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=458
167 lines
5.4 KiB
Diff
167 lines
5.4 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(+)
|
|
|
|
--- a/grub-core/kern/ieee1275/openfw.c
|
|
+++ b/grub-core/kern/ieee1275/openfw.c
|
|
@@ -593,6 +593,69 @@
|
|
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;
|
|
+}
|
|
+
|
|
char *
|
|
grub_ieee1275_get_boot_dev (void)
|
|
{
|
|
--- a/grub-core/normal/main.c
|
|
+++ b/grub-core/normal/main.c
|
|
@@ -34,6 +34,9 @@
|
|
#include <grub/charset.h>
|
|
#include <grub/script_sh.h>
|
|
#include <grub/bufio.h>
|
|
+#ifdef GRUB_MACHINE_IEEE1275
|
|
+#include <grub/ieee1275/ieee1275.h>
|
|
+#endif
|
|
|
|
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
|
@@ -276,6 +279,21 @@
|
|
{
|
|
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;
|
|
}
|
|
--- a/grub-core/script/execute.c
|
|
+++ b/grub-core/script/execute.c
|
|
@@ -28,6 +28,9 @@
|
|
#include <grub/extcmd.h>
|
|
#include <grub/i18n.h>
|
|
#include <grub/verify.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. */
|
|
@@ -883,6 +886,10 @@
|
|
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;
|
|
--- a/include/grub/ieee1275/ieee1275.h
|
|
+++ b/include/grub/ieee1275/ieee1275.h
|
|
@@ -256,6 +256,8 @@
|
|
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);
|
|
|
|
char *EXPORT_FUNC(grub_ieee1275_get_boot_dev) (void);
|
|
|