TianoCore EDK2 master
Loading...
Searching...
No Matches
StandaloneMmCryptLib.c
Go to the documentation of this file.
1
10#include <PiMm.h>
11#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
14#include <Protocol/SmmCrypto.h>
15
16EDKII_SMM_CRYPTO_PROTOCOL *mSmmCryptoProtocol = NULL;
17
28VOID *
30 VOID
31 )
32{
33 return (VOID *)mSmmCryptoProtocol;
34}
35
48EFIAPI
50 IN EFI_HANDLE ImageHandle,
51 IN EFI_MM_SYSTEM_TABLE *MmSystemTable
52 )
53{
54 EFI_STATUS Status;
55 UINTN Version;
56
57 Status = gMmst->MmLocateProtocol (
58 &gEdkiiSmmCryptoProtocolGuid,
59 NULL,
60 (VOID **)&mSmmCryptoProtocol
61 );
62 if (EFI_ERROR (Status) || (mSmmCryptoProtocol == NULL)) {
63 DEBUG ((DEBUG_ERROR, "[StandaloneMmCryptLib] Failed to locate Crypto SMM Protocol. Status = %r\n", Status));
64 ASSERT_EFI_ERROR (Status);
65 ASSERT (mSmmCryptoProtocol != NULL);
66 mSmmCryptoProtocol = NULL;
67 return EFI_NOT_FOUND;
68 }
69
70 Version = mSmmCryptoProtocol->GetVersion ();
71 if (Version < EDKII_CRYPTO_VERSION) {
72 DEBUG ((DEBUG_ERROR, "[StandaloneMmCryptLib] Crypto SMM Protocol unsupported version %d\n", Version));
73 ASSERT (Version >= EDKII_CRYPTO_VERSION);
74 mSmmCryptoProtocol = NULL;
75 return EFI_NOT_FOUND;
76 }
77
78 return EFI_SUCCESS;
79}
UINT64 UINTN
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define EDKII_CRYPTO_VERSION
Definition: Crypto.h:24
EFI_STATUS EFIAPI StandaloneMmCryptLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
VOID * GetCryptoServices(VOID)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EDKII_CRYPTO_GET_VERSION GetVersion
Version.
Definition: Crypto.h:5432