TianoCore EDK2 master
Loading...
Searching...
No Matches
PeiCryptLib.c
Go to the documentation of this file.
1
9#include <PiPei.h>
10#include <Library/BaseLib.h>
11#include <Library/DebugLib.h>
13#include <Ppi/Crypto.h>
14
26VOID *
28 VOID
29 )
30{
31 EFI_STATUS Status;
32 EDKII_CRYPTO_PPI *CryptoPpi;
33 UINTN Version;
34
35 CryptoPpi = NULL;
36 Status = PeiServicesLocatePpi (
37 &gEdkiiCryptoPpiGuid,
38 0,
39 NULL,
40 (VOID **)&CryptoPpi
41 );
42 if (EFI_ERROR (Status) || (CryptoPpi == NULL)) {
43 DEBUG ((DEBUG_ERROR, "[PeiCryptLib] Failed to locate Crypto PPI. Status = %r\n", Status));
44 ASSERT_EFI_ERROR (Status);
45 ASSERT (CryptoPpi != NULL);
46 return NULL;
47 }
48
49 Version = CryptoPpi->GetVersion ();
50 if (Version < EDKII_CRYPTO_VERSION) {
51 DEBUG ((DEBUG_ERROR, "[PeiCryptLib] Crypto PPI unsupported version %d\n", Version));
52 ASSERT (Version >= EDKII_CRYPTO_VERSION);
53 return NULL;
54 }
55
56 return (VOID *)CryptoPpi;
57}
UINT64 UINTN
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
#define NULL
Definition: Base.h:319
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
VOID * GetCryptoServices(VOID)
Definition: PeiCryptLib.c:27
#define EDKII_CRYPTO_VERSION
Definition: Crypto.h:24
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EDKII_CRYPTO_GET_VERSION GetVersion
Version.
Definition: Crypto.h:5432