Commit c4bb687a authored by Matt Fleming's avatar Matt Fleming Committed by Luis Henriques

efi/reboot: Add generic wrapper around EfiResetSystem()

commit 8562c99c upstream.

Implement efi_reboot(), which is really just a wrapper around the
EfiResetSystem() EFI runtime service, but it does at least allow us to
funnel all callers through a single location.

It also simplifies the callsites since users no longer need to check to
see whether EFI_RUNTIME_SERVICES are enabled.

Cc: Tony Luck <tony.luck@intel.com>
Tested-by: default avatarMark Salter <msalter@redhat.com>
Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent ddef2b7f
...@@ -662,7 +662,7 @@ void ...@@ -662,7 +662,7 @@ void
machine_restart (char *restart_cmd) machine_restart (char *restart_cmd)
{ {
(void) notify_die(DIE_MACHINE_RESTART, restart_cmd, NULL, 0, 0, 0); (void) notify_die(DIE_MACHINE_RESTART, restart_cmd, NULL, 0, 0, 0);
(*efi.reset_system)(EFI_RESET_WARM, 0, 0, NULL); efi_reboot(REBOOT_WARM, NULL);
} }
void void
......
...@@ -538,11 +538,7 @@ static void native_machine_emergency_restart(void) ...@@ -538,11 +538,7 @@ static void native_machine_emergency_restart(void)
break; break;
case BOOT_EFI: case BOOT_EFI:
if (efi_enabled(EFI_RUNTIME_SERVICES)) efi_reboot(reboot_mode, NULL);
efi.reset_system(reboot_mode == REBOOT_WARM ?
EFI_RESET_WARM :
EFI_RESET_COLD,
EFI_SUCCESS, 0, NULL);
reboot_type = BOOT_BIOS; reboot_type = BOOT_BIOS;
break; break;
......
# #
# Makefile for linux kernel # Makefile for linux kernel
# #
obj-$(CONFIG_EFI) += efi.o vars.o obj-$(CONFIG_EFI) += efi.o vars.o reboot.o
obj-$(CONFIG_EFI_VARS) += efivars.o obj-$(CONFIG_EFI_VARS) += efivars.o
obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o
obj-$(CONFIG_UEFI_CPER) += cper.o obj-$(CONFIG_UEFI_CPER) += cper.o
......
/*
* Copyright (C) 2014 Intel Corporation; author Matt Fleming
* Copyright (c) 2014 Red Hat, Inc., Mark Salter <msalter@redhat.com>
*/
#include <linux/efi.h>
#include <linux/reboot.h>
void efi_reboot(enum reboot_mode reboot_mode, const char *__unused)
{
int efi_mode;
if (!efi_enabled(EFI_RUNTIME_SERVICES))
return;
switch (reboot_mode) {
case REBOOT_WARM:
case REBOOT_SOFT:
efi_mode = EFI_RESET_WARM;
break;
default:
efi_mode = EFI_RESET_COLD;
break;
}
efi.reset_system(efi_mode, EFI_SUCCESS, 0, NULL);
}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/pfn.h> #include <linux/pfn.h>
#include <linux/pstore.h> #include <linux/pstore.h>
#include <linux/reboot.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -926,11 +927,14 @@ static inline bool efi_enabled(int feature) ...@@ -926,11 +927,14 @@ static inline bool efi_enabled(int feature)
{ {
return test_bit(feature, &efi.flags) != 0; return test_bit(feature, &efi.flags) != 0;
} }
extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
#else #else
static inline bool efi_enabled(int feature) static inline bool efi_enabled(int feature)
{ {
return false; return false;
} }
static inline void
efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {}
#endif #endif
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment