]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/FvbServicesRuntimeDxe/FvbInfo.c
Add new DEBUG_VERBOSE print error level.
[mirror_edk2.git] / UnixPkg / FvbServicesRuntimeDxe / FvbInfo.c
1 /*++
2
3 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 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 #include "PiDxe.h"
23 #include <Guid/EventGroup.h>
24 #include <Protocol/FirmwareVolumeBlock.h>
25 #include <Protocol/DevicePath.h>
26
27 #include <Library/UefiLib.h>
28 #include <Library/UefiDriverEntryPoint.h>
29 #include <Library/BaseLib.h>
30 #include <Library/DxeServicesTableLib.h>
31 #include <Library/UefiRuntimeLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/HobLib.h>
34 #include <Library/BaseMemoryLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/PcdLib.h>
38 #include <Library/DevicePathLib.h>
39
40 #include <Guid/FirmwareFileSystem2.h>
41 #include <Guid/SystemNvDataGuid.h>
42
43 typedef struct {
44 UINT64 FvLength;
45 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
46 //
47 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
48 //
49 EFI_FV_BLOCK_MAP_ENTRY End[1];
50 } EFI_FVB_MEDIA_INFO;
51
52 EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
53 //
54 // Recovery BOIS FVB
55 //
56 {
57 FixedPcdGet32 (PcdUnixFlashFvRecoverySize),
58 {
59 {
60 0,
61 }, // ZeroVector[16]
62 EFI_FIRMWARE_FILE_SYSTEM2_GUID,
63 FixedPcdGet32 (PcdUnixFlashFvRecoverySize),
64 EFI_FVH_SIGNATURE,
65 EFI_FVB2_READ_ENABLED_CAP |
66 EFI_FVB2_READ_STATUS |
67 EFI_FVB2_WRITE_ENABLED_CAP |
68 EFI_FVB2_WRITE_STATUS |
69 EFI_FVB2_ERASE_POLARITY,
70 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
71 0, // CheckSum
72 0, // ExtHeaderOffset
73 {
74 0,
75 }, // Reserved[1]
76 2, // Revision
77 {
78 {
79 FixedPcdGet32 (PcdUnixFlashFvRecoverySize)/FixedPcdGet32 (PcdUnixFirmwareBlockSize),
80 FixedPcdGet32 (PcdUnixFirmwareBlockSize),
81 }
82 }
83 },
84 {
85 {
86 0,
87 0
88 }
89 }
90 },
91 //
92 // Systen NvStorage FVB
93 //
94 {
95 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
96 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
97 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
98 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),
99 {
100 {
101 0,
102 }, // ZeroVector[16]
103 EFI_SYSTEM_NV_DATA_FV_GUID,
104 FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
105 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
106 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
107 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),
108 EFI_FVH_SIGNATURE,
109 EFI_FVB2_READ_ENABLED_CAP |
110 EFI_FVB2_READ_STATUS |
111 EFI_FVB2_WRITE_ENABLED_CAP |
112 EFI_FVB2_WRITE_STATUS |
113 EFI_FVB2_ERASE_POLARITY,
114 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
115 0, // CheckSum
116 0, // ExtHeaderOffset
117 {
118 0,
119 }, // Reserved[1]
120 2, // Revision
121 {
122 {
123 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
124 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
125 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
126 FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdUnixFirmwareBlockSize),
127 FixedPcdGet32 (PcdUnixFirmwareBlockSize),
128 }
129 }
130 },
131 {
132 {
133 0,
134 0
135 }
136 }
137 }
138 };
139
140 EFI_STATUS
141 GetFvbInfo (
142 IN UINT64 FvLength,
143 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
144 )
145 {
146 UINTN Index;
147
148 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
149 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
150 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
151 return EFI_SUCCESS;
152 }
153 }
154
155 return EFI_NOT_FOUND;
156 }