iPXE
Macros | Functions | Variables
efi_watchdog.c File Reference

EFI watchdog holdoff timer. More...

#include <errno.h>
#include <string.h>
#include <ipxe/retry.h>
#include <ipxe/timer.h>
#include <ipxe/init.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_watchdog.h>

Go to the source code of this file.

Macros

#define WATCHDOG_HOLDOFF_SECS   10
 Watchdog holdoff interval (in seconds) More...
 
#define WATCHDOG_TIMEOUT_SECS   ( 5 * 60 )
 Watchdog timeout (in seconds) More...
 
#define WATCHDOG_CODE   0x6950584544454144ULL
 Watchdog code (to be logged on watchdog timeout) More...
 
#define WATCHDOG_DATA   L"iPXE";
 Watchdog data (to be logged on watchdog timeout) More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void efi_watchdog_expired (struct retry_timer *timer, int over __unused)
 Hold off watchdog timer. More...
 
static void efi_watchdog_shutdown (int booting)
 Disable watching when shutting down to boot an operating system. More...
 
struct startup_fn efi_watchdog_startup_fn __startup_fn (STARTUP_EARLY)
 Watchdog startup/shutdown function. More...
 

Variables

struct retry_timer efi_watchdog = TIMER_INIT ( efi_watchdog_expired )
 Watchdog holdoff timer. More...
 

Detailed Description

EFI watchdog holdoff timer.

Definition in file efi_watchdog.c.

Macro Definition Documentation

◆ WATCHDOG_HOLDOFF_SECS

#define WATCHDOG_HOLDOFF_SECS   10

Watchdog holdoff interval (in seconds)

Definition at line 42 of file efi_watchdog.c.

◆ WATCHDOG_TIMEOUT_SECS

#define WATCHDOG_TIMEOUT_SECS   ( 5 * 60 )

Watchdog timeout (in seconds)

Definition at line 45 of file efi_watchdog.c.

◆ WATCHDOG_CODE

#define WATCHDOG_CODE   0x6950584544454144ULL

Watchdog code (to be logged on watchdog timeout)

Definition at line 48 of file efi_watchdog.c.

◆ WATCHDOG_DATA

#define WATCHDOG_DATA   L"iPXE";

Watchdog data (to be logged on watchdog timeout)

Definition at line 51 of file efi_watchdog.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_watchdog_expired()

static void efi_watchdog_expired ( struct retry_timer timer,
int over  __unused 
)
static

Hold off watchdog timer.

Parameters
retryRetry timer
overFailure indicator

Definition at line 59 of file efi_watchdog.c.

60  {
62  static CHAR16 data[] = WATCHDOG_DATA;
63  EFI_STATUS efirc;
64  int rc;
65 
66  DBGC2 ( timer, "EFI holding off watchdog timer\n" );
67 
68  /* Restart this holdoff timer */
70 
71  /* Reset watchdog timer */
72  if ( ( efirc = bs->SetWatchdogTimer ( WATCHDOG_TIMEOUT_SECS,
73  WATCHDOG_CODE, sizeof ( data ),
74  data ) ) != 0 ) {
75  rc = -EEFI ( efirc );
76  DBGC ( timer, "EFI could not set watchdog timer: %s\n",
77  strerror ( rc ) );
78  return;
79  }
80 }
#define WATCHDOG_CODE
Watchdog code (to be logged on watchdog timeout)
Definition: efi_watchdog.c:48
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
EFI_SET_WATCHDOG_TIMER SetWatchdogTimer
Definition: UefiSpec.h:1975
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
#define WATCHDOG_TIMEOUT_SECS
Watchdog timeout (in seconds)
Definition: efi_watchdog.c:45
#define DBGC(...)
Definition: compiler.h:505
unsigned short CHAR16
A timer.
Definition: timer.h:28
#define WATCHDOG_HOLDOFF_SECS
Watchdog holdoff interval (in seconds)
Definition: efi_watchdog.c:42
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
#define WATCHDOG_DATA
Watchdog data (to be logged on watchdog timeout)
Definition: efi_watchdog.c:51
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
uint8_t data[48]
Additional event data.
Definition: ena.h:22
EFI_SYSTEM_TABLE * efi_systab

References EFI_SYSTEM_TABLE::BootServices, data, DBGC, DBGC2, EEFI, efi_systab, rc, EFI_BOOT_SERVICES::SetWatchdogTimer, start_timer_fixed(), strerror(), TICKS_PER_SEC, WATCHDOG_CODE, WATCHDOG_DATA, WATCHDOG_HOLDOFF_SECS, and WATCHDOG_TIMEOUT_SECS.

◆ efi_watchdog_shutdown()

static void efi_watchdog_shutdown ( int  booting)
static

Disable watching when shutting down to boot an operating system.

Parameters
bootingSystem is shutting down for OS boot

Definition at line 90 of file efi_watchdog.c.

90  {
92  EFI_STATUS efirc;
93  int rc;
94 
95  /* If we are shutting down to boot an operating system, then
96  * disable the boot services watchdog timer. The UEFI
97  * specification mandates that the platform firmware does this
98  * as part of the ExitBootServices() call, but some platforms
99  * (e.g. Hyper-V) are observed to occasionally forget to do
100  * so, resulting in a reboot approximately five minutes after
101  * starting the operating system.
102  */
103  if ( booting &&
104  ( ( efirc = bs->SetWatchdogTimer ( 0, 0, 0, NULL ) ) != 0 ) ) {
105  rc = -EEFI ( efirc );
106  DBGC ( &efi_watchdog, "EFI could not disable watchdog timer: "
107  "%s\n", strerror ( rc ) );
108  /* Nothing we can do */
109  }
110 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
EFI_SET_WATCHDOG_TIMER SetWatchdogTimer
Definition: UefiSpec.h:1975
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
#define DBGC(...)
Definition: compiler.h:505
struct retry_timer efi_watchdog
Watchdog holdoff timer.
Definition: efi_watchdog.c:83
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_SYSTEM_TABLE * efi_systab
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References EFI_SYSTEM_TABLE::BootServices, DBGC, EEFI, efi_systab, efi_watchdog, NULL, rc, EFI_BOOT_SERVICES::SetWatchdogTimer, and strerror().

◆ __startup_fn()

struct startup_fn efi_watchdog_startup_fn __startup_fn ( STARTUP_EARLY  )

Watchdog startup/shutdown function.

Variable Documentation

◆ efi_watchdog

struct retry_timer efi_watchdog = TIMER_INIT ( efi_watchdog_expired )

Watchdog holdoff timer.

Definition at line 83 of file efi_watchdog.c.

Referenced by efi_watchdog_shutdown(), efi_watchdog_start(), and efi_watchdog_stop().