Skip to content

Commit

Permalink
[Binary Crypto] Remove the functions and macros from Crypto.c template
Browse files Browse the repository at this point in the history
Some of these macros and functions were present for the EDK2 upstream submission,
but 1) that submission never landed and 2) we don't currently support them in Mu.
  • Loading branch information
Bret Barkelew authored and kenlautner committed May 4, 2023
1 parent 8b8569e commit 9f3e8b2
Showing 1 changed file with 5 additions and 74 deletions.
79 changes: 5 additions & 74 deletions CryptoPkg/Driver/Packaging/Crypto.template.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,80 +13,11 @@
#include <Library/TlsLib.h>
#include <Protocol/Crypto.h>

/**
A macro used to retrieve the FixedAtBuild PcdCryptoServiceFamilyEnable with a
typecast to its associcted structure type PCD_CRYPTO_SERVICE_FAMILY_ENABLE.
**/
#define EDKII_CRYPTO_PCD(Name) \
(FixedPcdGetBool (PcdCryptoService##Name))

/**
A macro used to call a non-void BaseCryptLib function if it is enabled.
If a BaseCryptLib function is not enabled, there will be no references to it
from this module and will be optimized away reducing the size of this module.
@param Function The name of the BaseCryptLib function.
@param Args The argument list to pass to Function.
@param ErrorReturnValue The value to return if the BaseCryptLib function is
not enabled.
**/
#define CALL_BASECRYPTLIB(Function, Args, ErrorReturnValue) \
EDKII_CRYPTO_PCD(Function) \
? Function Args \
: (BaseCryptLibServiceNotEnabled (#Function), ErrorReturnValue)

/**
A macro used to call a void BaseCryptLib function if it is enabled.
If a BaseCryptLib function is not enabled, there will be no references to it
from this module and will be optimized away reducing the size of this module.
@param Enable The name of the enable field in PCD
PcdCryptoServiceFamilyEnable for the BaseCryptLib
function being called. If the value of this field
is non-zero, then the BaseCryptLib function is
enabled.
@param Function The name of the BaseCryptLib function.
@param Args The argument list to pass to Function.
**/
#define CALL_VOID_BASECRYPTLIB(Function, Args) \
EDKII_CRYPTO_PCD(Function) \
? Function Args \
: BaseCryptLibServiceNotEnabled (#Function)

/**
* A macro that will check if the PCD is enabled for RELEASE builds
*/
#define NULL_IF_DISABLED(Function) \
EDKII_CRYPTO_PCD(Function) \
? CryptoService##Function \
: NULL

/**
Internal worker function that prints a debug message and asserts if a call is
made to a BaseCryptLib function that is not enabled in the EDK II Crypto
Protocol/PPI.
If this debug message and assert are observed, then a module is using
BaseCryptLib function that is not enabled in a Crypto driver. The
PcdCryptoServiceFamilyEnable should be updated to enable the missing service.
@param[in] FunctionName Null-terminated ASCII string that is the name of an
EDK II Crypto service.
**/
static
VOID
BaseCryptLibServiceNotEnabled (
IN CONST CHAR8 *FunctionName
)
{
DEBUG ((DEBUG_ERROR, "[%a] Function %a() is not enabled\n", gEfiCallerBaseName, FunctionName));
ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
}
// MU_CHANGE - Remove BaseCryptLibServiceNotEnabled and macros
// These were added for upstreaming into EDK2 and are
// not used by Mu. They may eventually land in EDK2, at
// which point we will need to make a decision about
// their inclusion here.

/**
Returns the version of the EDK II Crypto Protocol.
Expand Down

0 comments on commit 9f3e8b2

Please sign in to comment.