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/UefiBootServicesTableLib.h>
21 #include <Library/UefiRuntimeLib.h>
22 #include <Protocol/DevicePath.h>
23 #include <Protocol/FirmwareVolumeBlock.h>
25 #include "FwBlockService.h"
26 #include "QemuFlash.h"
29 InstallProtocolInterfaces (
30 IN EFI_FW_VOL_BLOCK_DEVICE
*FvbDevice
35 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*OldFwbInterface
;
38 // Find a handle with a matching device path that has supports FW Block
41 Status
= gBS
->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid
,
42 &FvbDevice
->DevicePath
, &FwbHandle
);
43 if (EFI_ERROR (Status
)) {
45 // LocateDevicePath fails so install a new interface and device path
48 DEBUG ((EFI_D_INFO
, "Installing QEMU flash FVB\n"));
49 Status
= gBS
->InstallMultipleProtocolInterfaces (
51 &gEfiFirmwareVolumeBlockProtocolGuid
,
52 &FvbDevice
->FwVolBlockInstance
,
53 &gEfiDevicePathProtocolGuid
,
54 FvbDevice
->DevicePath
,
57 ASSERT_EFI_ERROR (Status
);
58 } else if (IsDevicePathEnd (FvbDevice
->DevicePath
)) {
60 // Device already exists, so reinstall the FVB protocol
62 Status
= gBS
->HandleProtocol (
64 &gEfiFirmwareVolumeBlockProtocolGuid
,
65 (VOID
**)&OldFwbInterface
67 ASSERT_EFI_ERROR (Status
);
69 DEBUG ((EFI_D_INFO
, "Reinstalling FVB for QEMU flash region\n"));
70 Status
= gBS
->ReinstallProtocolInterface (
72 &gEfiFirmwareVolumeBlockProtocolGuid
,
74 &FvbDevice
->FwVolBlockInstance
76 ASSERT_EFI_ERROR (Status
);
79 // There was a FVB protocol on an End Device Path node
89 FvbVirtualAddressChangeEvent (
97 Fixup internal data so that EFI and SAL can be call in virtual mode.
98 Call the passed in Child Notify event and convert the mFvbModuleGlobal
99 date items to there virtual address.
103 (Standard EFI notify event - EFI_EVENT_NOTIFY)
111 EFI_FW_VOL_INSTANCE
*FwhInstance
;
114 FwhInstance
= mFvbModuleGlobal
->FvInstance
;
115 EfiConvertPointer (0x0, (VOID
**) &mFvbModuleGlobal
->FvInstance
);
118 // Convert the base address of all the instances
121 while (Index
< mFvbModuleGlobal
->NumFv
) {
122 EfiConvertPointer (0x0, (VOID
**) &FwhInstance
->FvBase
);
123 FwhInstance
= (EFI_FW_VOL_INSTANCE
*)
125 (UINTN
) ((UINT8
*) FwhInstance
) +
126 FwhInstance
->VolumeHeader
.HeaderLength
+
127 (sizeof (EFI_FW_VOL_INSTANCE
) - sizeof (EFI_FIRMWARE_VOLUME_HEADER
))
132 EfiConvertPointer (0x0, (VOID
**) &mFvbModuleGlobal
);
133 QemuFlashConvertPointers ();
138 InstallVirtualAddressChangeHandler (
143 EFI_EVENT VirtualAddressChangeEvent
;
145 Status
= gBS
->CreateEventEx (
148 FvbVirtualAddressChangeEvent
,
150 &gEfiEventVirtualAddressChangeGuid
,
151 &VirtualAddressChangeEvent
153 ASSERT_EFI_ERROR (Status
);