Fixed EDKT116, which more than one target will break the build.
[mirror_edk2.git] / EdkNt32Pkg / RuntimeDxe / FvbServices / nt32 / FvbInfo.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, 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\r
23#include "FlashLayout.h"\r
24\r
25#define FIRMWARE_BLOCK_SIZE 0x10000\r
26\r
27typedef struct {\r
28 UINT64 FvLength;\r
29 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;\r
30 //\r
31 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0\r
32 //\r
33 EFI_FV_BLOCK_MAP_ENTRY End[1];\r
34} EFI_FVB_MEDIA_INFO;\r
35\r
36#define FVB_MEDIA_BLOCK_SIZE FIRMWARE_BLOCK_SIZE\r
37#define RECOVERY_BOIS_BLOCK_NUM FIRMWARE_BLOCK_NUMBER\r
38#define SYSTEM_NV_BLOCK_NUM 2\r
39\r
40EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {\r
41 //\r
42 // Recovery BOIS FVB\r
43 //\r
44 {\r
45 EFI_WINNT_FIRMWARE_LENGTH,\r
46 {\r
47 {\r
48 0,\r
49 }, // ZeroVector[16]\r
50 EFI_FIRMWARE_FILE_SYSTEM_GUID,\r
51 FVB_MEDIA_BLOCK_SIZE * RECOVERY_BOIS_BLOCK_NUM,\r
52 EFI_FVH_SIGNATURE,\r
53 EFI_FVB_READ_ENABLED_CAP |\r
54 EFI_FVB_READ_STATUS |\r
55 EFI_FVB_WRITE_ENABLED_CAP |\r
56 EFI_FVB_WRITE_STATUS |\r
57 EFI_FVB_ERASE_POLARITY,\r
58 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
59 0, // CheckSum\r
60 {\r
61 0,\r
62 }, // Reserved[3]\r
63 1, // Revision\r
64 {\r
65 RECOVERY_BOIS_BLOCK_NUM,\r
66 FVB_MEDIA_BLOCK_SIZE,\r
67 }\r
68 },\r
69 {\r
70 0,\r
71 0\r
72 }\r
73 },\r
74 //\r
75 // Systen NvStorage FVB\r
76 //\r
77 {\r
78 EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,\r
79 {\r
80 {\r
81 0,\r
82 }, // ZeroVector[16]\r
83 EFI_SYSTEM_NV_DATA_HOB_GUID,\r
84 FVB_MEDIA_BLOCK_SIZE * SYSTEM_NV_BLOCK_NUM,\r
85 EFI_FVH_SIGNATURE,\r
86 EFI_FVB_READ_ENABLED_CAP |\r
87 EFI_FVB_READ_STATUS |\r
88 EFI_FVB_WRITE_ENABLED_CAP |\r
89 EFI_FVB_WRITE_STATUS |\r
90 EFI_FVB_ERASE_POLARITY,\r
91 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
92 0, // CheckSum\r
93 {\r
94 0,\r
95 }, // Reserved[3]\r
96 1, // Revision\r
97 {\r
98 SYSTEM_NV_BLOCK_NUM,\r
99 FVB_MEDIA_BLOCK_SIZE,\r
100 }\r
101 },\r
102 {\r
103 0,\r
104 0\r
105 }\r
106 }\r
107};\r
108\r
109EFI_STATUS\r
110GetFvbInfo (\r
111 IN UINT64 FvLength,\r
112 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo\r
113 )\r
114{\r
115 UINTN Index;\r
116\r
117 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {\r
118 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {\r
119 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;\r
120 return EFI_SUCCESS;\r
121 }\r
122 }\r
123\r
124 return EFI_NOT_FOUND;\r
125}\r