2 SMM Firmware Volume Block Driver.
4 Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/SmmServicesTableLib.h>
11 #include "FvbSmmCommon.h"
12 #include "FvbService.h"
15 The function installs EFI_SMM_FIRMWARE_VOLUME_BLOCK protocol
16 for each FV in the system.
18 @param[in] FwhInstance The pointer to a FW volume instance structure,
19 which contains the information about one FV.
20 @param[in] InstanceNum The instance number which can be used as a ID
21 to locate this FwhInstance in other functions.
23 @retval EFI_SUCESS Installed successfully.
24 @retval Else Did not install successfully.
29 IN EFI_FW_VOL_INSTANCE
*FwhInstance
,
33 EFI_FW_VOL_BLOCK_DEVICE
*FvbDevice
;
34 EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
;
37 FV_MEMMAP_DEVICE_PATH
*FvDevicePath
;
40 FvbDevice
= (EFI_FW_VOL_BLOCK_DEVICE
*) AllocateRuntimeCopyPool (
41 sizeof (EFI_FW_VOL_BLOCK_DEVICE
),
44 if (FvbDevice
== NULL
) {
45 return EFI_OUT_OF_RESOURCES
;
48 FvbDevice
->Instance
= InstanceNum
;
49 FwVolHeader
= &FwhInstance
->VolumeHeader
;
52 // Set up the devicepath
54 if (FwVolHeader
->ExtHeaderOffset
== 0) {
56 // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
58 TempPtr
= AllocateRuntimeCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH
), &mFvMemmapDevicePathTemplate
);
59 FvbDevice
->DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) TempPtr
;
60 if (FvbDevice
->DevicePath
== NULL
) {
62 return EFI_OUT_OF_RESOURCES
;
64 FvDevicePath
= (FV_MEMMAP_DEVICE_PATH
*) FvbDevice
->DevicePath
;
65 FvDevicePath
->MemMapDevPath
.StartingAddress
= FwhInstance
->FvBase
;
66 FvDevicePath
->MemMapDevPath
.EndingAddress
= FwhInstance
->FvBase
+ FwVolHeader
->FvLength
- 1;
68 TempPtr
= AllocateRuntimeCopyPool (sizeof (FV_PIWG_DEVICE_PATH
), &mFvPIWGDevicePathTemplate
);
69 FvbDevice
->DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) TempPtr
;
70 if (FvbDevice
->DevicePath
== NULL
) {
72 return EFI_OUT_OF_RESOURCES
;
76 &((FV_PIWG_DEVICE_PATH
*)FvbDevice
->DevicePath
)->FvDevPath
.FvName
,
77 (GUID
*)(UINTN
)(FwhInstance
->FvBase
+ FwVolHeader
->ExtHeaderOffset
)
82 // Install the SMM Firmware Volume Block Protocol and Device Path Protocol
85 Status
= gSmst
->SmmInstallProtocolInterface (
87 &gEfiSmmFirmwareVolumeBlockProtocolGuid
,
89 &FvbDevice
->FwVolBlockInstance
91 ASSERT_EFI_ERROR (Status
);
93 Status
= gSmst
->SmmInstallProtocolInterface (
95 &gEfiDevicePathProtocolGuid
,
99 ASSERT_EFI_ERROR (Status
);
102 // Notify the Fvb wrapper driver SMM fvb is ready
105 Status
= gBS
->InstallProtocolInterface (
107 &gEfiSmmFirmwareVolumeBlockProtocolGuid
,
108 EFI_NATIVE_INTERFACE
,
109 &FvbDevice
->FwVolBlockInstance
117 The driver entry point for SMM Firmware Volume Block Driver.
119 The function does the necessary initialization work
120 Firmware Volume Block Driver.
122 @param[in] ImageHandle The firmware allocated handle for the UEFI image.
123 @param[in] SystemTable A pointer to the EFI system table.
125 @retval EFI_SUCCESS This funtion always return EFI_SUCCESS.
126 It will ASSERT on errors.
132 IN EFI_HANDLE ImageHandle
,
133 IN EFI_SYSTEM_TABLE
*SystemTable