2 Implement EFI RealTimeClock runtime services via Xen shared info page
4 Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <Library/BaseLib.h>
13 #include <Library/DebugLib.h>
16 Converts Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) to EFI_TIME
21 IN UINTN EpochSeconds
,
42 J
= (EpochSeconds
/ 86400) + 2440588;
46 c
= (((dg
/ 36524) + 1) * 3) / 4;
47 dc
= dg
- (c
* 36524);
50 a
= (((db
/ 365) + 1) * 3) / 4;
52 y
= (g
* 400) + (c
* 100) + (b
* 4) + a
;
53 m
= (((da
* 5) + 308) / 153) - 2;
54 d
= da
- (((m
+ 4) * 153) / 5) + 122;
56 Time
->Year
= (UINT16
)(y
- 4800 + ((m
+ 2) / 12));
57 Time
->Month
= ((m
+ 2) % 12) + 1;
58 Time
->Day
= (UINT8
)(d
+ 1);
60 ss
= EpochSeconds
% 60;
61 a
= (EpochSeconds
- ss
) / 60;
66 Time
->Hour
= (UINT8
)hh
;
67 Time
->Minute
= (UINT8
)mm
;
68 Time
->Second
= (UINT8
)ss
;
74 Returns the current time and date information, and the time-keeping capabilities
75 of the hardware platform.
77 @param Time A pointer to storage to receive a snapshot of the current time.
78 @param Capabilities An optional pointer to a buffer to receive the real time clock
79 device's capabilities.
81 @retval EFI_SUCCESS The operation completed successfully.
82 @retval EFI_INVALID_PARAMETER Time is NULL.
83 @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
90 OUT EFI_TIME_CAPABILITIES
*Capabilities
93 ASSERT (Time
!= NULL
);
96 // For now, there is nothing that we can do besides returning a bogus time,
97 // as Xen's timekeeping uses a shared info page which cannot be shared
98 // between UEFI and the OS
100 EpochToEfiTime(1421770011, Time
);
106 Sets the current local time and date information.
108 @param Time A pointer to the current time.
110 @retval EFI_SUCCESS The operation completed successfully.
111 @retval EFI_INVALID_PARAMETER A time field is out of range.
112 @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
121 return EFI_DEVICE_ERROR
;
126 Returns the current wakeup alarm clock setting.
128 @param Enabled Indicates if the alarm is currently enabled or disabled.
129 @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
130 @param Time The current alarm setting.
132 @retval EFI_SUCCESS The alarm settings were returned.
133 @retval EFI_INVALID_PARAMETER Any parameter is NULL.
134 @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
135 @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
141 OUT BOOLEAN
*Enabled
,
142 OUT BOOLEAN
*Pending
,
146 return EFI_UNSUPPORTED
;
150 Sets the system wakeup alarm clock time.
152 @param Enabled Enable or disable the wakeup alarm.
153 @param Time If Enable is TRUE, the time to set the wakeup alarm for.
155 @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
156 Enable is FALSE, then the wakeup alarm was disabled.
157 @retval EFI_INVALID_PARAMETER A time field is out of range.
158 @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
159 @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
169 return EFI_UNSUPPORTED
;
173 This is the declaration of an EFI image entry point. This can be the entry point to an application
174 written to this specification, an EFI boot service driver, or an EFI runtime driver.
176 @param ImageHandle Handle that identifies the loaded image.
177 @param SystemTable System Table for this image.
179 @retval EFI_SUCCESS The operation completed successfully.
185 IN EFI_HANDLE ImageHandle
,
186 IN EFI_SYSTEM_TABLE
*SystemTable