2 * Copyright (C) 2015 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
29 * EFI watchdog holdoff timer
35 #include <ipxe/retry.h>
36 #include <ipxe/timer.h>
37 #include <ipxe/efi/efi.h>
38 #include <ipxe/efi/efi_watchdog.h>
40 /** Watchdog holdoff interval (in seconds) */
41 #define WATCHDOG_HOLDOFF_SECS 10
43 /** Watchdog timeout (in seconds) */
44 #define WATCHDOG_TIMEOUT_SECS ( 5 * 60 )
46 /** Watchdog code (to be logged on watchdog timeout) */
47 #define WATCHDOG_CODE 0x6950584544454144ULL
49 /** Watchdog data (to be logged on watchdog timeout) */
50 #define WATCHDOG_DATA L"iPXE";
53 * Hold off watchdog timer
55 * @v retry Retry timer
56 * @v over Failure indicator
58 static void efi_watchdog_expired ( struct retry_timer *timer,
60 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
61 static CHAR16 data[] = WATCHDOG_DATA;
65 DBGC2 ( timer, "EFI holding off watchdog timer\n" );
67 /* Restart this holdoff timer */
68 start_timer_fixed ( timer, ( WATCHDOG_HOLDOFF_SECS * TICKS_PER_SEC ) );
70 /* Reset watchdog timer */
71 if ( ( efirc = bs->SetWatchdogTimer ( WATCHDOG_TIMEOUT_SECS,
72 WATCHDOG_CODE, sizeof ( data ),
75 DBGC ( timer, "EFI could not set watchdog timer: %s\n",
81 /** Watchdog holdoff timer */
82 struct retry_timer efi_watchdog = TIMER_INIT ( efi_watchdog_expired );