]> git.proxmox.com Git - mirror_edk2.git/blob - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
ce3fa904926de2643e296fb74c147a3ac8583d6b
[mirror_edk2.git] / PcAtChipsetPkg / PcatRealTimeClockRuntimeDxe / PcRtcEntry.c
1 /** @file
2 Provides Set/Get time operations.
3
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. 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 "PcRtc.h"
16
17 PC_RTC_MODULE_GLOBALS mModuleGlobal;
18
19 EFI_HANDLE mHandle = NULL;
20
21
22 /**
23 Returns the current time and date information, and the time-keeping capabilities
24 of the hardware platform.
25
26 @param Time A pointer to storage to receive a snapshot of the current time.
27 @param Capabilities An optional pointer to a buffer to receive the real time
28 clock device's capabilities.
29
30 @retval EFI_SUCCESS The operation completed successfully.
31 @retval EFI_INVALID_PARAMETER Time is NULL.
32 @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
33
34 **/
35 EFI_STATUS
36 EFIAPI
37 PcRtcEfiGetTime (
38 OUT EFI_TIME *Time,
39 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
40 )
41 {
42 return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);
43 }
44
45 /**
46 Sets the current local time and date information.
47
48 @param Time A pointer to the current time.
49
50 @retval EFI_SUCCESS The operation completed successfully.
51 @retval EFI_INVALID_PARAMETER A time field is out of range.
52 @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
53
54 **/
55 EFI_STATUS
56 EFIAPI
57 PcRtcEfiSetTime (
58 IN EFI_TIME *Time
59 )
60 {
61 return PcRtcSetTime (Time, &mModuleGlobal);
62 }
63
64 /**
65 Returns the current wakeup alarm clock setting.
66
67 @param Enabled Indicates if the alarm is currently enabled or disabled.
68 @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
69 @param Time The current alarm setting.
70
71 @retval EFI_SUCCESS The alarm settings were returned.
72 @retval EFI_INVALID_PARAMETER Enabled is NULL.
73 @retval EFI_INVALID_PARAMETER Pending is NULL.
74 @retval EFI_INVALID_PARAMETER Time is NULL.
75 @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
76 @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
77
78 **/
79 EFI_STATUS
80 EFIAPI
81 PcRtcEfiGetWakeupTime (
82 OUT BOOLEAN *Enabled,
83 OUT BOOLEAN *Pending,
84 OUT EFI_TIME *Time
85 )
86 {
87 return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);
88 }
89
90
91 /**
92 Sets the system wakeup alarm clock time.
93
94 @param Enabled Enable or disable the wakeup alarm.
95 @param Time If Enable is TRUE, the time to set the wakeup alarm for.
96 If Enable is FALSE, then this parameter is optional, and may be NULL.
97
98 @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.
99 If Enable is FALSE, then the wakeup alarm was disabled.
100 @retval EFI_INVALID_PARAMETER A time field is out of range.
101 @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
102 @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
103
104 **/
105 EFI_STATUS
106 EFIAPI
107 PcRtcEfiSetWakeupTime (
108 IN BOOLEAN Enabled,
109 IN EFI_TIME *Time OPTIONAL
110 )
111 {
112 return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);
113 }
114
115 /**
116 The user Entry Point for PcRTC module.
117
118 This is the entrhy point for PcRTC module. It installs the UEFI runtime service
119 including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().
120
121 @param ImageHandle The firmware allocated handle for the EFI image.
122 @param SystemTable A pointer to the EFI System Table.
123
124 @retval EFI_SUCCESS The entry point is executed successfully.
125 @retval Others Some error occurs when executing this entry point.
126
127 **/
128 EFI_STATUS
129 EFIAPI
130 InitializePcRtc (
131 IN EFI_HANDLE ImageHandle,
132 IN EFI_SYSTEM_TABLE *SystemTable
133 )
134 {
135 EFI_STATUS Status;
136
137 EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_HIGH_LEVEL);
138
139 Status = PcRtcInit (&mModuleGlobal);
140 if (EFI_ERROR (Status)) {
141 return Status;
142 }
143
144 gRT->GetTime = PcRtcEfiGetTime;
145 gRT->SetTime = PcRtcEfiSetTime;
146 gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;
147 gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;
148
149 Status = gBS->InstallMultipleProtocolInterfaces (
150 &mHandle,
151 &gEfiRealTimeClockArchProtocolGuid,
152 NULL,
153 NULL
154 );
155 ASSERT_EFI_ERROR (Status);
156
157 return Status;
158 }