OvmfPkg/QemuVideoDxe: child handles should have open parent protocol BY_CHILD_CONTROLLER

The QemuVideoDxe driver creates child controller handles, so it is acting
as a hybrid bus driver. The child handles should open the parent's bus
protocol BY_CHILD_CONTROLLER to properly maintain the protocol usage count.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Ruffin <chris.ruffin@intel.com>
Reviewed-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@14987 6f19259b-4bc3-4df7-8a09-765794883524
MdeModulePkg CapsuleRuntimeDxe: Get PcdMaxSizeNonPopulateCapsule and PcdMaxSizePopulateCapsule by PcdGet32 in EntryPoint.

PcdMaxSizeNonPopulateCapsule and PcdMaxSizePopulateCapsule are declared to support Dynamic, but used by FixedPcdGet32 in CapsuleRuntimeDxe.
QueryCapsuleCapabilities is a runtime interface and PCD protocol can’t be used in runtime environment.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14988 6f19259b-4bc3-4df7-8a09-765794883524
Add a new line to initialize the variable “PassThruProtocol”  in ConsoleWrapers.c to ensure the initialization not to be a part of its declaration.

Signed-off-by: Shumin Qiu <shumin.qiu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14989 6f19259b-4bc3-4df7-8a09-765794883524
Update code to ensure the pointer ‘CurrentName’ in function ‘PerformSingleMappingDisplay’ isn’t null before being processed.

Signed-off-by: Shumin Qiu <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14990 6f19259b-4bc3-4df7-8a09-765794883524
Add the missing assignment of EFI_DISK_IO2_TOKEN::Token in FlushDiskEx() implementation. Without the assignment, system may hang sometimes.

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@14991 6f19259b-4bc3-4df7-8a09-765794883524
Get entire variable data for efi varstore at first time.

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@14992 6f19259b-4bc3-4df7-8a09-765794883524
Fix two issues in PeiCore. 
1. HOB address is not 8 byte alignment.
2. FV with the max supported PEIM can't be dispatched. 

Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14993 6f19259b-4bc3-4df7-8a09-765794883524
Fix a bug in TCP driver’s component name print function.
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Dong, Guo <guo.dong@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14994 6f19259b-4bc3-4df7-8a09-765794883524
Update code to support guid op nest in the statement.

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@14995 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: QemuFlashFvbServicesRuntimeDxe: fix out-of-LBA write access

When QemuFlashWrite() is asked to write a range that includes the last
byte of the LBA, then the byte that the function uses to switch the flash
device back to read mode (ROMD mode in KVM speak) actually falls out of
the LBA.

Normally this doesn't cause visible problems. However, if the variable
store and the firmware code are backed by separate flash devices, as
implemented by

  [Qemu-devel] [PATCH v2] hw/i386/pc_sysfw: support two flash drives
  http://thread.gmane.org/gmane.comp.emulators.qemu/243678

plus

  [edk2] [edk2 PATCH] OvmfPkg: split the variable store to a separate file
  http://thread.gmane.org/gmane.comp.bios.tianocore.devel/5045/focus=5046

then the READ_ARRAY_CMD not only reaches a different LBA, it reaches a
different qemu device. This results in a guest reboot soon after.

Fix this by ensuring that we always stay within the LBA just written when
issuing READ_ARRAY_CMD.

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@14996 6f19259b-4bc3-4df7-8a09-765794883524
ShellPkg: Fix "for" command statement initialization.

The shell was failing to correctly parse up to the space only for “run (1 3)” and also losing the space for “in ” a b” c” for loop initialization.  This fixes for initialization to be correct.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14997 6f19259b-4bc3-4df7-8a09-765794883524
ShellPkg: Add missing function header comments

I found that some function headers had insufficient/incorrect information.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14998 6f19259b-4bc3-4df7-8a09-765794883524
Update code to avoid using potential NULL pointer.

Signed-off-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14999 6f19259b-4bc3-4df7-8a09-765794883524
Rollback the change to EFI_BOOT_KEY_DATA structure since UEFI Spec adds the clarification that bitfields are ordered such that bit 0 is the least significant bit.

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

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15000 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: IndustryStandard/VirtioBlk: add extra horizontal whitespace

We're going to introduce a new macro and a new VIRTIO_BLK_CONFIG member
that need realignment of existing definitions and comments. Separate out
the whitespace changes in this patch.

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@15001 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: IndustryStandard/VirtioBlk: introduce topology-related definitions

Based on
<https://tools.oasis-open.org/version-control/browse/wsvn/virtio/virtio-v1.0-wd01-part1-specification.txt?rev=159>,
which is the last text format revision.

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@15002 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg/VirtioBlkDxe/VirtioBlk.c: rewrap overlong lines

Lines should be no longer than 79 characters.

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@15003 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: VirtioBlkInit(): expose virtio-blk topology in BlockIo

UEFI spec                                virtio spec
=======================================  =================================
LowestAlignedLba EFI_LBA (UINT64)        alignment_offset u8
+--------------------------------------  +--------------------------------
| first LBA that is aligned to a         | offset of first aligned
| physical block boundary (SCSI          | logical block
| definition)

LogicalBlocksPerPhysicalBlock UINT32     physical_block_exp u8
+--------------------------------------  +--------------------------------
| number of logical blocks per           | # of logical blocks per
| physical block [...] does not contain  | physical block (log2)
| an exponential value

OptimalTransferLengthGranularity UINT32  opt_io_size le32
+--------------------------------------  +--------------------------------
| optimal transfer length granularity    | optimal (suggested maximum) I/O
| as a number of logical blocks [...] A  | size in blocks
| value of 0 means there is no reported
| optimal transfer length granularity

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@15004 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: VirtioBlkInit(): log topology attributes

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@15005 6f19259b-4bc3-4df7-8a09-765794883524
Converse the return value from 'int' to 'BOOLEAN' for function ‘ContainsSplit’ in Shell.c.

Signed-off-by: Shumin Qiu <shumin.qiu@intel.com>
Reviewed-by: Ni, Ruiyu <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15006 6f19259b-4bc3-4df7-8a09-765794883524