summaryrefslogtreecommitdiffstats
path: root/CryptoPkg/Driver/CryptoDxe.c
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2019-11-21 09:24:41 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-02-07 16:32:13 +0000
commitcc1d13c9228d988071834b12c8494efb28b55802 (patch)
treec0707b9b5abb10174657d478c0d6c1ef04da98c3 /CryptoPkg/Driver/CryptoDxe.c
parent3b0e04305b2559da8deec7e1acba2d9e9902b80e (diff)
downloadedk2-cc1d13c9228d988071834b12c8494efb28b55802.tar.gz
edk2-cc1d13c9228d988071834b12c8494efb28b55802.tar.bz2
edk2-cc1d13c9228d988071834b12c8494efb28b55802.zip
CryptoPkg/Driver: Add Crypto PEIM, DXE, and SMM modules
https://bugzilla.tianocore.org/show_bug.cgi?id=2420 Based on the following package with changes to merge into CryptoPkg. https://github.com/microsoft/mu_plus/tree/dev/201908/SharedCryptoPkg Add the CryptoPei, CryptoDxe, and CryptoSmm modules that produce EDK II Crypto Protocols/PPIs that provide the same services as the BaseCryptLib class. In order to optimize the size of CryptoPei, CryptoDxe, and CryptoSmm modules for a specific platform, the FixedAtBuild PCD gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable is used to determine if a specific service is enabled or disabled. If a service is enabled, then a call is made to the BaseCryptLib service. If the service is disabled, then a DEBUG() message and ASSERT() are performed and a default return value is returned. This provides simple detection of a service that is disabled but is used by another module when DEBUG()/ASSERT() macros are enabled. The use of a FixedAtBuild PCD is required so the compiler and linker know each services enable/disable setting at build time and allows disabled services to be optimized away. CryptoPei supports both pre-mem and post-mem use cases. If CryptoPei is initially dispatched pre-mmem, the the register for shadow service is used so the Crypto PPI can be reinstalled post-mem. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Xiaoyu Lu <xiaoyux.lu@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Diffstat (limited to 'CryptoPkg/Driver/CryptoDxe.c')
-rw-r--r--CryptoPkg/Driver/CryptoDxe.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/CryptoPkg/Driver/CryptoDxe.c b/CryptoPkg/Driver/CryptoDxe.c
new file mode 100644
index 0000000000..ee44c03cc4
--- /dev/null
+++ b/CryptoPkg/Driver/CryptoDxe.c
@@ -0,0 +1,38 @@
+/** @file
+ Installs the EDK II Crypto Protocol
+
+ Copyright (C) Microsoft Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/Crypto.h>
+
+extern CONST EDKII_CRYPTO_PROTOCOL mEdkiiCrypto;
+
+/**
+ The module Entry Point of the Crypto Dxe Driver.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval Other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+CryptoDxeEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return gBS->InstallMultipleProtocolInterfaces(
+ &ImageHandle,
+ &gEdkiiCryptoProtocolGuid,
+ (EDKII_CRYPTO_PROTOCOL *) &mEdkiiCrypto,
+ NULL
+ );
+}