VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/Fv.c@ 107675

最後變更 在這個檔案從107675是 99404,由 vboxsync 提交於 2 年 前

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 4.0 KB
 
1/** @file
2 Build FV related hobs for platform.
3
4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include "PiPei.h"
10#include "Platform.h"
11#include <Library/DebugLib.h>
12#include <Library/HobLib.h>
13#include <Library/PeiServicesLib.h>
14#include <Library/PcdLib.h>
15#ifdef VBOX
16# include <Library/BaseMemoryLib.h>
17#endif
18
19/**
20 Publish PEI & DXE (Decompressed) Memory based FVs to let PEI
21 and DXE know about them.
22
23 @retval EFI_SUCCESS Platform PEI FVs were initialized successfully.
24
25**/
26EFI_STATUS
27PeiFvInitialization (
28 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
29 )
30{
31 BOOLEAN SecureS3Needed;
32#ifdef VBOX
33 EFI_PHYSICAL_ADDRESS PhysOvmfDxeMemFvBaseRelocated = 0;
34 VOID *OvmfDxeMemFvBaseRelocated;
35#endif
36
37 DEBUG ((DEBUG_INFO, "Platform PEI Firmware Volume Initialization\n"));
38
39#ifdef VBOX
40 /*
41 * Relocate the DXE firmware to the top of the RAM so it doesn't interfer with older OS X bootloaders
42 * trying to allocate memory in the area where MEMFD is currently residing.
43 */
44 PeiServicesAllocatePages (EfiRuntimeServicesCode,
45 EFI_SIZE_TO_PAGES(PcdGet32 (PcdOvmfDxeMemFvSize)),
46 &PhysOvmfDxeMemFvBaseRelocated);
47
48 OvmfDxeMemFvBaseRelocated = (VOID *)(UINTN)PhysOvmfDxeMemFvBaseRelocated;
49 CopyMem (OvmfDxeMemFvBaseRelocated, (VOID *)(UINTN)PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
50
51 //
52 // Let DXE know about the DXE FV
53 //
54 BuildFvHob (PhysOvmfDxeMemFvBaseRelocated, PcdGet32 (PcdOvmfDxeMemFvSize));
55
56 SecureS3Needed = PlatformInfoHob->S3Supported && PlatformInfoHob->SmmSmramRequire;
57
58 //
59 // Create a memory allocation HOB for the DXE FV.
60 //
61 // If "secure" S3 is needed, then SEC will decompress both PEI and DXE
62 // firmware volumes at S3 resume too, hence we need to keep away the OS from
63 // DXEFV as well. Otherwise we only need to keep away DXE itself from the
64 // DXEFV area.
65 //
66 BuildMemoryAllocationHob (
67 PhysOvmfDxeMemFvBaseRelocated,
68 PcdGet32 (PcdOvmfDxeMemFvSize),
69 SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData
70 );
71
72 //
73 // Let PEI know about the DXE FV so it can find the DXE Core
74 //
75 PeiServicesInstallFvInfoPpi (
76 NULL,
77 (VOID *)(UINTN)OvmfDxeMemFvBaseRelocated,
78 PcdGet32 (PcdOvmfDxeMemFvSize),
79 NULL,
80 NULL
81 );
82#else
83
84 //
85 // Create a memory allocation HOB for the PEI FV.
86 //
87 // Allocate as ACPI NVS is S3 is supported
88 //
89 BuildMemoryAllocationHob (
90 PcdGet32 (PcdOvmfPeiMemFvBase),
91 PcdGet32 (PcdOvmfPeiMemFvSize),
92 PlatformInfoHob->S3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
93 );
94
95 //
96 // Let DXE know about the DXE FV
97 //
98 BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
99
100 SecureS3Needed = PlatformInfoHob->S3Supported && PlatformInfoHob->SmmSmramRequire;
101
102 //
103 // Create a memory allocation HOB for the DXE FV.
104 //
105 // If "secure" S3 is needed, then SEC will decompress both PEI and DXE
106 // firmware volumes at S3 resume too, hence we need to keep away the OS from
107 // DXEFV as well. Otherwise we only need to keep away DXE itself from the
108 // DXEFV area.
109 //
110 BuildMemoryAllocationHob (
111 PcdGet32 (PcdOvmfDxeMemFvBase),
112 PcdGet32 (PcdOvmfDxeMemFvSize),
113 SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData
114 );
115
116 //
117 // Additionally, said decompression will use temporary memory above the end
118 // of DXEFV, so let's keep away the OS from there too.
119 //
120 if (SecureS3Needed) {
121 UINT32 DxeMemFvEnd;
122
123 DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +
124 PcdGet32 (PcdOvmfDxeMemFvSize);
125 BuildMemoryAllocationHob (
126 DxeMemFvEnd,
127 PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd,
128 EfiACPIMemoryNVS
129 );
130 }
131
132 //
133 // Let PEI know about the DXE FV so it can find the DXE Core
134 //
135 PeiServicesInstallFvInfoPpi (
136 NULL,
137 (VOID *)(UINTN)PcdGet32 (PcdOvmfDxeMemFvBase),
138 PcdGet32 (PcdOvmfDxeMemFvSize),
139 NULL,
140 NULL
141 );
142#endif
143
144 return EFI_SUCCESS;
145}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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