OvmfPkg: QemuFlashFvbServicesRuntimeDxe: no dual addressing needed

Currently the EFI_FW_VOL_INSTANCE and ESAL_FWB_GLOBAL structures declare
the following entries as arrays, with two entries each:

- EFI_FW_VOL_INSTANCE.FvBase[2]
- ESAL_FWB_GLOBAL.FvInstance[2]

In every case, the entry at subscript zero is meant as "physical address",
while the entry at subscript one is meant as "virtual address" -- a
pointer to the same object. The virtual address entry is originally
initialized to the physical address, and then it is converted to the
virtual mapping in FvbVirtualddressChangeEvent().

Functions that (a) read the listed fields and (b) run both before and
after the virtual address change event -- since this is a runtime DXE
driver -- derive the correct array subscript by calling the
EfiGoneVirtual() function from UefiRuntimeLib.

The problem with the above infrastructure is that it's entirely
superfluous.

EfiGoneVirtual() "knows" whether EFI has gone virtual only because the
UefiRuntimeLib constructor registers the exact same kind of virtual
address change callback, and the callback flips a static variabe to TRUE,
and EfiGoneVirtual() queries that static variable.

In effect this means for QemuFlashFvbServicesRuntimeDxe: "when there is a
virtual address change, convert the entries with subscript one from
physical to virtual, and from then on use the entries with subscript one".

This would only make sense if QemuFlashFvbServicesRuntimeDxe ever needed
the original (physical) addresses (ie. the entries with subscript zero)
after the virtual address change, but that is not the case.

Replace the arrays with single elements. The subscript zero elements
simply disappear, and the single elements take the role of the prior
subscript one elements.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18670 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Laszlo Ersek
2015-10-26 14:58:33 +00:00
committed by lersek
parent f97a5b5e4c
commit 109301e5a1
2 changed files with 30 additions and 69 deletions

View File

@@ -23,21 +23,15 @@
#ifndef _FW_BLOCK_SERVICE_H
#define _FW_BLOCK_SERVICE_H
//
// BugBug: Add documentation here for data structure!!!!
//
#define FVB_PHYSICAL 0
#define FVB_VIRTUAL 1
typedef struct {
UINTN FvBase[2];
UINTN FvBase;
UINTN NumOfBlocks;
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
} EFI_FW_VOL_INSTANCE;
typedef struct {
UINT32 NumFv;
EFI_FW_VOL_INSTANCE *FvInstance[2];
EFI_FW_VOL_INSTANCE *FvInstance;
} ESAL_FWB_GLOBAL;
//
@@ -78,24 +72,21 @@ EFI_STATUS
FvbSetVolumeAttributes (
IN UINTN Instance,
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
IN ESAL_FWB_GLOBAL *Global
);
EFI_STATUS
FvbGetVolumeAttributes (
IN UINTN Instance,
OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
IN ESAL_FWB_GLOBAL *Global
);
EFI_STATUS
FvbGetPhysicalAddress (
IN UINTN Instance,
OUT EFI_PHYSICAL_ADDRESS *Address,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
IN ESAL_FWB_GLOBAL *Global
);
EFI_STATUS
@@ -120,8 +111,7 @@ FvbGetLbaAddress (
OUT UINTN *LbaAddress,
OUT UINTN *LbaLength,
OUT UINTN *NumOfBlocks,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
IN ESAL_FWB_GLOBAL *Global
);
//