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