efi/reboot: Add generic wrapper around EfiResetSystem()

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 <[email protected]>
Tested-by: Mark Salter <[email protected]>
Signed-off-by: Matt Fleming <[email protected]>
This commit is contained in:
Matt Fleming 2014-06-13 12:22:22 +01:00
commit 8562c99cdd
5 changed files with 33 additions and 7 deletions

View file

@ -1,7 +1,7 @@
#
# 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_PSTORE) += efi-pstore.o
obj-$(CONFIG_UEFI_CPER) += cper.o

View file

@ -0,0 +1,26 @@
/*
* 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);
}