3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 NT Emulation Architectural Protocol Driver as defined in Tiano
39 InitializeRealTimeClock (
40 IN EFI_HANDLE ImageHandle
,
41 IN EFI_SYSTEM_TABLE
*SystemTable
49 OUT EFI_TIME_CAPABILITIES
* Capabilities OPTIONAL
54 Service routine for RealTimeClockInstance->GetTime
58 Time - A pointer to storage that will receive a snapshot of the current time.
60 Capabilities - A pointer to storage that will receive the capabilities of the real time clock
61 in the platform. This includes the real time clock's resolution and accuracy.
62 All reported device capabilities are rounded up. This is an OPTIONAL argument.
66 EFI_SUCEESS - The underlying GetSystemTime call occurred and returned
67 Note that in the NT32 emulation, the GetSystemTime call has no return value
68 thus you will always receive a EFI_SUCCESS on this.
71 // TODO: EFI_INVALID_PARAMETER - add return value to function comment
75 // Check parameter for null pointer
78 return EFI_INVALID_PARAMETER
;
82 gUnix
->GetLocalTime (Time
);
84 if (Capabilities
!= NULL
) {
85 Capabilities
->Resolution
= 1;
86 Capabilities
->Accuracy
= 50000000;
87 Capabilities
->SetsToZero
= FALSE
;
102 Service routine for RealTimeClockInstance->SetTime
106 Time - A pointer to storage containing the time and date information to
107 program into the real time clock.
111 EFI_SUCEESS - The operation completed successfully.
113 EFI_INVALID_PARAMETER - One of the fields in Time is out of range.
115 EFI_DEVICE_ERROR - The operation could not be complete due to a device error.
118 // TODO: EFI_SUCCESS - add return value to function comment
123 return EFI_INVALID_PARAMETER
;
126 // Make sure that the time fields are valid
128 Status
= RtcTimeFieldsValid (Time
);
129 if (EFI_ERROR (Status
)) {
132 return EFI_UNSUPPORTED
;
139 OUT BOOLEAN
*Enabled
,
140 OUT BOOLEAN
*Pending
,
146 Service routine for RealTimeClockInstance->GetWakeupTime
149 This - Indicates the protocol instance structure.
151 Enabled - Indicates if the alarm is currently enabled or disabled.
153 Pending - Indicates if the alarm signal is pending and requires
156 Time - The current alarm setting.
160 EFI_SUCEESS - The operation completed successfully.
162 EFI_DEVICE_ERROR - The operation could not be complete due to a device error.
164 EFI_UNSUPPORTED - The operation is not supported on this platform.
168 return EFI_UNSUPPORTED
;
181 Service routine for RealTimeClockInstance->SetWakeupTime
185 Enabled - Enable or disable the wakeup alarm.
187 Time - If enable is TRUE, the time to set the wakup alarm for.
188 If enable is FALSE, then this parameter is optional, and
193 EFI_SUCEESS - The operation completed successfully.
195 EFI_DEVICE_ERROR - The operation could not be complete due to a device error.
197 EFI_INVALID_PARAMETER - A field in Time is out of range.
199 EFI_UNSUPPORTED - The operation is not supported on this platform.
203 return EFI_UNSUPPORTED
;
208 InitializeRealTimeClock (
209 IN EFI_HANDLE ImageHandle
,
210 IN EFI_SYSTEM_TABLE
*SystemTable
215 Install Real Time Clock Protocol
218 ImageHandle - Image Handle
219 SystemTable - Pointer to system table
223 EFI_SUCEESS - Real Time Clock Services are installed into the Runtime Services Table
230 SystemTable
->RuntimeServices
->GetTime
= UnixGetTime
;
231 SystemTable
->RuntimeServices
->SetTime
= UnixSetTime
;
232 SystemTable
->RuntimeServices
->GetWakeupTime
= UnixGetWakeupTime
;
233 SystemTable
->RuntimeServices
->SetWakeupTime
= UnixSetWakeupTime
;
236 Status
= gBS
->InstallMultipleProtocolInterfaces (
238 &gEfiRealTimeClockArchProtocolGuid
,
257 // TODO: Time - add argument and description to function comment
258 // TODO: EFI_INVALID_PARAMETER - add return value to function comment
259 // TODO: EFI_SUCCESS - add return value to function comment
261 if (Time
->Year
< 1998 ||
265 (!DayValid (Time
)) ||
269 Time
->Nanosecond
> 999999999 ||
270 (!(Time
->TimeZone
== EFI_UNSPECIFIED_TIMEZONE
|| (Time
->TimeZone
>= -1440 && Time
->TimeZone
<= 1440))) ||
271 (Time
->Daylight
& (~(EFI_TIME_ADJUST_DAYLIGHT
| EFI_TIME_IN_DAYLIGHT
)))
273 return EFI_INVALID_PARAMETER
;
287 TODO: Add function description
291 Time - TODO: add argument description
295 TODO: add return values
300 static const INTN DayOfMonth
[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
303 Time
->Day
> DayOfMonth
[Time
->Month
- 1] ||
304 (Time
->Month
== 2 && (!IsLeapYear (Time
) && Time
->Day
> 28))
320 TODO: Add function description
324 Time - TODO: add argument description
328 TODO: add return values
332 if (Time
->Year
% 4 == 0) {
333 if (Time
->Year
% 100 == 0) {
334 if (Time
->Year
% 400 == 0) {