]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/FvbServicesRuntimeDxe/FvbInfo.c
Clean Unix FVB driver doesn't produce the undefined FVB extension protocol.
[mirror_edk2.git] / UnixPkg / FvbServicesRuntimeDxe / FvbInfo.c
CommitLineData
804405e7 1/*++\r
2\r
3Copyright (c) 2006 - 2008, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 FvbInfo.c\r
15\r
16Abstract:\r
17\r
18 Defines data structure that is the volume header found.These data is intent\r
19 to decouple FVB driver with FV header.\r
20\r
21--*/\r
22#include "PiDxe.h"\r
23#include <Guid/EventGroup.h>\r
804405e7 24#include <Protocol/FirmwareVolumeBlock.h>\r
25#include <Guid/AlternateFvBlock.h>\r
26#include <Protocol/DevicePath.h>\r
27\r
28#include <Library/UefiLib.h>\r
29#include <Library/UefiDriverEntryPoint.h>\r
30#include <Library/BaseLib.h>\r
31#include <Library/DxeServicesTableLib.h>\r
32#include <Library/UefiRuntimeLib.h>\r
33#include <Library/DebugLib.h>\r
34#include <Library/HobLib.h>\r
35#include <Library/BaseMemoryLib.h>\r
36#include <Library/MemoryAllocationLib.h>\r
37#include <Library/UefiBootServicesTableLib.h>\r
9f0b86b7 38#include <Library/PcdLib.h>
39#include <Library/DevicePathLib.h>
40\r
804405e7 41#include <Guid/FirmwareFileSystem2.h>\r
42#include <Guid/SystemNvDataGuid.h>\r
43\r
44typedef struct {\r
45 UINT64 FvLength;\r
46 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;\r
47 //\r
48 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0\r
49 //\r
50 EFI_FV_BLOCK_MAP_ENTRY End[1];\r
51} EFI_FVB_MEDIA_INFO;\r
52\r
53EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {\r
54 //\r
55 // Recovery BOIS FVB\r
56 //\r
57 {\r
58 FixedPcdGet32 (PcdUnixFlashFvRecoverySize),\r
59 {\r
60 {\r
61 0,\r
62 }, // ZeroVector[16]\r
63 EFI_FIRMWARE_FILE_SYSTEM2_GUID,\r
64 FixedPcdGet32 (PcdUnixFlashFvRecoverySize),\r
65 EFI_FVH_SIGNATURE,\r
66 EFI_FVB2_READ_ENABLED_CAP |\r
67 EFI_FVB2_READ_STATUS |\r
68 EFI_FVB2_WRITE_ENABLED_CAP |\r
69 EFI_FVB2_WRITE_STATUS |\r
70 EFI_FVB2_ERASE_POLARITY,\r
71 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
72 0, // CheckSum\r
73 0, // ExtHeaderOffset\r
74 {\r
75 0,\r
76 }, // Reserved[1]\r
77 1, // Revision\r
78 {\r
79 {\r
80 FixedPcdGet32 (PcdUnixFlashFvRecoverySize)/FixedPcdGet32 (PcdUnixFirmwareBlockSize),\r
81 FixedPcdGet32 (PcdUnixFirmwareBlockSize),\r
82 }\r
83 }\r
84 },\r
85 {\r
86 {\r
87 0,\r
88 0\r
89 }\r
90 }\r
91 },\r
92 //\r
93 // Systen NvStorage FVB\r
94 //\r
95 {\r
96 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
97 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
98 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
99 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),\r
100 {\r
101 {\r
102 0,\r
103 }, // ZeroVector[16]\r
5e9d6cae 104 EFI_SYSTEM_NV_DATA_FV_GUID,\r
804405e7 105 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
106 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
107 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
108 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),\r
109 EFI_FVH_SIGNATURE,\r
110 EFI_FVB2_READ_ENABLED_CAP |\r
111 EFI_FVB2_READ_STATUS |\r
112 EFI_FVB2_WRITE_ENABLED_CAP |\r
113 EFI_FVB2_WRITE_STATUS |\r
114 EFI_FVB2_ERASE_POLARITY,\r
115 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
116 0, // CheckSum\r
117 0, // ExtHeaderOffset\r
118 {\r
119 0,\r
120 }, // Reserved[1]\r
121 1, // Revision\r
122 {\r
123 {\r
124 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
125 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
126 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
127 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdUnixFirmwareBlockSize),\r
128 FixedPcdGet32 (PcdUnixFirmwareBlockSize),\r
129 }\r
130 }\r
131 },\r
132 {\r
133 {\r
134 0,\r
135 0\r
136 }\r
137 }\r
138 }\r
139};\r
140\r
141EFI_STATUS\r
142GetFvbInfo (\r
143 IN UINT64 FvLength,\r
144 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo\r
145 )\r
146{\r
147 UINTN Index;\r
148\r
149 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {\r
150 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {\r
151 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;\r
152 return EFI_SUCCESS;\r
153 }\r
154 }\r
155\r
156 return EFI_NOT_FOUND;\r
157}\r