]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/Misc/SetWatchdogTimer.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Misc / SetWatchdogTimer.c
... / ...
CommitLineData
1/** @file\r
2 UEFI Miscellaneous boot Services SetWatchdogTimer service implementation\r
3\r
4Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#include "DxeMain.h"\r
10\r
11#define WATCHDOG_TIMER_CALIBRATE_PER_SECOND 10000000\r
12\r
13/**\r
14 Sets the system's watchdog timer.\r
15\r
16 @param Timeout The number of seconds to set the watchdog timer to.\r
17 A value of zero disables the timer.\r
18 @param WatchdogCode The numeric code to log on a watchdog timer timeout\r
19 event. The firmware reserves codes 0x0000 to 0xFFFF.\r
20 Loaders and operating systems may use other timeout\r
21 codes.\r
22 @param DataSize The size, in bytes, of WatchdogData.\r
23 @param WatchdogData A data buffer that includes a Null-terminated Unicode\r
24 string, optionally followed by additional binary data.\r
25 The string is a description that the call may use to\r
26 further indicate the reason to be logged with a\r
27 watchdog event.\r
28\r
29 @return EFI_SUCCESS Timeout has been set\r
30 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet\r
31 @return EFI_UNSUPPORTED System does not have a timer (currently not used)\r
32 @return EFI_DEVICE_ERROR Could not complete due to hardware error\r
33\r
34**/\r
35EFI_STATUS\r
36EFIAPI\r
37CoreSetWatchdogTimer (\r
38 IN UINTN Timeout,\r
39 IN UINT64 WatchdogCode,\r
40 IN UINTN DataSize,\r
41 IN CHAR16 *WatchdogData OPTIONAL\r
42 )\r
43{\r
44 EFI_STATUS Status;\r
45\r
46 //\r
47 // Check our architectural protocol\r
48 //\r
49 if (gWatchdogTimer == NULL) {\r
50 return EFI_NOT_AVAILABLE_YET;\r
51 }\r
52\r
53 //\r
54 // Attempt to set the timeout\r
55 //\r
56 Status = gWatchdogTimer->SetTimerPeriod (gWatchdogTimer, MultU64x32 (Timeout, WATCHDOG_TIMER_CALIBRATE_PER_SECOND));\r
57\r
58 //\r
59 // Check for errors\r
60 //\r
61 if (EFI_ERROR (Status)) {\r
62 return EFI_DEVICE_ERROR;\r
63 }\r
64\r
65 return EFI_SUCCESS;\r
66}\r