]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c
EmulatorPkg: Replace BSD License with BSD+Patent License
[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
35 typedef struct {
36 UINT64 FvLength;
37 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
38 //
39 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
40 //
41 EFI_FV_BLOCK_MAP_ENTRY End[1];
42 } EFI_FVB_MEDIA_INFO;
43
44 EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
45 //
46 // Recovery BOIS FVB
47 //
48 {
49 FixedPcdGet32 (PcdEmuFlashFvRecoverySize),
50 {
51 {
52 0,
53 }, // ZeroVector[16]
54 EFI_FIRMWARE_FILE_SYSTEM2_GUID,
55 FixedPcdGet32 (PcdEmuFlashFvRecoverySize),
56 EFI_FVH_SIGNATURE,
57 EFI_FVB2_READ_ENABLED_CAP |
58 EFI_FVB2_READ_STATUS |
59 EFI_FVB2_WRITE_ENABLED_CAP |
60 EFI_FVB2_WRITE_STATUS |
61 EFI_FVB2_ERASE_POLARITY,
62 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
63 0, // CheckSum
64 0, // ExtHeaderOffset
65 {
66 0,
67 }, // Reserved[1]
68 2, // Revision
69 {
70 {
71 FixedPcdGet32 (PcdEmuFlashFvRecoverySize)/FixedPcdGet32 (PcdEmuFirmwareBlockSize),
72 FixedPcdGet32 (PcdEmuFirmwareBlockSize),
73 }
74 }
75 },
76 {
77 {
78 0,
79 0
80 }
81 }
82 },
83 //
84 // Systen NvStorage FVB
85 //
86 {
87 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
88 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
89 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
90 FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),
91 {
92 {
93 0,
94 }, // ZeroVector[16]
95 EFI_SYSTEM_NV_DATA_FV_GUID,
96 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
97 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
98 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
99 FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),
100 EFI_FVH_SIGNATURE,
101 EFI_FVB2_READ_ENABLED_CAP |
102 EFI_FVB2_READ_STATUS |
103 EFI_FVB2_WRITE_ENABLED_CAP |
104 EFI_FVB2_WRITE_STATUS |
105 EFI_FVB2_ERASE_POLARITY,
106 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
107 0, // CheckSum
108 0, // ExtHeaderOffset
109 {
110 0,
111 }, // Reserved[1]
112 2, // Revision
113 {
114 {
115 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
116 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
117 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
118 FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdEmuFirmwareBlockSize),
119 FixedPcdGet32 (PcdEmuFirmwareBlockSize),
120 }
121 }
122 },
123 {
124 {
125 0,
126 0
127 }
128 }
129 }
130 };
131
132 EFI_STATUS
133 GetFvbInfo (
134 IN UINT64 FvLength,
135 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
136 )
137 {
138 UINTN Index;
139
140 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
141 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
142 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
143 return EFI_SUCCESS;
144 }
145 }
146
147 return EFI_NOT_FOUND;
148 }