]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c
Clean Nt32 FVB driver doesn't produce the undefined FVB extension protocol.
[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 <Guid/AlternateFvBlock.h>
36 #include <Protocol/DevicePath.h>
37 //
38 // The Library classes this module consumes
39 //
40 #include <Library/UefiLib.h>
41 #include <Library/UefiDriverEntryPoint.h>
42 #include <Library/BaseLib.h>
43 #include <Library/DxeServicesTableLib.h>
44 #include <Library/UefiRuntimeLib.h>
45 #include <Library/DebugLib.h>
46 #include <Library/HobLib.h>
47 #include <Library/BaseMemoryLib.h>
48 #include <Library/MemoryAllocationLib.h>
49 #include <Library/UefiBootServicesTableLib.h>
50 #include <Library/PcdLib.h>
51
52 typedef struct {
53 UINT64 FvLength;
54 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
55 //
56 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
57 //
58 EFI_FV_BLOCK_MAP_ENTRY End[1];
59 } EFI_FVB_MEDIA_INFO;
60
61 EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
62 //
63 // Recovery BOIS FVB
64 //
65 {
66 FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),
67 {
68 {
69 0,
70 }, // ZeroVector[16]
71 EFI_FIRMWARE_FILE_SYSTEM2_GUID,
72 FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),
73 EFI_FVH_SIGNATURE,
74 EFI_FVB2_READ_ENABLED_CAP |
75 EFI_FVB2_READ_STATUS |
76 EFI_FVB2_WRITE_ENABLED_CAP |
77 EFI_FVB2_WRITE_STATUS |
78 EFI_FVB2_ERASE_POLARITY,
79 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
80 0, // CheckSum
81 0, // ExtHeaderOffset
82 {
83 0,
84 }, // Reserved[1]
85 1, // Revision
86 {
87 FixedPcdGet32 (PcdWinNtFlashFvRecoverySize)/FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
88 FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
89 }
90 },
91 {
92 0,
93 0
94 }
95 },
96 //
97 // Systen NvStorage FVB
98 //
99 {
100 FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
101 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
102 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
103 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),
104 {
105 {
106 0,
107 }, // ZeroVector[16]
108 EFI_SYSTEM_NV_DATA_FV_GUID,
109 FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
110 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
111 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
112 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),
113 EFI_FVH_SIGNATURE,
114 EFI_FVB2_READ_ENABLED_CAP |
115 EFI_FVB2_READ_STATUS |
116 EFI_FVB2_WRITE_ENABLED_CAP |
117 EFI_FVB2_WRITE_STATUS |
118 EFI_FVB2_ERASE_POLARITY,
119 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
120 0, // CheckSum
121 0, // ExtHeaderOffset
122 {
123 0,
124 }, // Reserved[1]
125 1, // Revision
126 {
127 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
128 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
129 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
130 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
131 FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
132 }
133 },
134 {
135 0,
136 0
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 }