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