blob: fa737837ad71bb1c197da014bf45bd609895963e [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/**@file
2Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
3This program and the accompanying materials
4are licensed and made available under the terms and conditions of the BSD License
5which accompanies this distribution. The full text of the license may be found at
6http://opensource.org/licenses/bsd-license.php
7
8THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11Module Name:
12
13 FvbInfo.c
14
15Abstract:
16
17 Defines data structure that is the volume header found.These data is intent
18 to decouple FVB driver with FV header.
19
20**/
21#include "FileIo.h"
22#include "FlashLayout.h"
23
24typedef struct {
25 UINT64 FvLength;
26 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
27 EFI_FV_BLOCK_MAP_ENTRY End;
28} EFI_FVB_MEDIA_INFO;
29
30#define FVB_MEDIA_BLOCK_SIZE FIRMWARE_BLOCK_SIZE
31#define RECOVERY_BOIS_BLOCK_NUM FIRMWARE_BLOCK_NUMBER
32#define SYSTEM_NV_BLOCK_NUM 2
33
34EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
35 //
36 // Systen NvStorage FVB
37 //
38 {
39 NV_STORAGE_FVB_SIZE,
40 {
41 {
42 0,
43 }, // ZeroVector[16]
44 EFI_SYSTEM_NV_DATA_FV_GUID,
45 NV_STORAGE_FVB_SIZE,
46 EFI_FVH_SIGNATURE,
47 EFI_FVB2_READ_ENABLED_CAP |
48 EFI_FVB2_READ_STATUS |
49 EFI_FVB2_WRITE_ENABLED_CAP |
50 EFI_FVB2_WRITE_STATUS |
51 EFI_FVB2_ERASE_POLARITY,
52 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
53 0, // CheckSum
54 0, // ExtHeaderOffset
55 {
56 0,
57 }, // Reserved[1]
58 1, // Revision
59 {
60 NV_STORAGE_FVB_BLOCK_NUM,
61 FV_BLOCK_SIZE,
62 }
63 },
64 {
65 0,
66 0
67 }
68 },
69 //
70 // System FTW FVB
71 //
72 {
73 NV_FTW_FVB_SIZE,
74 {
75 {
76 0,
77 }, // ZeroVector[16]
78 EFI_SYSTEM_NV_DATA_FV_GUID,
79 NV_FTW_FVB_SIZE,
80 EFI_FVH_SIGNATURE,
81 EFI_FVB2_READ_ENABLED_CAP |
82 EFI_FVB2_READ_STATUS |
83 EFI_FVB2_WRITE_ENABLED_CAP |
84 EFI_FVB2_WRITE_STATUS |
85 EFI_FVB2_ERASE_POLARITY,
86 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
87 0, // CheckSum
88 0, // ExtHeaderOffset
89 {
90 0,
91 }, // Reserved[1]
92 1, // Revision
93 {
94 NV_FTW_FVB_BLOCK_NUM,
95 FV_BLOCK_SIZE,
96 }
97 },
98 {
99 0,
100 0
101 }
102 }
103};
104
105EFI_STATUS
106GetFvbInfo (
107 IN UINT64 FvLength,
108 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
109 )
110{
111 UINTN Index;
112
113 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
114 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
115 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
116 return EFI_SUCCESS;
117 }
118 }
119
120 return EFI_NOT_FOUND;
121}