2 SMM Firmware Volume Block Driver for Lakeport Platform.
4 Firmware volume block driver for FWH or SPI device.
5 It depends on which Flash Device Library to be linked with this driver.
7 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
16 #include <Library/SmmServicesTableLib.h>
17 #include "FvbSmmCommon.h"
18 #include "FvbService.h"
21 The function installs EFI_SMM_FIRMWARE_VOLUME_BLOCK protocol
22 for each FV in the system.
24 @param[in] FwhInstance The pointer to a FW volume instance structure,
25 which contains the information about one FV.
26 @param[in] InstanceNum The instance number which can be used as a ID
27 to locate this FwhInstance in other functions.
34 IN EFI_FW_VOL_INSTANCE
*FwhInstance
,
38 EFI_FW_VOL_BLOCK_DEVICE
*FvbDevice
;
39 EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
;
43 FvbDevice
= (EFI_FW_VOL_BLOCK_DEVICE
*) AllocateRuntimeCopyPool (
44 sizeof (EFI_FW_VOL_BLOCK_DEVICE
),
47 ASSERT (FvbDevice
!= NULL
);
49 FvbDevice
->Instance
= InstanceNum
;
50 FwVolHeader
= &FwhInstance
->VolumeHeader
;
53 // Set up the devicepath.
55 if (FwVolHeader
->ExtHeaderOffset
== 0) {
57 // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH.
59 FvbDevice
->DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocateRuntimeCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH
), &mFvMemmapDevicePathTemplate
);
60 ((FV_MEMMAP_DEVICE_PATH
*) FvbDevice
->DevicePath
)->MemMapDevPath
.StartingAddress
= FwhInstance
->FvBase
;
61 ((FV_MEMMAP_DEVICE_PATH
*) FvbDevice
->DevicePath
)->MemMapDevPath
.EndingAddress
= FwhInstance
->FvBase
+ FwVolHeader
->FvLength
- 1;
63 FvbDevice
->DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocateRuntimeCopyPool (sizeof (FV_PIWG_DEVICE_PATH
), &mFvPIWGDevicePathTemplate
);
65 &((FV_PIWG_DEVICE_PATH
*)FvbDevice
->DevicePath
)->FvDevPath
.FvName
,
66 (GUID
*)(UINTN
)(FwhInstance
->FvBase
+ FwVolHeader
->ExtHeaderOffset
)
71 // Install the SMM Firmware Volume Block Protocol and Device Path Protocol.
74 Status
= gSmst
->SmmInstallProtocolInterface (
76 &gEfiSmmFirmwareVolumeBlockProtocolGuid
,
78 &FvbDevice
->FwVolBlockInstance
80 ASSERT_EFI_ERROR (Status
);
82 Status
= gSmst
->SmmInstallProtocolInterface (
84 &gEfiDevicePathProtocolGuid
,
88 ASSERT_EFI_ERROR (Status
);
91 // Notify the Fvb wrapper driver SMM fvb is ready.
94 Status
= gBS
->InstallProtocolInterface (
96 &gEfiSmmFirmwareVolumeBlockProtocolGuid
,
98 &FvbDevice
->FwVolBlockInstance
104 The driver entry point for SMM Firmware Volume Block Driver.
106 The function does the necessary initialization work
107 Firmware Volume Block Driver.
109 @param[in] ImageHandle The firmware allocated handle for the UEFI image.
110 @param[in] SystemTable A pointer to the EFI system table.
112 @retval EFI_SUCCESS This funtion always return EFI_SUCCESS.
113 It will ASSERT on errors.
119 IN EFI_HANDLE ImageHandle
,
120 IN EFI_SYSTEM_TABLE
*SystemTable