Blob Blame History Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 11 Jul 2018 13:47:56 -0400
Subject: [PATCH] Make the "reboot" module be linked more like the "exit"
 module.

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 grub-core/Makefile.core.def         |  5 +++--
 grub-core/commands/efi/efifwsetup.c |  2 +-
 grub-core/kern/efi/efi.c            |  2 +-
 grub-core/lib/efi/reboot.c          | 29 +++++++++++++++++++++++++++++
 include/grub/efi/efi.h              |  1 +
 include/grub/misc.h                 |  3 +--
 6 files changed, 36 insertions(+), 6 deletions(-)
 create mode 100644 grub-core/lib/efi/reboot.c

diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 2851437e098..9b39c8e3cea 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -889,8 +889,8 @@ module = {
 
 module = {
   name = reboot;
-  i386 = lib/i386/reboot.c;
-  i386 = lib/i386/reboot_trampoline.S;
+  i386_pc = lib/i386/reboot.c;
+  i386_pc = lib/i386/reboot_trampoline.S;
   powerpc_ieee1275 = lib/ieee1275/reboot.c;
   sparc64_ieee1275 = lib/ieee1275/reboot.c;
   mips_arc = lib/mips/arc/reboot.c;
@@ -899,6 +899,7 @@ module = {
   xen = lib/xen/reboot.c;
   uboot = lib/uboot/reboot.c;
   arm_coreboot = lib/dummy/reboot.c;
+  efi = lib/efi/reboot.c;
   common = commands/reboot.c;
 };
 
diff --git a/grub-core/commands/efi/efifwsetup.c b/grub-core/commands/efi/efifwsetup.c
index 7a137a72a2f..be11c08a9ae 100644
--- a/grub-core/commands/efi/efifwsetup.c
+++ b/grub-core/commands/efi/efifwsetup.c
@@ -49,7 +49,7 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
   if (status != GRUB_ERR_NONE)
     return status;
 
-  grub_reboot ();
+  grub_efi_reboot ();
 
   return GRUB_ERR_BUG;
 }
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index 4d36fe31177..c54cb5df1fc 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -155,7 +155,7 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle)
 }
 
 void
-grub_reboot (void)
+grub_efi_reboot (void)
 {
   grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
   efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
diff --git a/grub-core/lib/efi/reboot.c b/grub-core/lib/efi/reboot.c
new file mode 100644
index 00000000000..6934a3b369e
--- /dev/null
+++ b/grub-core/lib/efi/reboot.c
@@ -0,0 +1,29 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2013  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 <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/kernel.h>
+#include <grub/loader.h>
+#include <grub/efi/efi.h>
+
+void
+grub_reboot (void)
+{
+  grub_efi_reboot();
+}
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 570a69361a5..3f02db48279 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -29,6 +29,7 @@ extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table);
 extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle);
 
 /* Functions.  */
+void EXPORT_FUNC(grub_efi_reboot) (void) __attribute__ ((noreturn));
 void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol,
 					     void *registration);
 grub_efi_handle_t *
diff --git a/include/grub/misc.h b/include/grub/misc.h
index 5f1c1c1be4e..4607e8defa9 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -444,8 +444,7 @@ grub_abs (int x)
 }
 
 /* Reboot the machine.  */
-#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) || \
-    defined (GRUB_MACHINE_EFI)
+#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS)
 void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn));
 #else
 void grub_reboot (void) __attribute__ ((noreturn));