]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c
retire gEfiAlternateFvBlockGuid. All platform FvbRuntimeDxe drivers will not produce...
[mirror_edk2.git] / Nt32Pkg / FvbServicesRuntimeDxe / FvbInfo.c
1 /**@file
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 //
24 // The package level header files this module uses
25 //
26 #include <PiDxe.h>
27 #include <WinNtDxe.h>
28 //
29 // The protocols, PPI and GUID defintions for this module
30 //
31 #include <Guid/EventGroup.h>
32 #include <Guid/FirmwareFileSystem2.h>
33 #include <Guid/SystemNvDataGuid.h>
34 #include <Protocol/FirmwareVolumeBlock.h>
35 #include <Protocol/DevicePath.h>
36 //
37 // The Library classes this module consumes
38 //
39 #include <Library/UefiLib.h>
40 #include <Library/UefiDriverEntryPoint.h>
41 #include <Library/BaseLib.h>
42 #include <Library/DxeServicesTableLib.h>
43 #include <Library/UefiRuntimeLib.h>
44 #include <Library/DebugLib.h>
45 #include <Library/HobLib.h>
46 #include <Library/BaseMemoryLib.h>
47 #include <Library/MemoryAllocationLib.h>
48 #include <Library/UefiBootServicesTableLib.h>
49 #include <Library/PcdLib.h>
50
51 typedef struct {
52 UINT64 FvLength;
53 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
54 //
55 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
56 //
57 EFI_FV_BLOCK_MAP_ENTRY End[1];
58 } EFI_FVB_MEDIA_INFO;
59
60 EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
61 //
62 // Recovery BOIS FVB
63 //
64 {
65 FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),
66 {
67 {
68 0,
69 }, // ZeroVector[16]
70 EFI_FIRMWARE_FILE_SYSTEM2_GUID,
71 FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),
72 EFI_FVH_SIGNATURE,
73 EFI_FVB2_READ_ENABLED_CAP |
74 EFI_FVB2_READ_STATUS |
75 EFI_FVB2_WRITE_ENABLED_CAP |
76 EFI_FVB2_WRITE_STATUS |
77 EFI_FVB2_ERASE_POLARITY,
78 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
79 0, // CheckSum
80 0, // ExtHeaderOffset
81 {
82 0,
83 }, // Reserved[1]
84 1, // Revision
85 {
86 FixedPcdGet32 (PcdWinNtFlashFvRecoverySize)/FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
87 FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
88 }
89 },
90 {
91 0,
92 0
93 }
94 },
95 //
96 // Systen NvStorage FVB
97 //
98 {
99 FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
100 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
101 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
102 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),
103 {
104 {
105 0,
106 }, // ZeroVector[16]
107 EFI_SYSTEM_NV_DATA_FV_GUID,
108 FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
109 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
110 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
111 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),
112 EFI_FVH_SIGNATURE,
113 EFI_FVB2_READ_ENABLED_CAP |
114 EFI_FVB2_READ_STATUS |
115 EFI_FVB2_WRITE_ENABLED_CAP |
116 EFI_FVB2_WRITE_STATUS |
117 EFI_FVB2_ERASE_POLARITY,
118 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
119 0, // CheckSum
120 0, // ExtHeaderOffset
121 {
122 0,
123 }, // Reserved[1]
124 1, // Revision
125 {
126 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
127 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
128 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
129 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
130 FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
131 }
132 },
133 {
134 0,
135 0
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 }