diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2018-08-23 13:37:37 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2018-08-27 15:20:56 +0800 |
commit | 07d8559c6bd8a8716e163a930a63f16e742aaa7a (patch) | |
tree | 403b85aa6616a1c1dc0bbc451406fd5fce7188f6 /EmulatorPkg | |
parent | 269c512393fa1fe557cdcbac46044c0831915562 (diff) | |
download | edk2-07d8559c6bd8a8716e163a930a63f16e742aaa7a.zip edk2-07d8559c6bd8a8716e163a930a63f16e742aaa7a.tar.gz edk2-07d8559c6bd8a8716e163a930a63f16e742aaa7a.tar.bz2 |
EmulatorPkg/Win: Add RTC support
Now firmware can display the time correctly.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Cc: Andrew Fish <afish@apple.com>
Diffstat (limited to 'EmulatorPkg')
-rw-r--r-- | EmulatorPkg/Win/Host/WinThunk.c | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c index ffe71ae..306fe75 100644 --- a/EmulatorPkg/Win/Host/WinThunk.c +++ b/EmulatorPkg/Win/Host/WinThunk.c @@ -482,14 +482,68 @@ SecGetTime ( OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
)
{
+ SYSTEMTIME SystemTime;
+ TIME_ZONE_INFORMATION TimeZone;
+
+ GetLocalTime (&SystemTime);
+ GetTimeZoneInformation (&TimeZone);
+
+ Time->Year = (UINT16)SystemTime.wYear;
+ Time->Month = (UINT8)SystemTime.wMonth;
+ Time->Day = (UINT8)SystemTime.wDay;
+ Time->Hour = (UINT8)SystemTime.wHour;
+ Time->Minute = (UINT8)SystemTime.wMinute;
+ Time->Second = (UINT8)SystemTime.wSecond;
+ Time->Nanosecond = (UINT32)(SystemTime.wMilliseconds * 1000000);
+ Time->TimeZone = (INT16)TimeZone.Bias;
+
+ if (Capabilities != NULL) {
+ Capabilities->Resolution = 1;
+ Capabilities->Accuracy = 50000000;
+ Capabilities->SetsToZero = FALSE;
+ }
+
+ Time->Daylight = 0;
+ if (TimeZone.StandardDate.wMonth) {
+ Time->Daylight = (UINT8)TimeZone.StandardDate.wMonth;
+ }
}
EFI_STATUS
SecSetTime (
IN EFI_TIME *Time
-)
+ )
{
- return EFI_SUCCESS;
+ TIME_ZONE_INFORMATION TimeZone;
+ SYSTEMTIME SystemTime;
+ BOOL Flag;
+
+ //
+ // Set Daylight savings time information and Time Zone
+ //
+ GetTimeZoneInformation (&TimeZone);
+ TimeZone.StandardDate.wMonth = Time->Daylight;
+ TimeZone.Bias = Time->TimeZone;
+ Flag = SetTimeZoneInformation (&TimeZone);
+ if (!Flag) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ SystemTime.wYear = Time->Year;
+ SystemTime.wMonth = Time->Month;
+ SystemTime.wDay = Time->Day;
+ SystemTime.wHour = Time->Hour;
+ SystemTime.wMinute = Time->Minute;
+ SystemTime.wSecond = Time->Second;
+ SystemTime.wMilliseconds = (INT16)(Time->Nanosecond / 1000000);
+
+ Flag = SetLocalTime (&SystemTime);
+
+ if (!Flag) {
+ return EFI_DEVICE_ERROR;
+ } else {
+ return EFI_SUCCESS;
+ }
}
EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
|