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 DD06021B02822 for ; Tue, 27 Nov 2018 03:27:08 -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 8FC6835F8; Tue, 27 Nov 2018 03:27:08 -0800 (PST) Received: from usa.arm.com (a75556-lin.blr.arm.com [10.162.2.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 82BE53F575; Tue, 27 Nov 2018 03:27:06 -0800 (PST) From: Jagadeesh Ujja To: edk2-devel@lists.01.org, liming.gao@intel.com, chao.b.zhang@intel.com, lersek@readhat.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Tue, 27 Nov 2018 16:56:26 +0530 Message-Id: <20181127112626.7854-12-jagadeesh.ujja@arm.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181127112626.7854-1-jagadeesh.ujja@arm.com> References: <20181127112626.7854-1-jagadeesh.ujja@arm.com> MIME-Version: 1.0 Subject: [RFC PATCH v2 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: Tue, 27 Nov 2018 11:27:09 -0000 Content-Transfer-Encoding: 8bit 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. Change-Id: I5b86a31c3023f31f04985e82a1089cf4d022f060 Signed-off-by: Jagadeesh Ujja Signed-off-by: Thomas Abraham --- .../Library/BaseCryptLib/BaseCryptLib.inf | 5 ++++ .../Library/BaseCryptLib/RuntimeCryptLib.inf | 5 ++++ .../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 c8aafefbab..df4aca6c20 100644 --- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf @@ -76,6 +76,7 @@ [Packages] MdePkg/MdePkg.dec CryptoPkg/CryptoPkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec [LibraryClasses] BaseLib @@ -86,6 +87,10 @@ 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 32628c8835..651a6736ba 100644 --- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf @@ -80,6 +80,7 @@ [Packages] MdePkg/MdePkg.dec CryptoPkg/CryptoPkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec [LibraryClasses] BaseLib @@ -91,6 +92,10 @@ 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 5f9b0c20d7..d01b5c5fc1 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.19.1