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