VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c@ 89876

Last change on this file since 89876 was 85718, checked in by vboxsync, 5 years ago

Devices/EFI: Merge edk-stable202005 and make it build, bugref:4643

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette