2 Functions related to the Firmware Volume Block service whose
3 implementation is specific to the runtime DXE driver build.
5 Copyright (C) 2015, Red Hat, Inc.
6 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Guid/EventGroup.h>
18 #include <Library/DebugLib.h>
19 #include <Library/DevicePathLib.h>
20 #include <Library/PcdLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/UefiRuntimeLib.h>
23 #include <Protocol/DevicePath.h>
24 #include <Protocol/FirmwareVolumeBlock.h>
26 #include "FwBlockService.h"
27 #include "QemuFlash.h"
30 InstallProtocolInterfaces (
31 IN EFI_FW_VOL_BLOCK_DEVICE
*FvbDevice
36 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*OldFwbInterface
;
38 ASSERT (!FeaturePcdGet (PcdSmmSmramRequire
));
41 // Find a handle with a matching device path that has supports FW Block
44 Status
= gBS
->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid
,
45 &FvbDevice
->DevicePath
, &FwbHandle
);
46 if (EFI_ERROR (Status
)) {
48 // LocateDevicePath fails so install a new interface and device path
51 DEBUG ((EFI_D_INFO
, "Installing QEMU flash FVB\n"));
52 Status
= gBS
->InstallMultipleProtocolInterfaces (
54 &gEfiFirmwareVolumeBlockProtocolGuid
,
55 &FvbDevice
->FwVolBlockInstance
,
56 &gEfiDevicePathProtocolGuid
,
57 FvbDevice
->DevicePath
,
60 ASSERT_EFI_ERROR (Status
);
61 } else if (IsDevicePathEnd (FvbDevice
->DevicePath
)) {
63 // Device already exists, so reinstall the FVB protocol
65 Status
= gBS
->HandleProtocol (
67 &gEfiFirmwareVolumeBlockProtocolGuid
,
68 (VOID
**)&OldFwbInterface
70 ASSERT_EFI_ERROR (Status
);
72 DEBUG ((EFI_D_INFO
, "Reinstalling FVB for QEMU flash region\n"));
73 Status
= gBS
->ReinstallProtocolInterface (
75 &gEfiFirmwareVolumeBlockProtocolGuid
,
77 &FvbDevice
->FwVolBlockInstance
79 ASSERT_EFI_ERROR (Status
);
82 // There was a FVB protocol on an End Device Path node
92 FvbVirtualAddressChangeEvent (
100 Fixup internal data so that EFI and SAL can be call in virtual mode.
101 Call the passed in Child Notify event and convert the mFvbModuleGlobal
102 date items to there virtual address.
106 (Standard EFI notify event - EFI_EVENT_NOTIFY)
114 EFI_FW_VOL_INSTANCE
*FwhInstance
;
117 FwhInstance
= mFvbModuleGlobal
->FvInstance
;
118 EfiConvertPointer (0x0, (VOID
**) &mFvbModuleGlobal
->FvInstance
);
121 // Convert the base address of all the instances
124 while (Index
< mFvbModuleGlobal
->NumFv
) {
125 EfiConvertPointer (0x0, (VOID
**) &FwhInstance
->FvBase
);
126 FwhInstance
= (EFI_FW_VOL_INSTANCE
*)
128 (UINTN
) ((UINT8
*) FwhInstance
) +
129 FwhInstance
->VolumeHeader
.HeaderLength
+
130 (sizeof (EFI_FW_VOL_INSTANCE
) - sizeof (EFI_FIRMWARE_VOLUME_HEADER
))
135 EfiConvertPointer (0x0, (VOID
**) &mFvbModuleGlobal
);
136 QemuFlashConvertPointers ();
141 InstallVirtualAddressChangeHandler (
146 EFI_EVENT VirtualAddressChangeEvent
;
148 Status
= gBS
->CreateEventEx (
151 FvbVirtualAddressChangeEvent
,
153 &gEfiEventVirtualAddressChangeGuid
,
154 &VirtualAddressChangeEvent
156 ASSERT_EFI_ERROR (Status
);