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