3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 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
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.
18 Defines data structure that is the volume header found.These data is intent
19 to decouple FVB driver with FV header.
24 // The package level header files this module uses
28 // The protocols, PPI and GUID defintions for this module
30 #include <Guid/EventGroup.h>
31 #include <Guid/FirmwareFileSystem2.h>
32 #include <Guid/SystemNvDataGuid.h>
33 #include <Protocol/FirmwareVolumeBlock.h>
34 #include <Protocol/DevicePath.h>
36 // The Library classes this module consumes
38 #include <Library/UefiLib.h>
39 #include <Library/UefiDriverEntryPoint.h>
40 #include <Library/BaseLib.h>
41 #include <Library/DxeServicesTableLib.h>
42 #include <Library/UefiRuntimeLib.h>
43 #include <Library/DebugLib.h>
44 #include <Library/HobLib.h>
45 #include <Library/BaseMemoryLib.h>
46 #include <Library/MemoryAllocationLib.h>
47 #include <Library/UefiBootServicesTableLib.h>
48 #include <Library/PcdLib.h>
52 EFI_FIRMWARE_VOLUME_HEADER FvbInfo
;
54 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
56 EFI_FV_BLOCK_MAP_ENTRY End
[1];
59 EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo
[] = {
61 // Systen NvStorage FVB
64 FixedPcdGet32 (PcdFlashNvStorageVariableSize
) +
65 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
66 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
67 FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize
),
72 EFI_SYSTEM_NV_DATA_FV_GUID
,
73 FixedPcdGet32 (PcdFlashNvStorageVariableSize
) +
74 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
75 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
76 FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize
),
78 EFI_FVB2_MEMORY_MAPPED
|
79 EFI_FVB2_READ_ENABLED_CAP
|
80 EFI_FVB2_READ_STATUS
|
81 EFI_FVB2_WRITE_ENABLED_CAP
|
82 EFI_FVB2_WRITE_STATUS
|
83 EFI_FVB2_ERASE_POLARITY
|
84 EFI_FVB2_ALIGNMENT_16
,
85 sizeof (EFI_FIRMWARE_VOLUME_HEADER
) + sizeof (EFI_FV_BLOCK_MAP_ENTRY
),
94 (FixedPcdGet32 (PcdFlashNvStorageVariableSize
) +
95 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
96 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
97 FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize
)) / FixedPcdGet32 (PcdOvmfFirmwareBlockSize
),
98 FixedPcdGet32 (PcdOvmfFirmwareBlockSize
),
114 OUT EFI_FIRMWARE_VOLUME_HEADER
**FvbInfo
117 STATIC BOOLEAN Checksummed
= FALSE
;
121 for (Index
= 0; Index
< sizeof (mPlatformFvbMediaInfo
) / sizeof (EFI_FVB_MEDIA_INFO
); Index
+= 1) {
123 mPlatformFvbMediaInfo
[Index
].FvbInfo
.Checksum
= 0;
124 Checksum
= CalculateCheckSum16 (
125 (UINT16
*) &mPlatformFvbMediaInfo
[Index
].FvbInfo
,
126 mPlatformFvbMediaInfo
[Index
].FvbInfo
.HeaderLength
128 mPlatformFvbMediaInfo
[Index
].FvbInfo
.Checksum
= Checksum
;
133 for (Index
= 0; Index
< sizeof (mPlatformFvbMediaInfo
) / sizeof (EFI_FVB_MEDIA_INFO
); Index
+= 1) {
134 if (mPlatformFvbMediaInfo
[Index
].FvLength
== FvLength
) {
135 *FvbInfo
= &mPlatformFvbMediaInfo
[Index
].FvbInfo
;
140 return EFI_NOT_FOUND
;