TianoCore EDK2 master
Loading...
Searching...
No Matches
XenRealTimeClockLib.c
Go to the documentation of this file.
1
10#include <Uefi.h>
11#include <PiDxe.h>
12#include <Library/BaseLib.h>
13#include <Library/DebugLib.h>
14
19VOID
21 IN UINTN EpochSeconds,
22 OUT EFI_TIME *Time
23 )
24{
25 UINTN a;
26 UINTN b;
27 UINTN c;
28 UINTN d;
29 UINTN g;
30 UINTN j;
31 UINTN m;
32 UINTN y;
33 UINTN da;
34 UINTN db;
35 UINTN dc;
36 UINTN dg;
37 UINTN hh;
38 UINTN mm;
39 UINTN ss;
40 UINTN J;
41
42 J = (EpochSeconds / 86400) + 2440588;
43 j = J + 32044;
44 g = j / 146097;
45 dg = j % 146097;
46 c = (((dg / 36524) + 1) * 3) / 4;
47 dc = dg - (c * 36524);
48 b = dc / 1461;
49 db = dc % 1461;
50 a = (((db / 365) + 1) * 3) / 4;
51 da = db - (a * 365);
52 y = (g * 400) + (c * 100) + (b * 4) + a;
53 m = (((da * 5) + 308) / 153) - 2;
54 d = da - (((m + 4) * 153) / 5) + 122;
55
56 Time->Year = (UINT16)(y - 4800 + ((m + 2) / 12));
57 Time->Month = ((m + 2) % 12) + 1;
58 Time->Day = (UINT8)(d + 1);
59
60 ss = EpochSeconds % 60;
61 a = (EpochSeconds - ss) / 60;
62 mm = a % 60;
63 b = (a - mm) / 60;
64 hh = b % 24;
65
66 Time->Hour = (UINT8)hh;
67 Time->Minute = (UINT8)mm;
68 Time->Second = (UINT8)ss;
69 Time->Nanosecond = 0;
70}
71
89EFIAPI
91 OUT EFI_TIME *Time,
92 OUT EFI_TIME_CAPABILITIES *Capabilities
93 )
94{
95 ASSERT (Time != NULL);
96
97 //
98 // For now, there is nothing that we can do besides returning a bogus time,
99 // as Xen's timekeeping uses a shared info page which cannot be shared
100 // between UEFI and the OS
101 //
102 EpochToEfiTime (1421770011, Time);
103
104 return EFI_SUCCESS;
105}
106
121EFIAPI
123 IN EFI_TIME *Time
124 )
125{
126 return EFI_DEVICE_ERROR;
127}
128
147EFIAPI
149 OUT BOOLEAN *Enabled,
150 OUT BOOLEAN *Pending,
151 OUT EFI_TIME *Time
152 )
153{
154 return EFI_UNSUPPORTED;
155}
156
175EFIAPI
177 IN BOOLEAN Enabled,
178 OUT EFI_TIME *Time
179 )
180{
181 return EFI_UNSUPPORTED;
182}
183
195EFIAPI
197 IN EFI_HANDLE ImageHandle,
198 IN EFI_SYSTEM_TABLE *SystemTable
199 )
200{
201 return EFI_SUCCESS;
202}
UINT64 UINTN
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_STATUS EFIAPI LibSetWakeupTime(IN BOOLEAN Enabled, OUT EFI_TIME *Time)
EFI_STATUS EFIAPI LibRtcInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC VOID EpochToEfiTime(IN UINTN EpochSeconds, OUT EFI_TIME *Time)
EFI_STATUS EFIAPI LibGetWakeupTime(OUT BOOLEAN *Enabled, OUT BOOLEAN *Pending, OUT EFI_TIME *Time)
EFI_STATUS EFIAPI LibSetTime(IN EFI_TIME *Time)
EFI_STATUS EFIAPI LibGetTime(OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities)