\r
**/\r
\r
-//\r
-// The package level header files this module uses\r
-//\r
-#include <PiDxe.h>\r
-\r
//\r
// The protocols, PPI and GUID defintions for this module\r
//\r
-#include <Guid/EventGroup.h>\r
#include <Protocol/FirmwareVolumeBlock.h>\r
#include <Protocol/DevicePath.h>\r
\r
//\r
// The Library classes this module consumes\r
//\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
#include <Library/BaseLib.h>\r
#include <Library/DxeServicesTableLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
};\r
\r
\r
-\r
-VOID\r
-EFIAPI\r
-FvbVirtualddressChangeEvent (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-/*++\r
-\r
- Routine Description:\r
-\r
- Fixup internal data so that EFI and SAL can be call in virtual mode.\r
- Call the passed in Child Notify event and convert the mFvbModuleGlobal\r
- date items to there virtual address.\r
-\r
- Arguments:\r
-\r
- (Standard EFI notify event - EFI_EVENT_NOTIFY)\r
-\r
- Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- EFI_FW_VOL_INSTANCE *FwhInstance;\r
- UINTN Index;\r
-\r
- FwhInstance = mFvbModuleGlobal->FvInstance;\r
- EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance);\r
-\r
- //\r
- // Convert the base address of all the instances\r
- //\r
- Index = 0;\r
- while (Index < mFvbModuleGlobal->NumFv) {\r
- EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase);\r
- FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
- (\r
- (UINTN) ((UINT8 *) FwhInstance) +\r
- FwhInstance->VolumeHeader.HeaderLength +\r
- (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
- );\r
- Index++;\r
- }\r
-\r
- EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);\r
- QemuFlashConvertPointers ();\r
-}\r
-\r
EFI_STATUS\r
GetFvbInstance (\r
IN UINTN Instance,\r
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
UINT32 BufferSize;\r
EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;\r
- EFI_HANDLE FwbHandle;\r
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface;\r
UINT32 MaxLbaSize;\r
EFI_PHYSICAL_ADDRESS BaseAddress;\r
UINTN Length;\r
UINTN NumOfBlocks;\r
- EFI_EVENT VirtualAddressChangeEvent;\r
\r
if (EFI_ERROR (QemuFlashInitialize ())) {\r
//\r
}\r
\r
//\r
- // Find a handle with a matching device path that has supports FW Block\r
- // protocol\r
+ // Module type specific hook.\r
//\r
- Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid,\r
- &FvbDevice->DevicePath, &FwbHandle);\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // LocateDevicePath fails so install a new interface and device path\r
- //\r
- FwbHandle = NULL;\r
- DEBUG ((EFI_D_INFO, "Installing QEMU flash FVB\n"));\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &FwbHandle,\r
- &gEfiFirmwareVolumeBlockProtocolGuid,\r
- &FvbDevice->FwVolBlockInstance,\r
- &gEfiDevicePathProtocolGuid,\r
- FvbDevice->DevicePath,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- } else if (IsDevicePathEnd (FvbDevice->DevicePath)) {\r
- //\r
- // Device already exists, so reinstall the FVB protocol\r
- //\r
- Status = gBS->HandleProtocol (\r
- FwbHandle,\r
- &gEfiFirmwareVolumeBlockProtocolGuid,\r
- (VOID**)&OldFwbInterface\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- DEBUG ((EFI_D_INFO, "Reinstalling FVB for QEMU flash region\n"));\r
- Status = gBS->ReinstallProtocolInterface (\r
- FwbHandle,\r
- &gEfiFirmwareVolumeBlockProtocolGuid,\r
- OldFwbInterface,\r
- &FvbDevice->FwVolBlockInstance\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- } else {\r
- //\r
- // There was a FVB protocol on an End Device Path node\r
- //\r
- ASSERT (FALSE);\r
- }\r
+ InstallProtocolInterfaces (FvbDevice);\r
\r
MarkMemoryRangeForRuntimeAccess (BaseAddress, Length);\r
\r
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
);\r
\r
- VirtualAddressChangeEvent = NULL;\r
- Status = gBS->CreateEventEx (\r
- EVT_NOTIFY_SIGNAL,\r
- TPL_NOTIFY,\r
- FvbVirtualddressChangeEvent,\r
- NULL,\r
- &gEfiEventVirtualAddressChangeGuid,\r
- &VirtualAddressChangeEvent\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
+ //\r
+ // Module type specific hook.\r
+ //\r
+ InstallVirtualAddressChangeHandler ();\r
\r
PcdSetBool (PcdOvmfFlashVariablesEnable, TRUE);\r
return EFI_SUCCESS;\r