From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=jagadeesh.ujja@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 6ED1621B02822 for ; Wed, 28 Nov 2018 01:35:45 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D4CD1B55; Wed, 28 Nov 2018 01:35:45 -0800 (PST) Received: from usa.arm.com (a075555-lin.blr.arm.com [10.162.2.152]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 53FD63F5A0; Wed, 28 Nov 2018 01:35:43 -0800 (PST) From: Jagadeesh Ujja To: edk2-devel@lists.01.org, liming.gao@intel.com, chao.b.zhang@intel.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Wed, 28 Nov 2018 15:05:09 +0530 Message-Id: <1543397709-31847-12-git-send-email-jagadeesh.ujja@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543397709-31847-1-git-send-email-jagadeesh.ujja@arm.com> References: <1543397709-31847-1-git-send-email-jagadeesh.ujja@arm.com> Subject: [RFC PATCH v3 11/11] CryptoPkg/BaseCryptLib: Hack to get time in MM Standalone mode 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: Wed, 28 Nov 2018 09:35:45 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:45 -0000 This is hack to get the time when executing in MM Standalone mode. It is not clear how to implement a function that gets the current time. So using this as a hack for now. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja --- CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf | 5 ++++ CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf | 5 ++++ CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 27 +++++++++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf index c8aafefbab9c..df4aca6c20e2 100644 --- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf @@ -76,6 +76,7 @@ [Sources.AARCH64] [Packages] MdePkg/MdePkg.dec CryptoPkg/CryptoPkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec [LibraryClasses] BaseLib @@ -86,6 +87,10 @@ [LibraryClasses] OpensslLib IntrinsicLib PrintLib + PcdLib + +[FeaturePcd] + gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable # # Remove these [BuildOptions] after this library is cleaned up diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf index 32628c8835a6..651a6736ba48 100644 --- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf @@ -80,6 +80,7 @@ [Sources.AARCH64] [Packages] MdePkg/MdePkg.dec CryptoPkg/CryptoPkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec [LibraryClasses] BaseLib @@ -91,6 +92,10 @@ [LibraryClasses] OpensslLib IntrinsicLib PrintLib + PcdLib + +[FeaturePcd] + gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable # # Remove these [BuildOptions] after this library is cleaned up diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c index 5f9b0c20d75d..d01b5c5fc113 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c @@ -3,6 +3,7 @@ for OpenSSL-based Cryptographic Library (used in DXE & RUNTIME). Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018, ARM Limited. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -77,12 +78,26 @@ time_t time (time_t *timer) time_t CalTime; UINTN Year; - // - // Get the current time and date information - // - Status = gRT->GetTime (&Time, NULL); - if (EFI_ERROR (Status) || (Time.Year < 1970)) { - return 0; + if (!PcdGetBool (PcdStandaloneMmEnable)) { + // + // Get the current time and date information + // + Status = gRT->GetTime (&Time, NULL); + if (EFI_ERROR (Status) || (Time.Year < 1970)) { + return 0; + } + } else { + // + //[ToDo] Find out a way to get the current time for code executing as MM_STANDALONE + // + Time.Year = 2007; + Time.Month = 11; + Time.Day = 29; + Time.Hour = 17; + Time.Minute = 43; + Time.Second = 30; + + Year = (UINTN) (Time.Year % 100); } // -- 2.7.4