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 This program and the accompanying materials are licensed and made available under
10 the terms and conditions of the BSD License that accompanies this distribution.
11 The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php.
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <Library/SmmServicesTableLib.h>
22 #include "FvbSmmCommon.h"
23 #include "FvbService.h"
26 The function installs EFI_SMM_FIRMWARE_VOLUME_BLOCK protocol
27 for each FV in the system.
29 @param[in] FwhInstance The pointer to a FW volume instance structure,
30 which contains the information about one FV.
31 @param[in] InstanceNum The instance number which can be used as a ID
32 to locate this FwhInstance in other functions.
39 IN EFI_FW_VOL_INSTANCE
*FwhInstance
,
43 EFI_FW_VOL_BLOCK_DEVICE
*FvbDevice
;
44 EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
;
48 FvbDevice
= (EFI_FW_VOL_BLOCK_DEVICE
*) AllocateRuntimeCopyPool (
49 sizeof (EFI_FW_VOL_BLOCK_DEVICE
),
52 ASSERT (FvbDevice
!= NULL
);
54 FvbDevice
->Instance
= InstanceNum
;
55 FwVolHeader
= &FwhInstance
->VolumeHeader
;
58 // Set up the devicepath.
60 if (FwVolHeader
->ExtHeaderOffset
== 0) {
62 // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH.
64 FvbDevice
->DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocateRuntimeCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH
), &mFvMemmapDevicePathTemplate
);
65 ((FV_MEMMAP_DEVICE_PATH
*) FvbDevice
->DevicePath
)->MemMapDevPath
.StartingAddress
= FwhInstance
->FvBase
;
66 ((FV_MEMMAP_DEVICE_PATH
*) FvbDevice
->DevicePath
)->MemMapDevPath
.EndingAddress
= FwhInstance
->FvBase
+ FwVolHeader
->FvLength
- 1;
68 FvbDevice
->DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocateRuntimeCopyPool (sizeof (FV_PIWG_DEVICE_PATH
), &mFvPIWGDevicePathTemplate
);
70 &((FV_PIWG_DEVICE_PATH
*)FvbDevice
->DevicePath
)->FvDevPath
.FvName
,
71 (GUID
*)(UINTN
)(FwhInstance
->FvBase
+ FwVolHeader
->ExtHeaderOffset
)
76 // Install the SMM Firmware Volume Block Protocol and Device Path Protocol.
79 Status
= gSmst
->SmmInstallProtocolInterface (
81 &gEfiSmmFirmwareVolumeBlockProtocolGuid
,
83 &FvbDevice
->FwVolBlockInstance
85 ASSERT_EFI_ERROR (Status
);
87 Status
= gSmst
->SmmInstallProtocolInterface (
89 &gEfiDevicePathProtocolGuid
,
93 ASSERT_EFI_ERROR (Status
);
96 // Notify the Fvb wrapper driver SMM fvb is ready.
99 Status
= gBS
->InstallProtocolInterface (
101 &gEfiSmmFirmwareVolumeBlockProtocolGuid
,
102 EFI_NATIVE_INTERFACE
,
103 &FvbDevice
->FwVolBlockInstance
109 The driver entry point for SMM Firmware Volume Block Driver.
111 The function does the necessary initialization work
112 Firmware Volume Block Driver.
114 @param[in] ImageHandle The firmware allocated handle for the UEFI image.
115 @param[in] SystemTable A pointer to the EFI system table.
117 @retval EFI_SUCCESS This funtion always return EFI_SUCCESS.
118 It will ASSERT on errors.
124 IN EFI_HANDLE ImageHandle
,
125 IN EFI_SYSTEM_TABLE
*SystemTable