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