TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptoPei.c
Go to the documentation of this file.
1
11#include <PiPei.h>
13#include <Library/DebugLib.h>
14#include <Ppi/Crypto.h>
15
16extern CONST EDKII_CRYPTO_PROTOCOL mEdkiiCrypto;
17
18CONST EFI_PEI_PPI_DESCRIPTOR mEdkiiCryptoPpiList = {
19 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
20 &gEdkiiCryptoPpiGuid,
21 (EDKII_CRYPTO_PPI *)&mEdkiiCrypto
22};
23
33EFIAPI
35 IN EFI_PEI_FILE_HANDLE FileHandle,
36 IN CONST EFI_PEI_SERVICES **PeiServices
37 )
38{
39 EFI_STATUS Status;
40 VOID *MemoryDiscoveredPpi;
41 EDKII_CRYPTO_PPI *EdkiiCryptoPpi;
42 EFI_PEI_PPI_DESCRIPTOR *EdkiiCryptoPpiDescriptor;
43
44 //
45 // Not all Open SSL services support XIP due to use of global variables.
46 // Use gEfiPeiMemoryDiscoveredPpiGuid to detect Pre-Mem and Post-Mem and
47 // always shadow this module in memory in Post-Mem.
48 //
49 Status = PeiServicesLocatePpi (
50 &gEfiPeiMemoryDiscoveredPpiGuid,
51 0,
52 NULL,
53 (VOID **)&MemoryDiscoveredPpi
54 );
55 if (Status == EFI_NOT_FOUND) {
56 //
57 // CryptoPei is dispatched before gEfiPeiMemoryDiscoveredPpiGuid
58 //
59 Status = PeiServicesRegisterForShadow (FileHandle);
60 ASSERT_EFI_ERROR (Status);
61 if (!EFI_ERROR (Status)) {
62 //
63 // First CryptoPpi installation. CryptoPei could come from memory or flash
64 // it will be re-installed after gEfiPeiMemoryDiscoveredPpiGuid
65 //
66 DEBUG ((DEBUG_INFO, "CryptoPeiEntry: Install Pre-Memory Crypto PPI\n"));
67 Status = PeiServicesInstallPpi (&mEdkiiCryptoPpiList);
68 ASSERT_EFI_ERROR (Status);
69 }
70 } else if (Status == EFI_SUCCESS) {
71 //
72 // CryptoPei is dispatched after gEfiPeiMemoryDiscoveredPpiGuid
73 //
74 Status = PeiServicesLocatePpi (
75 &gEdkiiCryptoPpiGuid,
76 0,
77 &EdkiiCryptoPpiDescriptor,
78 (VOID **)&EdkiiCryptoPpi
79 );
80 if (!EFI_ERROR (Status)) {
81 //
82 // CryptoPei was also dispatched before gEfiPeiMemoryDiscoveredPpiGuid
83 //
84 DEBUG ((DEBUG_INFO, "CryptoPeiEntry: ReInstall Post-Memmory Crypto PPI\n"));
86 EdkiiCryptoPpiDescriptor,
87 &mEdkiiCryptoPpiList
88 );
89 ASSERT_EFI_ERROR (Status);
90 } else {
91 DEBUG ((DEBUG_INFO, "CryptoPeiEntry: Install Post-Memmory Crypto PPI\n"));
92 Status = PeiServicesInstallPpi (&mEdkiiCryptoPpiList);
93 }
94 } else {
95 ASSERT_EFI_ERROR (Status);
96 }
97
98 return Status;
99}
EFI_STATUS EFIAPI CryptoPeiEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
Definition: CryptoPei.c:34
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
EFI_STATUS EFIAPI PeiServicesReInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi, IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi)
EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
VOID * EFI_PEI_FILE_HANDLE
Definition: PiPeiCis.h:26
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112