]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c
UefiCpuPkg: Remove double \r
[mirror_edk2.git] / Nt32Pkg / FvbServicesRuntimeDxe / FvbInfo.c
1 /**@file
2
3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 Module Name:
7
8 FvbInfo.c
9
10 Abstract:
11
12 Defines data structure that is the volume header found.These data is intent
13 to decouple FVB driver with FV header.
14
15 **/
16
17 //
18 // The package level header files this module uses
19 //
20 #include <PiDxe.h>
21 #include <WinNtDxe.h>
22 //
23 // The protocols, PPI and GUID defintions for this module
24 //
25 #include <Guid/EventGroup.h>
26 #include <Guid/FirmwareFileSystem2.h>
27 #include <Guid/SystemNvDataGuid.h>
28 #include <Protocol/FirmwareVolumeBlock.h>
29 #include <Protocol/DevicePath.h>
30 //
31 // The Library classes this module consumes
32 //
33 #include <Library/UefiLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/BaseLib.h>
36 #include <Library/DxeServicesTableLib.h>
37 #include <Library/UefiRuntimeLib.h>
38 #include <Library/DebugLib.h>
39 #include <Library/HobLib.h>
40 #include <Library/BaseMemoryLib.h>
41 #include <Library/MemoryAllocationLib.h>
42 #include <Library/UefiBootServicesTableLib.h>
43 #include <Library/PcdLib.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 (PcdWinNtFlashFvRecoverySize),
60 {
61 {
62 0,
63 }, // ZeroVector[16]
64 EFI_FIRMWARE_FILE_SYSTEM2_GUID,
65 FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),
66 EFI_FVH_SIGNATURE,
67 EFI_FVB2_MEMORY_MAPPED |
68 EFI_FVB2_READ_ENABLED_CAP |
69 EFI_FVB2_READ_STATUS |
70 EFI_FVB2_WRITE_ENABLED_CAP |
71 EFI_FVB2_WRITE_STATUS |
72 EFI_FVB2_ERASE_POLARITY |
73 EFI_FVB2_ALIGNMENT_16,
74 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
75 0xE947, // CheckSum
76 0, // ExtHeaderOffset
77 {
78 0,
79 }, // Reserved[1]
80 2, // Revision
81 {
82 FixedPcdGet32 (PcdWinNtFlashFvRecoverySize)/FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
83 FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
84 }
85 },
86 {
87 0,
88 0
89 }
90 },
91 //
92 // Systen NvStorage FVB
93 //
94 {
95 FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
96 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
97 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
98 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),
99 {
100 {
101 0,
102 }, // ZeroVector[16]
103 EFI_SYSTEM_NV_DATA_FV_GUID,
104 FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
105 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
106 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
107 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),
108 EFI_FVH_SIGNATURE,
109 EFI_FVB2_MEMORY_MAPPED |
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 EFI_FVB2_ALIGNMENT_16,
116 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
117 0xFBFF, // CheckSum
118 0, // ExtHeaderOffset
119 {
120 0,
121 }, // Reserved[1]
122 2, // Revision
123 {
124 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
125 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
126 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
127 FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
128 FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
129 }
130 },
131 {
132 0,
133 0
134 }
135 }
136 };
137
138 EFI_STATUS
139 GetFvbInfo (
140 IN UINT64 FvLength,
141 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
142 )
143 {
144 UINTN Index;
145
146 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
147 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
148 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
149 return EFI_SUCCESS;
150 }
151 }
152
153 return EFI_NOT_FOUND;
154 }