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