iPXE
Functions
efi_reboot.c File Reference

EFI reboot mechanism. More...

#include <errno.h>
#include <string.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Guid/GlobalVariable.h>
#include <ipxe/reboot.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void efi_reboot (int flags)
 Reboot system. More...
 
static int efi_poweroff (void)
 Power off system. More...
 
 PROVIDE_REBOOT (efi, reboot, efi_reboot)
 
 PROVIDE_REBOOT (efi, poweroff, efi_poweroff)
 

Detailed Description

EFI reboot mechanism.

Definition in file efi_reboot.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_reboot()

static void efi_reboot ( int  flags)
static

Reboot system.

Parameters
flagsReboot flags

Definition at line 44 of file efi_reboot.c.

44  {
47  UINT64 osind;
48  UINT32 attrs;
50  EFI_STATUS efirc;
51  int rc;
52 
53  /* Request boot to firmware setup, if applicable */
54  if ( flags & REBOOT_SETUP ) {
59  if ( ( efirc = rs->SetVariable ( wname, &efi_global_variable,
60  attrs, sizeof ( osind ),
61  &osind ) ) != 0 ) {
62  rc = -EEFI ( efirc );
63  DBGC ( efi_systab, "EFI could not set %ls: %s\n",
64  wname, strerror ( rc ) );
65  /* Continue to reboot anyway */
66  }
67  }
68 
69  /* Use runtime services to reset system */
71  rs->ResetSystem ( type, 0, 0, NULL );
72 }
#define EFI_VARIABLE_RUNTIME_ACCESS
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:174
EFI_RESET_TYPE
Enumeration of reset types.
uint32_t type
Operating system type.
Definition: ena.h:12
#define REBOOT_SETUP
Reboot to firmware setup.
Definition: reboot.h:59
#define DBGC(...)
Definition: compiler.h:505
#define EFI_VARIABLE_BOOTSERVICE_ACCESS
unsigned int UINT32
Definition: ProcessorBind.h:98
unsigned short CHAR16
#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI
Definition: UefiSpec.h:1843
Used to induce a system-wide reset.
Used to induce a system-wide initialization.
#define EFI_OS_INDICATIONS_VARIABLE_NAME
Allows the OS to request the firmware to enable certain features and to take certain actions.
EFI_SET_VARIABLE SetVariable
Definition: UefiSpec.h:1904
EFI_GUID efi_global_variable
Global variable GUID.
Definition: efi_guid.c:468
EFI Runtime Services Table.
Definition: UefiSpec.h:1879
EFI_RESET_SYSTEM ResetSystem
Definition: UefiSpec.h:1910
uint8_t flags
Flags.
Definition: ena.h:18
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define REBOOT_WARM
Perform a warm reboot.
Definition: reboot.h:58
unsigned long long UINT64
Definition: ProcessorBind.h:96
EFI_RUNTIME_SERVICES * RuntimeServices
A pointer to the EFI Runtime Services Table.
Definition: UefiSpec.h:2094
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_SYSTEM_TABLE * efi_systab
#define EFI_VARIABLE_NON_VOLATILE
Attributes of variable.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References DBGC, EEFI, efi_global_variable, EFI_OS_INDICATIONS_BOOT_TO_FW_UI, EFI_OS_INDICATIONS_VARIABLE_NAME, efi_systab, EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE, EFI_VARIABLE_RUNTIME_ACCESS, EfiResetCold, EfiResetWarm, flags, NULL, rc, REBOOT_SETUP, REBOOT_WARM, EFI_RUNTIME_SERVICES::ResetSystem, EFI_SYSTEM_TABLE::RuntimeServices, EFI_RUNTIME_SERVICES::SetVariable, strerror(), and type.

◆ efi_poweroff()

static int efi_poweroff ( void  )
static

Power off system.

Return values
rcReturn status code

Definition at line 79 of file efi_reboot.c.

79  {
81 
82  /* Use runtime services to power off system */
83  rs->ResetSystem ( EfiResetShutdown, 0, 0, NULL );
84 
85  /* Should never happen */
86  return -ECANCELED;
87 }
#define ECANCELED
Operation canceled.
Definition: errno.h:343
EFI Runtime Services Table.
Definition: UefiSpec.h:1879
EFI_RESET_SYSTEM ResetSystem
Definition: UefiSpec.h:1910
Used to induce an entry into a power state equivalent to the ACPI G2/S5 or G3 state.
EFI_RUNTIME_SERVICES * RuntimeServices
A pointer to the EFI Runtime Services Table.
Definition: UefiSpec.h:2094
EFI_SYSTEM_TABLE * efi_systab
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ECANCELED, efi_systab, EfiResetShutdown, NULL, EFI_RUNTIME_SERVICES::ResetSystem, and EFI_SYSTEM_TABLE::RuntimeServices.

◆ PROVIDE_REBOOT() [1/2]

PROVIDE_REBOOT ( efi  ,
reboot  ,
efi_reboot   
)

◆ PROVIDE_REBOOT() [2/2]

PROVIDE_REBOOT ( efi  ,
poweroff  ,
efi_poweroff   
)