From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 49A0021102DBB for ; Thu, 23 Aug 2018 02:51:42 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2018 02:51:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,278,1531810800"; d="scan'208";a="85740748" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.8]) by orsmga002.jf.intel.com with ESMTP; 23 Aug 2018 02:51:41 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Hao Wu , Andrew Fish Date: Thu, 23 Aug 2018 17:52:10 +0800 Message-Id: <20180823095215.274248-8-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180823095215.274248-1-ruiyu.ni@intel.com> References: <20180823095215.274248-1-ruiyu.ni@intel.com> Subject: [PATCH 07/12] EmulatorPkg/Win: Add RTC support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Aug 2018 09:51:42 -0000 Now firmware can display the time correctly. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Hao Wu Cc: Andrew Fish --- 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