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