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
;
65 FvDevicePath
= (FV_MEMMAP_DEVICE_PATH
*)FvbDevice
->DevicePath
;
66 FvDevicePath
->MemMapDevPath
.StartingAddress
= FwhInstance
->FvBase
;
67 FvDevicePath
->MemMapDevPath
.EndingAddress
= FwhInstance
->FvBase
+ FwVolHeader
->FvLength
- 1;
69 TempPtr
= AllocateRuntimeCopyPool (sizeof (FV_PIWG_DEVICE_PATH
), &mFvPIWGDevicePathTemplate
);
70 FvbDevice
->DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*)TempPtr
;
71 if (FvbDevice
->DevicePath
== NULL
) {
73 return EFI_OUT_OF_RESOURCES
;
77 &((FV_PIWG_DEVICE_PATH
*)FvbDevice
->DevicePath
)->FvDevPath
.FvName
,
78 (GUID
*)(UINTN
)(FwhInstance
->FvBase
+ FwVolHeader
->ExtHeaderOffset
)
83 // Install the SMM Firmware Volume Block Protocol and Device Path Protocol
86 Status
= gSmst
->SmmInstallProtocolInterface (
88 &gEfiSmmFirmwareVolumeBlockProtocolGuid
,
90 &FvbDevice
->FwVolBlockInstance
92 ASSERT_EFI_ERROR (Status
);
94 Status
= gSmst
->SmmInstallProtocolInterface (
96 &gEfiDevicePathProtocolGuid
,
100 ASSERT_EFI_ERROR (Status
);
103 // Notify the Fvb wrapper driver SMM fvb is ready
106 Status
= gBS
->InstallProtocolInterface (
108 &gEfiSmmFirmwareVolumeBlockProtocolGuid
,
109 EFI_NATIVE_INTERFACE
,
110 &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