History log of /device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
0f2eb31c764685a1919b52f414bea44ea37580a2 26-Oct-2015 Laszlo Ersek <lersek@redhat.com> OvmfPkg: QemuFlashFvbServicesRuntimeDxe: clean up includes and libraries

Before introducing the SMM driver interface, clean up #include directives
and [LibraryClasses] by:
- removing what's not directly used (HobLib and UefiLib),
- adding what's used but not spelled out (DevicePathLib),
- sorting the result.

This helps with seeing each source file's dependencies and with
determining the library classes for the SMM driver.

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@18672 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
1767877a31b3ce191ddae6cb9aefba99a733fe20 26-Oct-2015 Laszlo Ersek <lersek@redhat.com> OvmfPkg: QemuFlashFvbServicesRuntimeDxe: split out runtime DXE specifics

In preparation for introducing an SMM interface to this driver, move the
following traits to separate files, so that we can replace them in the new
SMM INF file:

- Protocol installations. The SMM driver will install protocol interfaces
in the SMM protocol database, using SMM services.

- Virtual address change handler and pointer conversions. SMM drivers run
with physical mappings and pointers must not be converted.

There are further restrictions and changes for an SMM driver, but the rest
of the code either complies with those already, or will handle the changes
transparently. For example:

- SMM drivers have access to both UEFI and SMM protocols in their entry
points (see the PI spec 1.4, "1.7 SMM Driver Initialization"),

- MemoryAllocationLib has an SMM instance that serves allocation requests
with the gSmst->SmmAllocatePool() service transparently, allocating
runtime-marked SMRAM.

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@18671 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
109301e5a14ec4bfd0ce93e15439e30d7ccd8b0a 26-Oct-2015 Laszlo Ersek <lersek@redhat.com> 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
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
f97a5b5e4cab1f01f92a0899cc95b92c5a9f3ed3 26-Oct-2015 Laszlo Ersek <lersek@redhat.com> OvmfPkg: QemuFlashFvbServicesRuntimeDxe: remove FvbScratchSpace field

The ESAL_FWB_GLOBAL.FvbScratchSpace array is never initialized (it
contains garbage from AllocateRuntimePool()). Its element at subscript one
(=FVB_VIRTUAL), containing garbage as well, is converted to virtual
mapping. Then the array is never used again.

Remove it.

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@18669 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
a05aff56554f4ff74629d13db92260d504f8cb5b 26-Oct-2015 Laszlo Ersek <lersek@redhat.com> OvmfPkg: QemuFlashFvbServicesRuntimeDxe: remove FvbDevLock field

The EFI_FW_VOL_INSTANCE.FvbDevLock member is initialized and then never
used. Remove it.

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@18668 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
ea0d111efe756dcc53d355bc25d17d9a925c6007 26-Oct-2015 Laszlo Ersek <lersek@redhat.com> OvmfPkg: QemuFlashFvbServicesRuntimeDxe: rewrap source code to 79 chars

Some of the line lengths in this driver are atrocious. While we have to
put up with the status quo outside of OvmfPkg, we can at least rewrap this
driver before refactoring it.

In the FvbInitialize() function there's no way around introducing two
local variables, just for the sake of sensibly rewrapping the code.

Furthermore, in "FwBlockService.c" the function comment blocks are now
indented; their original position causes diff to print bogus function
names at the top of hunks.

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@18666 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
141f0c644512e4da3bad7a0382fe82aa8c460762 26-Oct-2015 Laszlo Ersek <lersek@redhat.com> OvmfPkg: QemuFlashFvbServicesRuntimeDxe: strip trailing whitespace

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@18665 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
1c5901528147af6f2d095a7b7d4bb73e19eeb365 14-Nov-2014 Laszlo Ersek <lersek@redhat.com> OvmfPg: flash driver: drop gratuitous 64-by-32 bit divisions (VS2010)

In the InitializeVariableFvHeader() function, all three of "Offset",
"Start" and "BlockSize" have type UINTN. Therefore the (Offset /
BlockSize) and (Start / BlockSize) divisions can be compiled on all
platforms without intrinsics.

In the current expressions

(EFI_LBA) Offset / BlockSize
(EFI_LBA) Start / BlockSize

