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