]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Core/Dxe/Misc/SetWatchdogTimer.c
Initial import.
[mirror_edk2.git] / EdkModulePkg / Core / Dxe / Misc / SetWatchdogTimer.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 SetWatchdogTimer.c\r
15\r
16Abstract:\r
17\r
18 Tiano Miscellaneous Services SetWatchdogTimer service implementation\r
19\r
20--*/\r
21\r
22#include <DxeMain.h>\r
23\r
24#define WATCHDOG_TIMER_CALIBRATE_PER_SECOND 10000000\r
25\r
26\r
27EFI_STATUS\r
28EFIAPI\r
29CoreSetWatchdogTimer (\r
30 IN UINTN Timeout,\r
31 IN UINT64 WatchdogCode,\r
32 IN UINTN DataSize,\r
33 IN CHAR16 *WatchdogData OPTIONAL\r
34 )\r
35/*++\r
36\r
37Routine Description:\r
38\r
39 Sets the system's watchdog timer.\r
40\r
41Arguments:\r
42\r
43 Timeout The number of seconds. Zero disables the timer.\r
44\r
45 ///////following three parameters are left for platform specific using \r
46 \r
47 WatchdogCode The numberic code to log. 0x0 to 0xffff are firmware\r
48 DataSize Size of the optional data\r
49 WatchdogData Optional Null terminated unicode string followed by binary \r
50 data.\r
51\r
52Returns:\r
53\r
54 EFI_SUCCESS Timeout has been set\r
55 EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet \r
56 EFI_UNSUPPORTED System does not have a timer (currently not used)\r
57 EFI_DEVICE_ERROR Could not complete due to hardware error\r
58\r
59--*/\r
60{\r
61 EFI_STATUS Status;\r
62\r
63 //\r
64 // Check our architectural protocol\r
65 //\r
66 if (gWatchdogTimer == NULL) {\r
67 return EFI_NOT_AVAILABLE_YET;\r
68 }\r
69\r
70 //\r
71 // Attempt to set the timeout\r
72 //\r
73 Status = gWatchdogTimer->SetTimerPeriod (gWatchdogTimer, MultU64x32 (Timeout, WATCHDOG_TIMER_CALIBRATE_PER_SECOND));\r
74\r
75 //\r
76 // Check for errors\r
77 //\r
78 if (EFI_ERROR (Status)) {\r
79 return EFI_DEVICE_ERROR;\r
80 }\r
81\r
82 return EFI_SUCCESS;\r
83}\r