Fix wrong parameter usage in GenericBdsLibConstructor

Signed-off-by : Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by   : Ni Ruiyu   <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14826 6f19259b-4bc3-4df7-8a09-765794883524
Fix several bugs in DevicePathLib implementation regarding the device path node and text conversion.

Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14827 6f19259b-4bc3-4df7-8a09-765794883524
Update the logic, based on the device path and formset guid to find the HiiHandle.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14828 6f19259b-4bc3-4df7-8a09-765794883524
Not update the imageId for EXT1,2,4 type.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14829 6f19259b-4bc3-4df7-8a09-765794883524
Add BaseSmbusLibNull instance for SmbusLib. Add check in BootScriptExecutorDxe driver for the return status of S3BootScriptExecute().

Signed-off-by: Shumin Qiu <shumin.qiu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14830 6f19259b-4bc3-4df7-8a09-765794883524
Check in Fat release (EBC, IA32, X64, IPF) binaries built from MdePkg and BaseTools (r14830), FatPkg (r67).

Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14831 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: Increase DEBUG build size to 2MB by default

The 1MB image with full debug and the shell included is too
large to implement flash based non-volatile variable.

After this change, building with -D FD_SIZE_1MB will
force the smaller flash size.

The default size for RELEASE build remains at 1MB, so using
-b RELEASE on the build command line will result in a
1MB flash size. For RELEASE builds -D FD_SIZE_2MB can be
used to produce a 2MB flash image.

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

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg: Add NV Variable storage within FD

This is to prepare for QEMU flash support which will allow
non-volatile variables to be saved in the flash image.

Note two size changes:
 * NV Varstore size increased from 0xc000 to 0xe000
 * FTW work size decreased from 0x2000 to 0x1000

The reason for this change is that the fault-tolerant write
support requires that the work area fit within the block
just before the fault-tolerant write spare storage blocks.
Since QEMU flash blocks have a size of 0x1000, this means
that the maximum FTW work size is 0x1000.

v2:
 * Update commit message and PcdVariableStoreSize

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/README: Add information about OVMF flash layout

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/AcpiPlatformDxe/Qemu: Decrease upper limit for PCI window 32

In a later patch we will want to mark the flash memory as a
runtime services data memory range. This will allow a new runtime
services firmware block driver to read & write flash memory when
the OS has set up virtual memory protection.

Since this memory range will appear as runtime services data, we
need to adjust the limit when scanning for PCI window 32 down to
just below the flash device. If we don't adjust the limit, then
the algorithm in PopulateFwData will fail because it will see a
EfiGcdMemoryTypeSystemMemory memory range just below 4GB.

v2:
 * This patch replaces the v1 patch:
   "OvmfPkg/AcpiPlatformDxe/Qemu: Allow high runtime memory regions"

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/EmuVariableFvbRuntimeDxe: Disable if flash variables are supported

If QEMU flash is supported, then the PcdFlashNvStorageVariableBase64
will be set by the flash FVB driver. If it is set to a non-zero value,
then we disable memory based variables.

In future patches we will add the flash FVB driver and
force it to run before this driver. Therefore, if QEMU flash
writing is supported, then this driver will be disabled.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.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>
OvmfPkg: Add QemuFlashFvbServicesRuntimeDxe to firmware image

This driver will support a flash FVB implementation if QEMU flash
is detected.

The driver is added to the apriori list to make sure it runs
before the EmuVariableFvbRuntimeDxe driver. If this driver detects
flash support, then it will disable the EmuVariableFvbRuntimeDxe
driver by setting PcdFlashNvStorageVariableBase64.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/build.sh: Support --enable-flash switch

If this argument is used, then when QEMU is run, the -pflash
parameter will be used with QEMU to enable QEMU's flash
mode.

It should be used before the 'qemu' argument, since it is
not a QEMU parameter, but instead it updates how build.sh
runs QEMU.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/build.sh: Enable flash for QEMU >= 1.6

If the QEMU version is found to be >= 1.6, then automatically
enable flash (using the QEMU pflash command line parameter).

QEMU supports flash since 1.2, but only if KVM is disabled.
As of QEMU 1.6, flash support should also be enabled when
KVM is used. Therefore it is safest to only enable flash for
QEMU 1.6 and newer.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: 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>
OvmfPkg/BdsPlatform: don't restore NvVars from disk when flash is present

QemuFlashFvbServicesRuntimeDxe provides actual persistent storage for
non-volatile variables. When it is active, any on-disk NvVars file counts
as a stale source of variables -- hence don't load these files in BDS.

This also allows Secure Boot settings (eg. enrolled keys) to survive cold
VM reboots.

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