"Offset" and "Start" are cast to UINT64 (== EFI_LBA), which leads to
64-by-32 bit divisions on Ia32, breaking the VS2010 / NOOPT / Ia32 build.
The simplest way to fix them is to realize we don't need casts at all.
(The prototypes of QemuFlashEraseBlock() and QemuFlashWrite() are visible
via "QemuFlash.h", and they will easily take our UINTN quotients as
UINT64.)

Suggested-by: Scott Duplichan <scott@notabs.org>

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Build-tested-by: Scott Duplichan <scott@notabs.org>

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16383 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
1e62c89c3ae0da2eeabb37c5ab299b928ebbbb30 14-Nov-2014 Laszlo Ersek <lersek@redhat.com> OvmfPg: flash driver: fix type of EFI_SIZE_TO_PAGES argument (VS2010)

The MarkMemoryRangeForRuntimeAccess() function passes the Length parameter
(of type UINT64) to the macro EFI_SIZE_TO_PAGES(). When building for the
Ia32 platform, this violates the interface contract of the macro:

[...] Passing in a parameter that is larger than UINTN may produce
unexpected results.

In addition, it trips up compilation by VS2010 for the Ia32 platform and
the NOOPT target -- it generates calls to intrinsics, which are not
allowed in edk2.

Fix both issues with the following steps:

(1) Demote the Length parameter of MarkMemoryRangeForRuntimeAccess() to
UINTN. Even a UINT32 value is plenty for representing the size of the
flash chip holding the variable store. Length parameter is used in the
following contexts:
- passed to gDS->RemoveMemorySpace() -- takes an UINT64
- passed to gDS->AddMemorySpace() -- ditto
- passed to EFI_SIZE_TO_PAGES() -- requires an UINTN. This also guarantees
that the return type of EFI_SIZE_TO_PAGES() will be UINTN, hence we can
drop the outer cast.

(2) The only caller of MarkMemoryRangeForRuntimeAccess() is
FvbInitialize(). The latter function populates the local Length variable
(passed to MarkMemoryRangeForRuntimeAccess()) from
PcdGet32(PcdOvmfFirmwareFdSize). Therefore we can simply demote the local
variable to UINTN in this function as well.
- There's only one other use of Length in FvbInitialize(): it is passed to
GetFvbInfo(). GetFvbInfo() takes an UINT64, so passing an UINTN is fine.

Suggested-by: Scott Duplichan <scott@notabs.org>

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Build-tested-by: Scott Duplichan <scott@notabs.org>

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16382 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
c404616199df383226df1b70940008c01cfaec81 25-Sep-2014 Jordan Justen <jordan.l.justen@intel.com> OvmfPkg: Fix VS2005 build warnings

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16171 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
8c01a99b8472f231e746c7eb9bade0ddddf2b445 27-Jun-2014 Gao, Liming <liming.gao@intel.com> OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Fix GCC44 build failure.

Initialize the input parameter FwhInstance in function GetFvbInstance().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Gao, Liming" <liming.gao@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15601 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
9d35ac2611aecc7c6c28597e69cff18e20e40a05 12-Nov-2013 Laszlo Ersek <lersek@redhat.com> OvmfPkg: indicate enablement of flash variables with a dedicated PCD

PcdFlashNvStorageVariableBase64 is used to arbitrate between
QemuFlashFvbServicesRuntimeDxe and EmuVariableFvbRuntimeDxe, but even the
latter driver sets it if we fall back to it.

Allow code running later than the startup of these drivers to know about
the availability of flash variables, through a dedicated PCD.

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@14843 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
a4ce9ffd470dbbab07ad1a9caeab5049b5a4bb6a 12-Nov-2013 Jordan Justen <jordan.l.justen@intel.com> OvmfPkg: Add QemuFlashFvbServicesRuntimeDxe driver

If QEMU flash is detected, this module will install
FirmwareVolumeBlock support for the QEMU flash device.

It will also set PCDs with the results that:
1. OvmfPkg/EmuVariableFvbRuntimeDxe will be disabled
2. MdeModulePkg variable services will read/write flash directly

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

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14839 6f19259b-4bc3-4df7-8a09-765794883524
/device/linaro/bootloader/edk2/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c