audk/ArmVirtPkg/Library
Laszlo Ersek afa456de25 ArmVirtPkg/PlatformBootManagerLib: rebase boot order manipulation
QemuBootOrderLib can only filter out and reorder boot options; it cannot
create boot options. It relies on Platform BDS to auto-generate all
possible boot options first (for example, for new virtual devices that
have been configured since the last run of the virtual machine). Then it
will decide, case-by-case, whether each of those auto-generated boot
options should be preserved (and at what position), or removed.

Thus far, the only implementation of SetBootOrderFromQemu(), used in
connection with IntelFrameworkModulePkg BDS, has expected said complete
boot option list as an input parameter:

BdsEntry()                         [IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c]
  // create empty list
  InitializeListHead (
    &BootOptionList
    )

  PlatformBdsPolicyBehavior(       [ArmVirtPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c]
    BootOptionList
    )

    BdsLibConnectAll()
    BdsLibEnumerateAllBootOption(
      BootOptionList
      )

    // at this point, BootOptionList starts with the preexistent boot
    // options, and ends with the auto-generated options

    SetBootOrderFromQemu(          [OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c]
      BootOptionList
      )

      // write out changed boot order to UEFI variables

    // The "BootOrder" variable may have changed. Refresh BootOptionList
    // from it, and return it to BdsEntry().

With MdeModulePkg BDS, a BootOptionList is not propagated from BdsEntry()
to SetBootOrderFromQemu() and back. All processing is based directly on
the underlying "BootOrder" and "Boot####" variables.

In OvmfPkg, commit d27ec22d11 introduced a new instance of
QemuBootOrderLib, called QemuNewBootOrderLib. It is based on
UefiBootManagerLib, and rather than taking a complete BootOptionList as a
parameter, it expects that the "BootOrder" and "Boot####" variables are
complete in the above sense.

Rebase the boot order manipulation to UefiBootManagerLib and
QemuNewBootOrderLib, while keeping the requirement satisfied, like this:

BdsEntry()                               [MdeModulePkg/Universal/BdsDxe/BdsEntry.c]
  PlatformBootManagerAfterConsole()      [ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c]
    EfiBootManagerConnectAll()
    EfiBootManagerRefreshAllBootOption()

    // at this point all auto-generated options exist at the end of
    // "BootOrder"

    SetBootOrderFromQemu()               [OvmfPkg/Library/QemuNewBootOrderLib/QemuBootOrderLib.c]

      // read boot options from "BootOrder" and "Boot####", then
      // manipulate them

This patch parallels OvmfPkg commit 04fe914ba5.

Once the USE_OLD_BDS fallback is removed from OvmfPkg, the parameter list
of the SetBootOrderFromQemu() prototype can be updated to VOID.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Ruiyu Ni <ruiyu.ni@Intel.com>
2016-05-06 10:04:50 +02:00
..
ArmQemuRelocatablePlatformLib ArmVirtPkg/RelocatableVirtHelper: use correct FindMemNode argument order 2016-04-13 15:35:01 +02:00
ArmVirtDxeHobLib Renamed ArmPlatformPkg/ArmVirtualizationPkg into ArmVirtPkg 2015-05-29 13:50:43 +00:00
ArmVirtGicArchLib ArmVirtPkg/ArmGicArchLib: move to FdtClient protocol 2016-04-11 18:12:21 +02:00
ArmVirtMemoryInitPeiLib ArmVirtPkg/ArmVirtMemoryInitPeiLib: handle memory above 4 GB on 32-bit ARM 2015-09-09 14:48:33 +00:00
ArmVirtPL031FdtClientLib ArmVirtPkg: implement ArmVirtPL031FdtClientLib 2016-04-13 16:55:24 +02:00
ArmVirtPlatformLib ArmVirtPkg: ArmVirtPlatformLib: find the lowest memory node 2015-12-04 16:17:12 +00:00
ArmVirtPsciResetSystemLib ArmVirtPkg/ArmVirtPsciResetSystemLib: move to FDT client protocol 2016-04-11 18:12:21 +02:00
ArmVirtTimerFdtClientLib ArmVirtPkg: implement ArmVirtTimerFdtClientLib 2016-04-11 18:12:22 +02:00
ArmXenRelocatablePlatformLib ArmVirtPkg/RelocatableVirtHelper: use correct FindMemNode argument order 2016-04-13 15:35:01 +02:00
BaseCachingPciExpressLib ArmVirtPkg/BaseCachingPciExpressLib: depend on PciPcdProducerLib 2016-04-12 16:57:20 +02:00
FdtPL011SerialPortLib ArmVirtPkg/EarlyFdtPL011: allow patchable PCD for initial DT base address 2016-02-05 16:58:31 +01:00
FdtPciPcdProducerLib ArmVirtPkg: implement FdtPciPcdProducerLib 2016-04-12 16:26:46 +02:00
NorFlashQemuLib Renamed ArmPlatformPkg/ArmVirtualizationPkg into ArmVirtPkg 2015-05-29 13:50:43 +00:00
PlatformBootManagerLib ArmVirtPkg/PlatformBootManagerLib: rebase boot order manipulation 2016-05-06 10:04:50 +02:00
PlatformIntelBdsLib ArmVirtPkg: PlatformIntelBdsLib: signal gRootBridgesConnectedEventGroupGuid 2016-03-23 17:39:32 +01:00
PlatformPeiLib Renamed ArmPlatformPkg/ArmVirtualizationPkg into ArmVirtPkg 2015-05-29 13:50:43 +00:00
QemuFwCfgLib ArmVirtPkg/QemuFwCfgLib: move to FDT client protocol 2016-04-12 11:07:35 +02:00
XenRealTimeClockLib ArmVirtPkg: XenRealTimeClockLib: fixup typo in Linaro copyright notice 2015-06-08 22:00:32 +00:00