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