1 | /** @file
|
---|
2 | Implement EFI RealTimeClock runtime services via RTC Lib.
|
---|
3 |
|
---|
4 | Currently this driver does not support runtime virtual calling.
|
---|
5 |
|
---|
6 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
---|
7 |
|
---|
8 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
9 |
|
---|
10 | **/
|
---|
11 |
|
---|
12 | #include <PiDxe.h>
|
---|
13 | #include <Library/BaseLib.h>
|
---|
14 | #include <Library/DebugLib.h>
|
---|
15 | #include <Library/IoLib.h>
|
---|
16 | #include <Library/RealTimeClockLib.h>
|
---|
17 |
|
---|
18 |
|
---|
19 | /**
|
---|
20 | Returns the current time and date information, and the time-keeping capabilities
|
---|
21 | of the hardware platform.
|
---|
22 |
|
---|
23 | @param Time A pointer to storage to receive a snapshot of the current time.
|
---|
24 | @param Capabilities An optional pointer to a buffer to receive the real time clock
|
---|
25 | device's capabilities.
|
---|
26 |
|
---|
27 | @retval EFI_SUCCESS The operation completed successfully.
|
---|
28 | @retval EFI_INVALID_PARAMETER Time is NULL.
|
---|
29 | @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
|
---|
30 |
|
---|
31 | **/
|
---|
32 | EFI_STATUS
|
---|
33 | EFIAPI
|
---|
34 | LibGetTime (
|
---|
35 | OUT EFI_TIME *Time,
|
---|
36 | OUT EFI_TIME_CAPABILITIES *Capabilities
|
---|
37 | )
|
---|
38 | {
|
---|
39 | //
|
---|
40 | // Fill in Time and Capabilities via data from you RTC
|
---|
41 | //
|
---|
42 | return EFI_DEVICE_ERROR;
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | /**
|
---|
47 | Sets the current local time and date information.
|
---|
48 |
|
---|
49 | @param Time A pointer to the current time.
|
---|
50 |
|
---|
51 | @retval EFI_SUCCESS The operation completed successfully.
|
---|
52 | @retval EFI_INVALID_PARAMETER A time field is out of range.
|
---|
53 | @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
|
---|
54 |
|
---|
55 | **/
|
---|
56 | EFI_STATUS
|
---|
57 | EFIAPI
|
---|
58 | LibSetTime (
|
---|
59 | IN EFI_TIME *Time
|
---|
60 | )
|
---|
61 | {
|
---|
62 | //
|
---|
63 | // Use Time, to set the time in your RTC hardware
|
---|
64 | //
|
---|
65 | return EFI_DEVICE_ERROR;
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | /**
|
---|
70 | Returns the current wakeup alarm clock setting.
|
---|
71 |
|
---|
72 | @param Enabled Indicates if the alarm is currently enabled or disabled.
|
---|
73 | @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
|
---|
74 | @param Time The current alarm setting.
|
---|
75 |
|
---|
76 | @retval EFI_SUCCESS The alarm settings were returned.
|
---|
77 | @retval EFI_INVALID_PARAMETER Any parameter is NULL.
|
---|
78 | @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
|
---|
79 |
|
---|
80 | **/
|
---|
81 | EFI_STATUS
|
---|
82 | EFIAPI
|
---|
83 | LibGetWakeupTime (
|
---|
84 | OUT BOOLEAN *Enabled,
|
---|
85 | OUT BOOLEAN *Pending,
|
---|
86 | OUT EFI_TIME *Time
|
---|
87 | )
|
---|
88 | {
|
---|
89 | // Not a required feature
|
---|
90 | return EFI_UNSUPPORTED;
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | /**
|
---|
95 | Sets the system wakeup alarm clock time.
|
---|
96 |
|
---|
97 | @param Enabled Enable or disable the wakeup alarm.
|
---|
98 | @param Time If Enable is TRUE, the time to set the wakeup alarm for.
|
---|
99 |
|
---|
100 | @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
|
---|
101 | Enable is FALSE, then the wakeup alarm was disabled.
|
---|
102 | @retval EFI_INVALID_PARAMETER A time field is out of range.
|
---|
103 | @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
|
---|
104 | @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
|
---|
105 |
|
---|
106 | **/
|
---|
107 | EFI_STATUS
|
---|
108 | EFIAPI
|
---|
109 | LibSetWakeupTime (
|
---|
110 | IN BOOLEAN Enabled,
|
---|
111 | OUT EFI_TIME *Time
|
---|
112 | )
|
---|
113 | {
|
---|
114 | // Not a required feature
|
---|
115 | return EFI_UNSUPPORTED;
|
---|
116 | }
|
---|
117 |
|
---|
118 |
|
---|
119 |
|
---|
120 | /**
|
---|
121 | This is the declaration of an EFI image entry point. This can be the entry point to an application
|
---|
122 | written to this specification, an EFI boot service driver, or an EFI runtime driver.
|
---|
123 |
|
---|
124 | @param ImageHandle Handle that identifies the loaded image.
|
---|
125 | @param SystemTable System Table for this image.
|
---|
126 |
|
---|
127 | @retval EFI_SUCCESS The operation completed successfully.
|
---|
128 |
|
---|
129 | **/
|
---|
130 | EFI_STATUS
|
---|
131 | EFIAPI
|
---|
132 | LibRtcInitialize (
|
---|
133 | IN EFI_HANDLE ImageHandle,
|
---|
134 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
135 | )
|
---|
136 | {
|
---|
137 | //
|
---|
138 | // Do some initialization if required to turn on the RTC
|
---|
139 | //
|
---|
140 | return EFI_SUCCESS;
|
---|
141 | }
|
---|
142 |
|
---|
143 |
|
---|
144 | /**
|
---|
145 | Fixup internal data so that EFI can be call in virtual mode.
|
---|
146 | Call the passed in Child Notify event and convert any pointers in
|
---|
147 | lib to virtual mode.
|
---|
148 |
|
---|
149 | @param[in] Event The Event that is being processed
|
---|
150 | @param[in] Context Event Context
|
---|
151 | **/
|
---|
152 | VOID
|
---|
153 | EFIAPI
|
---|
154 | LibRtcVirtualNotifyEvent (
|
---|
155 | IN EFI_EVENT Event,
|
---|
156 | IN VOID *Context
|
---|
157 | )
|
---|
158 | {
|
---|
159 | //
|
---|
160 | // Only needed if you are going to support the OS calling RTC functions in virtual mode.
|
---|
161 | // You will need to call EfiConvertPointer (). To convert any stored physical addresses
|
---|
162 | // to virtual address. After the OS transitions to calling in virtual mode, all future
|
---|
163 | // runtime calls will be made in virtual mode.
|
---|
164 | //
|
---|
165 | return;
|
---|
166 | }
|
---|
167 |
|
---|
168 |
|
---|
169 |
|
---|