1 /** @file 2 UEFI Miscellaneous boot Services SetWatchdogTimer service implementation 3 4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #include "DxeMain.h" 16 17 #define WATCHDOG_TIMER_CALIBRATE_PER_SECOND 10000000 18 19 /** 20 Sets the system's watchdog timer. 21 22 @param Timeout The number of seconds to set the watchdog timer to. 23 A value of zero disables the timer. 24 @param WatchdogCode The numeric code to log on a watchdog timer timeout 25 event. The firmware reserves codes 0x0000 to 0xFFFF. 26 Loaders and operating systems may use other timeout 27 codes. 28 @param DataSize The size, in bytes, of WatchdogData. 29 @param WatchdogData A data buffer that includes a Null-terminated Unicode 30 string, optionally followed by additional binary data. 31 The string is a description that the call may use to 32 further indicate the reason to be logged with a 33 watchdog event. 34 35 @return EFI_SUCCESS Timeout has been set 36 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet 37 @return EFI_UNSUPPORTED System does not have a timer (currently not used) 38 @return EFI_DEVICE_ERROR Could not complete due to hardware error 39 40 **/ 41 EFI_STATUS 42 EFIAPI 43 CoreSetWatchdogTimer ( 44 IN UINTN Timeout, 45 IN UINT64 WatchdogCode, 46 IN UINTN DataSize, 47 IN CHAR16 *WatchdogData OPTIONAL 48 ) 49 { 50 EFI_STATUS Status; 51 52 // 53 // Check our architectural protocol 54 // 55 if (gWatchdogTimer == NULL) { 56 return EFI_NOT_AVAILABLE_YET; 57 } 58 59 // 60 // Attempt to set the timeout 61 // 62 Status = gWatchdogTimer->SetTimerPeriod (gWatchdogTimer, MultU64x32 (Timeout, WATCHDOG_TIMER_CALIBRATE_PER_SECOND)); 63 64 // 65 // Check for errors 66 // 67 if (EFI_ERROR (Status)) { 68 return EFI_DEVICE_ERROR; 69 } 70 71 return EFI_SUCCESS; 72 } 73