From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Hao Wu <hao.a.wu@intel.com>, Andrew Fish <afish@apple.com>
Subject: [PATCH v2 07/12] EmulatorPkg/Win: Add RTC support
Date: Thu, 23 Aug 2018 17:56:15 +0800 [thread overview]
Message-ID: <20180823095620.280996-8-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20180823095620.280996-1-ruiyu.ni@intel.com>
Now firmware can display the time correctly.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Andrew Fish <afish@apple.com>
---
EmulatorPkg/Win/Host/WinThunk.c | 58 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c
index ffe71aef9a..306fe75ecd 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 = {
--
2.16.1.windows.1
next prev parent reply other threads:[~2018-08-23 9:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-23 9:56 [PATCH v2 00/12] Add WinHost support in EmulatorPkg Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 01/12] EmulatorPkg/ThunkProtocolList: Fix VS build failure Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 02/12] EmulatorPkg/Win: Add Windows host support Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 03/12] EmulatorPkg/Win: Enable source level debugging Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 04/12] EmulatorPkg/Win: Enable native OS console as firmware console Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 05/12] EmulatorPkg/Win: Add input/output support Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 06/12] EmulatorPkg/Win: Add timer and interrupt support Ruiyu Ni
2018-08-23 9:56 ` Ruiyu Ni [this message]
2018-08-23 9:56 ` [PATCH v2 08/12] EmulatorPkg/Win: Add SimpleFileSystem support Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 09/12] EmulatorPkg/Win: Add BlockIo support Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 10/12] EmulatorPkg/PlatformBds: Signal EndOfDxe in platform BDS Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 11/12] EmulatorPkg/EmuFileSystem: Fix a bug that causes Close() assertion Ruiyu Ni
2018-08-23 9:56 ` [PATCH v2 12/12] EmulatorPkg/DSC: Remove FS mapping to EDK Shell bin directory Ruiyu Ni
2018-08-23 15:24 ` [PATCH v2 00/12] Add WinHost support in EmulatorPkg Kinney, Michael D
2018-08-23 16:27 ` Ni, Ruiyu
2018-08-27 6:43 ` Wu, Hao A
2018-08-30 1:57 ` Shia, Cinnamon
2018-09-04 2:32 ` Ni, Ruiyu
2018-09-04 3:12 ` krishnaLee
2018-09-04 15:12 ` Kinney, Michael D
2018-09-04 6:17 ` Shia, Cinnamon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180823095620.280996-8-ruiyu.ni@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox