TianoCore EDK2 master
Loading...
Searching...
No Matches
FvbServiceSmm.c
Go to the documentation of this file.
1
9#include <PiSmm.h>
11#include "FvbSmmCommon.h"
12#include "FvbService.h"
13
29 IN EFI_FW_VOL_INSTANCE *FwhInstance,
30 IN UINTN InstanceNum
31 )
32{
33 EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
34 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
35 EFI_STATUS Status;
36 EFI_HANDLE FvbHandle;
37 FV_MEMMAP_DEVICE_PATH *FvDevicePath;
38 VOID *TempPtr;
39
42 &mFvbDeviceTemplate
43 );
44 if (FvbDevice == NULL) {
45 return EFI_OUT_OF_RESOURCES;
46 }
47
48 FvbDevice->Instance = InstanceNum;
49 FwVolHeader = &FwhInstance->VolumeHeader;
50
51 //
52 // Set up the devicepath
53 //
54 if (FwVolHeader->ExtHeaderOffset == 0) {
55 //
56 // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
57 //
58 TempPtr = AllocateRuntimeCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate);
59 FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)TempPtr;
60 if (FvbDevice->DevicePath == NULL) {
61 ASSERT (FALSE);
62 return EFI_OUT_OF_RESOURCES;
63 }
64
65 FvDevicePath = (FV_MEMMAP_DEVICE_PATH *)FvbDevice->DevicePath;
66 FvDevicePath->MemMapDevPath.StartingAddress = FwhInstance->FvBase;
67 FvDevicePath->MemMapDevPath.EndingAddress = FwhInstance->FvBase + FwVolHeader->FvLength - 1;
68 } else {
69 TempPtr = AllocateRuntimeCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate);
70 FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)TempPtr;
71 if (FvbDevice->DevicePath == NULL) {
72 ASSERT (FALSE);
73 return EFI_OUT_OF_RESOURCES;
74 }
75
76 CopyGuid (
77 &((FV_PIWG_DEVICE_PATH *)FvbDevice->DevicePath)->FvDevPath.FvName,
78 (GUID *)(UINTN)(FwhInstance->FvBase + FwVolHeader->ExtHeaderOffset)
79 );
80 }
81
82 //
83 // Install the SMM Firmware Volume Block Protocol and Device Path Protocol
84 //
85 FvbHandle = NULL;
87 &FvbHandle,
88 &gEfiSmmFirmwareVolumeBlockProtocolGuid,
90 &FvbDevice->FwVolBlockInstance
91 );
92 ASSERT_EFI_ERROR (Status);
93
95 &FvbHandle,
96 &gEfiDevicePathProtocolGuid,
98 FvbDevice->DevicePath
99 );
100 ASSERT_EFI_ERROR (Status);
101
102 //
103 // Notify the Fvb wrapper driver SMM fvb is ready
104 //
105 FvbHandle = NULL;
106 Status = gBS->InstallProtocolInterface (
107 &FvbHandle,
108 &gEfiSmmFirmwareVolumeBlockProtocolGuid,
110 &FvbDevice->FwVolBlockInstance
111 );
112
113 return Status;
114}
115
130EFIAPI
132 IN EFI_HANDLE ImageHandle,
133 IN EFI_SYSTEM_TABLE *SystemTable
134 )
135{
136 FvbInitialize ();
137
138 return EFI_SUCCESS;
139}
UINT64 UINTN
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
VOID *EFIAPI AllocateRuntimeCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS InstallFvbProtocol(IN EFI_FW_VOL_INSTANCE *FwhInstance, IN UINTN InstanceNum)
Definition: FvbServiceSmm.c:28
EFI_STATUS EFIAPI FvbSmmInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define NULL
Definition: Base.h:319
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
EFI_SMM_SYSTEM_TABLE2 * gSmst
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
EFI_INSTALL_PROTOCOL_INTERFACE SmmInstallProtocolInterface
Definition: PiSmmCis.h:185
Definition: Base.h:213
EFI_PHYSICAL_ADDRESS StartingAddress
Definition: DevicePath.h:123
EFI_PHYSICAL_ADDRESS EndingAddress
Definition: DevicePath.h:127