]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/FvbServicesRuntimeDxe/FvbInfo.c
Integrate patch from Andrew Fish to make it run on OS X.
[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
804405e7 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
ccd55824 37#include <Library/PcdLib.h>\r
38#include <Library/DevicePathLib.h>\r
9f0b86b7 39\r
804405e7 40#include <Guid/FirmwareFileSystem2.h>\r
41#include <Guid/SystemNvDataGuid.h>\r
42\r
43typedef struct {\r
44 UINT64 FvLength;\r
45 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;\r
46 //\r
47 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0\r
48 //\r
49 EFI_FV_BLOCK_MAP_ENTRY End[1];\r
50} EFI_FVB_MEDIA_INFO;\r
51\r
52EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {\r
53 //\r
54 // Recovery BOIS FVB\r
55 //\r
56 {\r
57 FixedPcdGet32 (PcdUnixFlashFvRecoverySize),\r
58 {\r
59 {\r
60 0,\r
61 }, // ZeroVector[16]\r
62 EFI_FIRMWARE_FILE_SYSTEM2_GUID,\r
63 FixedPcdGet32 (PcdUnixFlashFvRecoverySize),\r
64 EFI_FVH_SIGNATURE,\r
65 EFI_FVB2_READ_ENABLED_CAP |\r
66 EFI_FVB2_READ_STATUS |\r
67 EFI_FVB2_WRITE_ENABLED_CAP |\r
68 EFI_FVB2_WRITE_STATUS |\r
69 EFI_FVB2_ERASE_POLARITY,\r
70 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
71 0, // CheckSum\r
72 0, // ExtHeaderOffset\r
73 {\r
74 0,\r
75 }, // Reserved[1]\r
f7796c71 76 2, // Revision\r
804405e7 77 {\r
78 {\r
79 FixedPcdGet32 (PcdUnixFlashFvRecoverySize)/FixedPcdGet32 (PcdUnixFirmwareBlockSize),\r
80 FixedPcdGet32 (PcdUnixFirmwareBlockSize),\r
81 }\r
82 }\r
83 },\r
84 {\r
85 {\r
86 0,\r
87 0\r
88 }\r
89 }\r
90 },\r
91 //\r
92 // Systen NvStorage FVB\r
93 //\r
94 {\r
95 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
96 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
97 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
98 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),\r
99 {\r
100 {\r
101 0,\r
102 }, // ZeroVector[16]\r
5e9d6cae 103 EFI_SYSTEM_NV_DATA_FV_GUID,\r
804405e7 104 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
105 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
106 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
107 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),\r
108 EFI_FVH_SIGNATURE,\r
109 EFI_FVB2_READ_ENABLED_CAP |\r
110 EFI_FVB2_READ_STATUS |\r
111 EFI_FVB2_WRITE_ENABLED_CAP |\r
112 EFI_FVB2_WRITE_STATUS |\r
113 EFI_FVB2_ERASE_POLARITY,\r
114 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
115 0, // CheckSum\r
116 0, // ExtHeaderOffset\r
117 {\r
118 0,\r
119 }, // Reserved[1]\r
f7796c71 120 2, // Revision\r
804405e7 121 {\r
122 {\r
123 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
124 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
125 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
126 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdUnixFirmwareBlockSize),\r
127 FixedPcdGet32 (PcdUnixFirmwareBlockSize),\r
128 }\r
129 }\r
130 },\r
131 {\r
132 {\r
133 0,\r
134 0\r
135 }\r
136 }\r
137 }\r
138};\r
139\r
140EFI_STATUS\r
141GetFvbInfo (\r
142 IN UINT64 FvLength,\r
143 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo\r
144 )\r
145{\r
146 UINTN Index;\r
147\r
148 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {\r
149 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {\r
150 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;\r
151 return EFI_SUCCESS;\r
152 }\r
153 }\r
154\r
155 return EFI_NOT_FOUND;\r
156}\r