]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / FvbServicesRuntimeDxe / FvbInfo.c
1 /*++ @file
2 Defines data structure that is the volume header found.These data is intent
3 to decouple FVB driver with FV header.
4
5 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2011, Apple Inc. All rights reserved.
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9
10 **/
11
12 #include <PiDxe.h>
13
14 #include <Guid/EventGroup.h>
15 #include <Guid/FirmwareFileSystem2.h>
16 #include <Guid/SystemNvDataGuid.h>
17
18 #include <Protocol/FirmwareVolumeBlock.h>
19 #include <Protocol/DevicePath.h>
20
21 #include <Library/UefiLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/BaseLib.h>
24 #include <Library/DxeServicesTableLib.h>
25 #include <Library/UefiRuntimeLib.h>
26 #include <Library/DebugLib.h>
27 #include <Library/HobLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/PcdLib.h>
32 #include <Library/DevicePathLib.h>
33
34 typedef struct {
35 UINT64 FvLength;
36 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
37 //
38 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
39 //
40 EFI_FV_BLOCK_MAP_ENTRY End[1];
41 } EFI_FVB_MEDIA_INFO;
42
43 EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
44 //
45 // Recovery BOIS FVB
46 //
47 {
48 FixedPcdGet32 (PcdEmuFlashFvRecoverySize),
49 {
50 {
51 0,
52 }, // ZeroVector[16]
53 EFI_FIRMWARE_FILE_SYSTEM2_GUID,
54 FixedPcdGet32 (PcdEmuFlashFvRecoverySize),
55 EFI_FVH_SIGNATURE,
56 EFI_FVB2_READ_ENABLED_CAP |
57 EFI_FVB2_READ_STATUS |
58 EFI_FVB2_WRITE_ENABLED_CAP |
59 EFI_FVB2_WRITE_STATUS |
60 EFI_FVB2_ERASE_POLARITY,
61 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
62 0, // CheckSum
63 0, // ExtHeaderOffset
64 {
65 0,
66 }, // Reserved[1]
67 2, // Revision
68 {
69 {
70 FixedPcdGet32 (PcdEmuFlashFvRecoverySize)/FixedPcdGet32 (PcdEmuFirmwareBlockSize),
71 FixedPcdGet32 (PcdEmuFirmwareBlockSize),
72 }
73 }
74 },
75 {
76 {
77 0,
78 0
79 }
80 }
81 },
82 //
83 // Systen NvStorage FVB
84 //
85 {
86 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
87 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
88 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
89 FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),
90 {
91 {
92 0,
93 }, // ZeroVector[16]
94 EFI_SYSTEM_NV_DATA_FV_GUID,
95 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
96 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
97 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
98 FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),
99 EFI_FVH_SIGNATURE,
100 EFI_FVB2_READ_ENABLED_CAP |
101 EFI_FVB2_READ_STATUS |
102 EFI_FVB2_WRITE_ENABLED_CAP |
103 EFI_FVB2_WRITE_STATUS |
104 EFI_FVB2_ERASE_POLARITY,
105 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
106 0, // CheckSum
107 0, // ExtHeaderOffset
108 {
109 0,
110 }, // Reserved[1]
111 2, // Revision
112 {
113 {
114 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
115 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
116 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
117 FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdEmuFirmwareBlockSize),
118 FixedPcdGet32 (PcdEmuFirmwareBlockSize),
119 }
120 }
121 },
122 {
123 {
124 0,
125 0
126 }
127 }
128 }
129 };
130
131 EFI_STATUS
132 GetFvbInfo (
133 IN UINT64 FvLength,
134 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
135 )
136 {
137 UINTN Index;
138
139 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
140 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
141 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
142 return EFI_SUCCESS;
143 }
144 }
145
146 return EFI_NOT_FOUND;
147 }