Remove autogen.h from all dxs files, because autogen.h file has been included by...
[mirror_edk2.git] / EdkUnixPkg / RuntimeDxe / FvbServices / FvbInfo.c
CommitLineData
c9093a06 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
8ef571df 65 {\r
66 RECOVERY_BOIS_BLOCK_NUM,\r
67 FVB_MEDIA_BLOCK_SIZE\r
68 }\r
c9093a06 69 }\r
70 },\r
71 {\r
8ef571df 72 {\r
73 0,\r
74 0\r
75 }\r
c9093a06 76 }\r
77 },\r
78 //\r
79 // Systen NvStorage FVB\r
80 //\r
81 {\r
82 EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,\r
83 {\r
84 {\r
85 0,\r
86 }, // ZeroVector[16]\r
87 EFI_SYSTEM_NV_DATA_HOB_GUID,\r
88 FVB_MEDIA_BLOCK_SIZE * SYSTEM_NV_BLOCK_NUM,\r
89 EFI_FVH_SIGNATURE,\r
90 EFI_FVB_READ_ENABLED_CAP |\r
91 EFI_FVB_READ_STATUS |\r
92 EFI_FVB_WRITE_ENABLED_CAP |\r
93 EFI_FVB_WRITE_STATUS |\r
94 EFI_FVB_ERASE_POLARITY,\r
95 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
96 0, // CheckSum\r
97 {\r
98 0,\r
99 }, // Reserved[3]\r
100 1, // Revision\r
101 {\r
8ef571df 102 {\r
103 SYSTEM_NV_BLOCK_NUM,\r
104 FVB_MEDIA_BLOCK_SIZE\r
105 }\r
c9093a06 106 }\r
107 },\r
108 {\r
8ef571df 109 {\r
110 0,\r
111 0\r
112 }\r
c9093a06 113 }\r
114 }\r
115};\r
116\r
117EFI_STATUS\r
118GetFvbInfo (\r
119 IN UINT64 FvLength,\r
120 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo\r
121 )\r
122{\r
123 UINTN Index;\r
124\r
125 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {\r
126 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {\r
127 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;\r
128 return EFI_SUCCESS;\r
129 }\r
130 }\r
131\r
132 return EFI_NOT_FOUND;\r
133}\r