Program SD Cards into 4-bit mode (support for this is required in the spec). This...
[mirror_edk2.git] / PcAtChipsetPkg / PcatRealTimeClockRuntimeDxe / PcRtcEntry.c
CommitLineData
fb0b259e 1/** @file\r
2 Provides Set/Get time operations.\r
8cd4d17c 3\r
95d48e82
HT
4Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
3cfb790c 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
8cd4d17c 12\r
fb0b259e 13**/\r
8cd4d17c 14\r
15#include "PcRtc.h"\r
16\r
fe1e36e5 17PC_RTC_MODULE_GLOBALS mModuleGlobal;\r
8cd4d17c 18\r
8d85dc31 19EFI_HANDLE mHandle = NULL;\r
8cd4d17c 20\r
8cd4d17c 21\r
8d85dc31 22/**\r
23 Returns the current time and date information, and the time-keeping capabilities\r
24 of the hardware platform.\r
8cd4d17c 25\r
8d85dc31 26 @param Time A pointer to storage to receive a snapshot of the current time.\r
27 @param Capabilities An optional pointer to a buffer to receive the real time\r
28 clock device's capabilities.\r
8cd4d17c 29\r
8d85dc31 30 @retval EFI_SUCCESS The operation completed successfully.\r
31 @retval EFI_INVALID_PARAMETER Time is NULL.\r
32 @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.\r
8cd4d17c 33\r
8d85dc31 34**/\r
35EFI_STATUS\r
36EFIAPI\r
37PcRtcEfiGetTime (\r
38 OUT EFI_TIME *Time,\r
39 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL\r
40 )\r
8cd4d17c 41{\r
42 return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);\r
43}\r
44\r
8d85dc31 45/**\r
46 Sets the current local time and date information.\r
47\r
48 @param Time A pointer to the current time.\r
49\r
50 @retval EFI_SUCCESS The operation completed successfully.\r
51 @retval EFI_INVALID_PARAMETER A time field is out of range.\r
52 @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.\r
53\r
54**/\r
8cd4d17c 55EFI_STATUS\r
56EFIAPI\r
57PcRtcEfiSetTime (\r
58 IN EFI_TIME *Time\r
59 )\r
8cd4d17c 60{\r
61 return PcRtcSetTime (Time, &mModuleGlobal);\r
62}\r
63\r
8d85dc31 64/**\r
65 Returns the current wakeup alarm clock setting.\r
66\r
67 @param Enabled Indicates if the alarm is currently enabled or disabled.\r
68 @param Pending Indicates if the alarm signal is pending and requires acknowledgement.\r
69 @param Time The current alarm setting.\r
70\r
71 @retval EFI_SUCCESS The alarm settings were returned.\r
72 @retval EFI_INVALID_PARAMETER Enabled is NULL.\r
73 @retval EFI_INVALID_PARAMETER Pending is NULL.\r
74 @retval EFI_INVALID_PARAMETER Time is NULL.\r
75 @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.\r
76 @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
77\r
78**/\r
8cd4d17c 79EFI_STATUS\r
80EFIAPI\r
81PcRtcEfiGetWakeupTime (\r
82 OUT BOOLEAN *Enabled,\r
83 OUT BOOLEAN *Pending,\r
84 OUT EFI_TIME *Time\r
85 )\r
8d85dc31 86{\r
87 return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);\r
88}\r
8cd4d17c 89\r
8cd4d17c 90\r
8d85dc31 91/**\r
92 Sets the system wakeup alarm clock time.\r
8cd4d17c 93\r
8d85dc31 94 @param Enabled Enable or disable the wakeup alarm.\r
95 @param Time If Enable is TRUE, the time to set the wakeup alarm for.\r
96 If Enable is FALSE, then this parameter is optional, and may be NULL.\r
8cd4d17c 97\r
8d85dc31 98 @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.\r
99 If Enable is FALSE, then the wakeup alarm was disabled.\r
100 @retval EFI_INVALID_PARAMETER A time field is out of range.\r
101 @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.\r
102 @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
8cd4d17c 103\r
8d85dc31 104**/\r
8cd4d17c 105EFI_STATUS\r
106EFIAPI\r
107PcRtcEfiSetWakeupTime (\r
108 IN BOOLEAN Enabled,\r
8d85dc31 109 IN EFI_TIME *Time OPTIONAL\r
8cd4d17c 110 )\r
8d85dc31 111{\r
112 return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);\r
113}\r
8cd4d17c 114\r
8d85dc31 115/**\r
116 The user Entry Point for PcRTC module.\r
8cd4d17c 117\r
8d85dc31 118 This is the entrhy point for PcRTC module. It installs the UEFI runtime service\r
119 including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().\r
8cd4d17c 120\r
8d85dc31 121 @param ImageHandle The firmware allocated handle for the EFI image.\r
122 @param SystemTable A pointer to the EFI System Table.\r
8cd4d17c 123\r
8d85dc31 124 @retval EFI_SUCCESS The entry point is executed successfully.\r
125 @retval Others Some error occurs when executing this entry point.\r
8cd4d17c 126\r
8d85dc31 127**/\r
8cd4d17c 128EFI_STATUS\r
129EFIAPI\r
130InitializePcRtc (\r
131 IN EFI_HANDLE ImageHandle,\r
132 IN EFI_SYSTEM_TABLE *SystemTable\r
133 )\r
8cd4d17c 134{\r
135 EFI_STATUS Status;\r
8cd4d17c 136\r
137 EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_HIGH_LEVEL);\r
138\r
139 Status = PcRtcInit (&mModuleGlobal);\r
140 if (EFI_ERROR (Status)) {\r
141 return Status;\r
142 }\r
143\r
144 gRT->GetTime = PcRtcEfiGetTime;\r
145 gRT->SetTime = PcRtcEfiSetTime;\r
146 gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;\r
147 gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;\r
148\r
8cd4d17c 149 Status = gBS->InstallMultipleProtocolInterfaces (\r
8d85dc31 150 &mHandle,\r
8cd4d17c 151 &gEfiRealTimeClockArchProtocolGuid,\r
152 NULL,\r
153 NULL\r
154 );\r
8d85dc31 155 ASSERT_EFI_ERROR (Status);\r
8cd4d17c 156\r
157 return Status;\r
158}\r