VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Driver/CryptoPei.c@ 85718

Last change on this file since 85718 was 85718, checked in by vboxsync, 4 years ago

Devices/EFI: Merge edk-stable202005 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1/** @file
2 Installs the EDK II Crypto PPI. If this PEIM is dispatched before memory is
3 discovered, the RegisterForShadow() feature is used to reload this PEIM into
4 memory after memory is discovered.
5
6 Copyright (C) Microsoft Corporation. All rights reserved.
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9**/
10
11#include <PiPei.h>
12#include <Library/PeiServicesLib.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
24/**
25Entry to CryptoPeiEntry.
26
27@param FileHandle The image handle.
28@param PeiServices The PEI services table.
29
30@retval Status From internal routine or boot object, should not fail
31**/
32EFI_STATUS
33EFIAPI
34CryptoPeiEntry (
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"));
85 Status = PeiServicesReInstallPpi (
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}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette