]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmulatorPkg: Use MdeModulePkg/Bds module
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 30 Aug 2018 01:53:49 +0000 (09:53 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Fri, 31 Aug 2018 02:40:18 +0000 (10:40 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1120

Logo is enabled by adding a separate core driver LogoDxe.
UiApp and BootManagerMenuApp are added to provide two UIs.

LoadFileOnFv2 is added to auto-install LoadFile protocol for
applications in FV so the boot options for applications can be
auto-created from LoadFile.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Cc: Andrew Fish <afish@apple.com>
EmulatorPkg/EmulatorPkg.dsc
EmulatorPkg/EmulatorPkg.fdf
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c [deleted file]
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h [deleted file]
EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf [deleted file]
EmulatorPkg/Library/EmuBdsLib/PlatformData.c [deleted file]
EmulatorPkg/Library/PlatformBmLib/PlatformBm.c [new file with mode: 0644]
EmulatorPkg/Library/PlatformBmLib/PlatformBm.h [new file with mode: 0644]
EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c [new file with mode: 0644]
EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf [new file with mode: 0644]
EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c [new file with mode: 0644]

index 72e8aa1788c3bced81c6bf313d0fb71e81afe9a1..78e9a3f1cc88dfd03346994061faa648973f868e 100644 (file)
@@ -79,7 +79,9 @@
   UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf\r
   DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r
   OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
-  GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
+  BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf\r
+  FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf\r
+  UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
   BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf\r
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf\r
   CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
@@ -90,7 +92,7 @@
   #\r
   # Platform\r
   #\r
-  PlatformBdsLib|EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf\r
+  PlatformBootManagerLib|EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf\r
   KeyMapLib|EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf\r
 \r
   #\r
   AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf\r
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf\r
   SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf\r
-  UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
 \r
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
   TimerLib|EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf\r
 \r
-[LibraryClasses.common.UEFI_DRIVER]\r
-  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
-\r
-[LibraryClasses.common.UEFI_APPLICATION]\r
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-\r
-\r
 [PcdsFeatureFlag]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE\r
 \r
   gEmulatorPkgTokenSpaceGuid.PcdEmuMemorySize|L"64!64"\r
 \r
+  # Change PcdBootManagerMenuFile to UiApp\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }\r
+\r
 !ifndef $(USE_OLD_SHELL)\r
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }\r
 !endif\r
 [PcdsDynamicHii.common.DEFAULT]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Setup"|gEmuSystemConfigGuid|0x0|80\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Setup"|gEmuSystemConfigGuid|0x4|25\r
-\r
+  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|10\r
 \r
 [Components]\r
 !ifdef $(UNIX_SEC_BUILD)\r
   }\r
 \r
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
-  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+  MdeModulePkg/Logo/LogoDxe.inf\r
+  MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf\r
+  MdeModulePkg/Application/UiApp/UiApp.inf {\r
+   <LibraryClasses>\r
+      NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf\r
+      NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf\r
+      NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf\r
+  }\r
+  MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf\r
+\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
   #{\r
   #  <LibraryClasses>\r
index 314eb7b895a74a4d238002ba3688c174f10ab944..5b5f81443dff29c92b5952cf8a5711159c6f5a94 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This is Emulator FDF file with UEFI HII features enabled\r
 #\r
-# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2009 - 2011, Apple Inc. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials\r
@@ -183,9 +183,12 @@ INF  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
 INF  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
 INF  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
 INF  MdeModulePkg/Universal/PrintDxe/PrintDxe.inf\r
-INF  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+INF  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+INF  MdeModulePkg/Logo/LogoDxe.inf\r
+INF  MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf\r
+INF  RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf\r
+INF  MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf\r
 INF  MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf\r
-INF  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
 \r
 #\r
 # Network stack drivers\r
@@ -212,11 +215,6 @@ INF  ShellPkg/Application/Shell/Shell.inf
 INF  RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf\r
 !endif\r
 \r
-FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {\r
-  SECTION RAW = MdeModulePkg/Logo/Logo.bmp\r
-}\r
-\r
-\r
 [Rule.Common.SEC]\r
   FILE SEC = $(NAMED_GUID)  {\r
     PE32     PE32    Align=Auto     $(INF_OUTPUT)/$(MODULE_NAME).efi\r
@@ -296,6 +294,13 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
     }\r
   }\r
 \r
+[Rule.Common.UEFI_APPLICATION.UI]\r
+  FILE APPLICATION = $(NAMED_GUID) {\r
+    PE32      PE32                     $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+    UI        STRING="Enter Setup"\r
+    VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+  }\r
+\r
 [Rule.Common.UEFI_DRIVER.BINARY]\r
   FILE DRIVER = $(NAMED_GUID) {\r
     DXE_DEPEX DXE_DEPEX Optional      |.depex\r
diff --git a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c b/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c
deleted file mode 100644 (file)
index 75fba84..0000000
+++ /dev/null
@@ -1,559 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "BdsPlatform.h"\r
-\r
-EMU_SYSTEM_CONFIGURATION mSystemConfigData;\r
-\r
-VOID\r
-SetupVariableInit (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  UINTN                           Size;\r
-\r
-  Size = sizeof (mSystemConfigData);\r
-  Status = gRT->GetVariable (\r
-                  L"Setup",\r
-                  &gEmuSystemConfigGuid,\r
-                  NULL,\r
-                  &Size,\r
-                  (VOID *) &mSystemConfigData\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // SetupVariable is corrupt\r
-    //\r
-    mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);\r
-    mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);\r
-\r
-    Status = gRT->SetVariable (\r
-                    L"Setup",\r
-                    &gEmuSystemConfigGuid,\r
-                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                    sizeof (mSystemConfigData),\r
-                    (VOID *) &mSystemConfigData\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
-    }\r
-  }\r
-}\r
-\r
-//\r
-// BDS Platform Functions\r
-//\r
-VOID\r
-EFIAPI\r
-PlatformBdsInit (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Platform Bds init. Include the platform firmware vendor, revision\r
-  and so crc check.\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
-**/\r
-{\r
-  SetupVariableInit ();\r
-\r
-  EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r
-}\r
-\r
-EFI_STATUS\r
-PlatformBdsConnectConsole (\r
-  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Connect the predefined platform default console device. Always try to find\r
-  and enable the vga device if have.\r
-\r
-Arguments:\r
-\r
-  PlatformConsole         - Predefined platform default console device array.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             - Success connect at least one ConIn and ConOut\r
-                            device, there must have one ConOut device is\r
-                            active vga device.\r
-\r
-  EFI_STATUS              - Return the status of\r
-                            BdsLibConnectAllDefaultConsoles ()\r
-\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       Index;\r
-\r
-  Index   = 0;\r
-  Status  = EFI_SUCCESS;\r
-\r
-  //\r
-  // Have chance to connect the platform default console,\r
-  // the platform default console is the minimum device group\r
-  // the platform should support\r
-  //\r
-  while (PlatformConsole[Index].DevicePath != NULL) {\r
-    //\r
-    // Update the console variable with the connect type\r
-    //\r
-    if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
-      BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
-    }\r
-\r
-    if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
-      BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
-    }\r
-\r
-    if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
-      BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
-    }\r
-\r
-    Index++;\r
-  }\r
-  //\r
-  // Connect the all the default console with current cosole variable\r
-  //\r
-  Status = BdsLibConnectAllDefaultConsoles ();\r
-  return Status;\r
-}\r
-\r
-VOID\r
-PlatformBdsConnectSequence (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Connect with predefined platform connect sequence,\r
-  the OEM/IBV can customize with their own connect sequence.\r
-\r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
-**/\r
-{\r
-  UINTN Index;\r
-\r
-  Index = 0;\r
-\r
-  //\r
-  // Here we can get the customized platform connect sequence\r
-  // Notes: we can connect with new variable which record the\r
-  // last time boots connect device path sequence\r
-  //\r
-  while (gPlatformConnectSequence[Index] != NULL) {\r
-    //\r
-    // Build the platform boot option\r
-    //\r
-    BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
-    Index++;\r
-  }\r
-\r
-  //\r
-  // Just use the simple policy to connect all devices\r
-  //\r
-  BdsLibConnectAll ();\r
-}\r
-\r
-VOID\r
-PlatformBdsGetDriverOption (\r
-  IN OUT LIST_ENTRY              *BdsDriverLists\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Load the predefined driver option, OEM/IBV can customize this\r
-  to load their own drivers\r
-\r
-Arguments:\r
-\r
-  BdsDriverLists  - The header of the driver option link list.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
-**/\r
-{\r
-  UINTN Index;\r
-\r
-  Index = 0;\r
-\r
-  //\r
-  // Here we can get the customized platform driver option\r
-  //\r
-  while (gPlatformDriverOption[Index] != NULL) {\r
-    //\r
-    // Build the platform boot option\r
-    //\r
-    BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
-    Index++;\r
-  }\r
-\r
-}\r
-\r
-VOID\r
-PlatformBdsDiagnostics (\r
-  IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,\r
-  IN BOOLEAN                     QuietBoot,\r
-  IN BASEM_MEMORY_TEST           BaseMemoryTest\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Perform the platform diagnostic, such like test memory. OEM/IBV also\r
-  can customize this fuction to support specific platform diagnostic.\r
-\r
-Arguments:\r
-\r
-  MemoryTestLevel  - The memory test intensive level\r
-\r
-  QuietBoot        - Indicate if need to enable the quiet boot\r
-\r
-  BaseMemoryTest   - A pointer to BdsMemoryTest()\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Here we can decide if we need to show\r
-  // the diagnostics screen\r
-  // Notes: this quiet boot code should be remove\r
-  // from the graphic lib\r
-  //\r
-  if (QuietBoot) {\r
-    EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
-    //\r
-    // Perform system diagnostic\r
-    //\r
-    Status = BaseMemoryTest (MemoryTestLevel);\r
-    if (EFI_ERROR (Status)) {\r
-      DisableQuietBoot ();\r
-    }\r
-\r
-    return ;\r
-  }\r
-  //\r
-  // Perform system diagnostic\r
-  //\r
-  Status = BaseMemoryTest (MemoryTestLevel);\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsPolicyBehavior (\r
-  IN OUT LIST_ENTRY                  *DriverOptionList,\r
-  IN OUT LIST_ENTRY                  *BootOptionList,\r
-  IN PROCESS_CAPSULES                ProcessCapsules,\r
-  IN BASEM_MEMORY_TEST               BaseMemoryTest\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The function will execute with as the platform policy, current policy\r
-  is driven by boot mode. IBV/OEM can customize this code for their specific\r
-  policy action.\r
-\r
-Arguments:\r
-\r
-  DriverOptionList - The header of the driver option link list\r
-\r
-  BootOptionList   - The header of the boot option link list\r
-\r
-  ProcessCapsules  - A pointer to ProcessCapsules()\r
-\r
-  BaseMemoryTest   - A pointer to BaseMemoryTest()\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
-**/\r
-{\r
-  EFI_STATUS     Status;\r
-  UINT16         Timeout;\r
-  EFI_BOOT_MODE  BootMode;\r
-\r
-  //\r
-  // Init the time out value\r
-  //\r
-  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
-\r
-  //\r
-  // Load the driver option as the driver option list\r
-  //\r
-  PlatformBdsGetDriverOption (DriverOptionList);\r
-\r
-  //\r
-  // Get current Boot Mode\r
-  //\r
-  Status = BdsLibGetBootMode (&BootMode);\r
-\r
-  //\r
-  // Go the different platform policy with different boot mode\r
-  // Notes: this part code can be change with the table policy\r
-  //\r
-  switch (BootMode) {\r
-\r
-  case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
-  case BOOT_WITH_MINIMAL_CONFIGURATION:\r
-    //\r
-    // In no-configuration boot mode, we can connect the\r
-    // console directly.\r
-    //\r
-    BdsLibConnectAllDefaultConsoles ();\r
-    PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
-\r
-    //\r
-    // Perform some platform specific connect sequence\r
-    //\r
-    PlatformBdsConnectSequence ();\r
-\r
-    //\r
-    // Notes: current time out = 0 can not enter the\r
-    // front page\r
-    //\r
-    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-\r
-    //\r
-    // Check the boot option with the boot option list\r
-    //\r
-    BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
-    break;\r
-\r
-  case BOOT_ON_FLASH_UPDATE:\r
-    //\r
-    // Boot with the specific configuration\r
-    //\r
-    PlatformBdsConnectConsole (gPlatformConsole);\r
-    PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
-    BdsLibConnectAll ();\r
-    ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
-    break;\r
-\r
-  case BOOT_IN_RECOVERY_MODE:\r
-    //\r
-    // In recovery mode, just connect platform console\r
-    // and show up the front page\r
-    //\r
-    PlatformBdsConnectConsole (gPlatformConsole);\r
-    PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
-\r
-    //\r
-    // In recovery boot mode, we still enter to the\r
-    // frong page now\r
-    //\r
-    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-    break;\r
-\r
-  case BOOT_WITH_FULL_CONFIGURATION:\r
-  case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
-  case BOOT_WITH_DEFAULT_SETTINGS:\r
-  default:\r
-    //\r
-    // Connect platform console\r
-    //\r
-    Status = PlatformBdsConnectConsole (gPlatformConsole);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Here OEM/IBV can customize with defined action\r
-      //\r
-      PlatformBdsNoConsoleAction ();\r
-    }\r
-\r
-    PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
-\r
-    //\r
-    // Perform some platform specific connect sequence\r
-    //\r
-    PlatformBdsConnectSequence ();\r
-\r
-    //\r
-    // Give one chance to enter the setup if we\r
-    // have the time out\r
-    //\r
-    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-\r
-    //\r
-    // Here we have enough time to do the enumeration of boot device\r
-    //\r
-    BdsLibEnumerateAllBootOption (BootOptionList);\r
-    break;\r
-  }\r
-\r
-  return ;\r
-\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootSuccess (\r
-  IN  BDS_COMMON_OPTION   *Option\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Hook point after a boot attempt succeeds. We don't expect a boot option to\r
-  return, so the EFI 1.0 specification defines that you will default to an\r
-  interactive mode and stop processing the BootOrder list in this case. This\r
-  is alos a platform implementation and can be customized by IBV/OEM.\r
-\r
-Arguments:\r
-\r
-  Option - Pointer to Boot Option that succeeded to boot.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
-**/\r
-{\r
-  CHAR16  *TmpStr;\r
-\r
-  //\r
-  // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
-  // select loop then we need to pop up a UI and wait for user input.\r
-  //\r
-  TmpStr = Option->StatusString;\r
-  if (TmpStr != NULL) {\r
-    BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
-    FreePool (TmpStr);\r
-  }\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootFail (\r
-  IN  BDS_COMMON_OPTION  *Option,\r
-  IN  EFI_STATUS         Status,\r
-  IN  CHAR16             *ExitData,\r
-  IN  UINTN              ExitDataSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Hook point after a boot attempt fails.\r
-\r
-Arguments:\r
-\r
-  Option - Pointer to Boot Option that failed to boot.\r
-\r
-  Status - Status returned from failed boot.\r
-\r
-  ExitData - Exit data returned from failed boot.\r
-\r
-  ExitDataSize - Exit data size returned from failed boot.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
-**/\r
-{\r
-  CHAR16  *TmpStr;\r
-\r
-  //\r
-  // If Boot returned with failed status then we need to pop up a UI and wait\r
-  // for user input.\r
-  //\r
-  TmpStr = Option->StatusString;\r
-  if (TmpStr != NULL) {\r
-    BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
-    FreePool (TmpStr);\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-PlatformBdsNoConsoleAction (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function is remained for IBV/OEM to do some platform action,\r
-  if there no console device can be connected.\r
-\r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS      - Direct return success now.\r
-\r
-**/\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsLockNonUpdatableFlash (\r
-  VOID\r
-  )\r
-{\r
-  return;\r
-}\r
-\r
-/**\r
-  Lock the ConsoleIn device in system table. All key\r
-  presses will be ignored until the Password is typed in. The only way to\r
-  disable the password is to type it in to a ConIn device.\r
-\r
-  @param  Password        Password used to lock ConIn device.\r
-\r
-  @retval EFI_SUCCESS     lock the Console In Spliter virtual handle successfully.\r
-  @retval EFI_UNSUPPORTED Password not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LockKeyboards (\r
-  IN  CHAR16    *Password\r
-  )\r
-{\r
-    return EFI_UNSUPPORTED;\r
-}\r
diff --git a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h b/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h
deleted file mode 100644 (file)
index 5ececd4..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _BDS_PLATFORM_H\r
-#define _BDS_PLATFORM_H\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Guid/EmuSystemConfig.h>\r
-#include <Guid/EventGroup.h>\r
-#include <Protocol/EmuThunk.h>\r
-#include <Protocol/EmuIoThunk.h>\r
-#include <Protocol/EmuGraphicsWindow.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/GenericBdsLib.h>\r
-#include <Library/PlatformBdsLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/UefiLib.h>\r
-\r
-\r
-extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];\r
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];\r
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformDriverOption[];\r
-\r
-#define gEndEntire \\r
-  { \\r
-    END_DEVICE_PATH_TYPE,\\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\\r
-    { \\r
-      END_DEVICE_PATH_LENGTH,\\r
-      0\\r
-    }\\r
-  }\r
-\r
-\r
-typedef struct {\r
-  EMU_VENDOR_DEVICE_PATH_NODE     EmuBus;\r
-  EMU_VENDOR_DEVICE_PATH_NODE     EmuGraphicsWindow;\r
-  EFI_DEVICE_PATH_PROTOCOL        End;\r
-} EMU_PLATFORM_UGA_DEVICE_PATH;\r
-\r
-\r
-//\r
-// Platform BDS Functions\r
-//\r
-VOID\r
-PlatformBdsGetDriverOption (\r
-  IN LIST_ENTRY               *BdsDriverLists\r
-  );\r
-\r
-EFI_STATUS\r
-BdsMemoryTest (\r
-  EXTENDMEM_COVERAGE_LEVEL Level\r
-  );\r
-\r
-\r
-VOID\r
-PlatformBdsConnectSequence (\r
-  VOID\r
-  );\r
-\r
-EFI_STATUS\r
-ProcessCapsules (\r
-  EFI_BOOT_MODE BootMode\r
-  );\r
-\r
-EFI_STATUS\r
-PlatformBdsConnectConsole (\r
-  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
-  );\r
-\r
-EFI_STATUS\r
-PlatformBdsNoConsoleAction (\r
-  VOID\r
-  );\r
-\r
-VOID\r
-PlatformBdsEnterFrontPage (\r
-  IN UINT16                 TimeoutDefault,\r
-  IN BOOLEAN                ConnectAllHappened\r
-  );\r
-\r
-#endif // _BDS_PLATFORM_H\r
diff --git a/EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf b/EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf
deleted file mode 100644 (file)
index 755c50c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-## @file\r
-# Platfrom BDS driver\r
-#\r
-# Do platform action customized by IBV/OEM.\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuBdsLib\r
-  FILE_GUID                      =  59569181-CBF8-2E44-9C3E-C2AB2F5608E1\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PlatformBdsLib|DXE_DRIVER\r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  BdsPlatform.c\r
-  PlatformData.c\r
-  BdsPlatform.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  EmulatorPkg/EmulatorPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-  UefiRuntimeServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  PcdLib\r
-  GenericBdsLib\r
-  DevicePathLib\r
-  UefiLib\r
-\r
-[Guids]\r
-  gEmuSystemConfigGuid\r
-  gEfiEndOfDxeEventGroupGuid\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn\r
-  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile\r
-\r
-[Depex]\r
-  gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid\r
diff --git a/EmulatorPkg/Library/EmuBdsLib/PlatformData.c b/EmulatorPkg/Library/EmuBdsLib/PlatformData.c
deleted file mode 100644 (file)
index 3eb959b..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "BdsPlatform.h"\r
-\r
-\r
-\r
-EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {\r
-  {\r
-    {\r
-      {\r
-        HARDWARE_DEVICE_PATH,\r
-        HW_VENDOR_DP,\r
-        {\r
-          (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
-          (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
-        }\r
-      },\r
-      EMU_THUNK_PROTOCOL_GUID\r
-    },\r
-    0\r
-  },\r
-  {\r
-    {\r
-      {\r
-        HARDWARE_DEVICE_PATH,\r
-        HW_VENDOR_DP,\r
-        {\r
-          (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
-          (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
-        },\r
-      },\r
-      EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,\r
-    },\r
-    0\r
-  },\r
-  gEndEntire\r
-};\r
-\r
-//\r
-// Predefined platform default console device path\r
-//\r
-BDS_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {\r
-  {\r
-    (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,\r
-    (CONSOLE_OUT | CONSOLE_IN)\r
-  },\r
-  {\r
-    NULL,\r
-    0\r
-  }\r
-};\r
-\r
-//\r
-// Predefined platform specific driver option\r
-//\r
-EFI_DEVICE_PATH_PROTOCOL    *gPlatformDriverOption[] = { NULL };\r
-\r
-//\r
-// Predefined platform connect sequence\r
-//\r
-EFI_DEVICE_PATH_PROTOCOL    *gPlatformConnectSequence[] = { NULL };\r
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
new file mode 100644 (file)
index 0000000..4e3297c
--- /dev/null
@@ -0,0 +1,435 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "PlatformBm.h"\r
+\r
+EFI_GUID mBootMenuFile = {\r
+  0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }\r
+};\r
+\r
+/**\r
+  Initialize the "Setup" variable.\r
+**/\r
+VOID\r
+SetupVariableInit (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  UINTN                           Size;\r
+  EMU_SYSTEM_CONFIGURATION        SystemConfigData;\r
+\r
+  Size = sizeof (SystemConfigData);\r
+  Status = gRT->GetVariable (\r
+                  L"Setup",\r
+                  &gEmuSystemConfigGuid,\r
+                  NULL,\r
+                  &Size,\r
+                  (VOID *) &SystemConfigData\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // SetupVariable is corrupt\r
+    //\r
+    SystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);\r
+    SystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);\r
+\r
+    Status = gRT->SetVariable (\r
+                    L"Setup",\r
+                    &gEmuSystemConfigGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                    sizeof (SystemConfigData),\r
+                    (VOID *) &SystemConfigData\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((DEBUG_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
+    }\r
+  }\r
+}\r
+\r
+EFI_DEVICE_PATH *\r
+FvFilePath (\r
+  EFI_GUID                     *FileGuid\r
+  )\r
+{\r
+\r
+  EFI_STATUS                         Status;\r
+  EFI_LOADED_IMAGE_PROTOCOL          *LoadedImage;\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;\r
+\r
+  EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  gImageHandle,\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID **) &LoadedImage\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  return AppendDevicePathNode (\r
+           DevicePathFromHandle (LoadedImage->DeviceHandle),\r
+           (EFI_DEVICE_PATH_PROTOCOL *) &FileNode\r
+           );\r
+}\r
+\r
+/**\r
+  Create one boot option for BootManagerMenuApp.\r
+\r
+  @param  FileGuid          Input file guid for the BootManagerMenuApp.\r
+  @param  Description       Description of the BootManagerMenuApp boot option.\r
+  @param  Position          Position of the new load option to put in the ****Order variable.\r
+  @param  IsBootCategory    Whether this is a boot category.\r
+\r
+\r
+  @retval OptionNumber      Return the option number info.\r
+\r
+**/\r
+UINTN\r
+RegisterBootManagerMenuAppBootOption (\r
+  EFI_GUID                         *FileGuid,\r
+  CHAR16                           *Description,\r
+  UINTN                            Position,\r
+  BOOLEAN                          IsBootCategory\r
+  )\r
+{\r
+  EFI_STATUS                       Status;\r
+  EFI_BOOT_MANAGER_LOAD_OPTION     NewOption;\r
+  EFI_DEVICE_PATH_PROTOCOL         *DevicePath;\r
+  UINTN                            OptionNumber;\r
+\r
+  DevicePath = FvFilePath (FileGuid);\r
+  Status = EfiBootManagerInitializeLoadOption (\r
+             &NewOption,\r
+             LoadOptionNumberUnassigned,\r
+             LoadOptionTypeBoot,\r
+             IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,\r
+             Description,\r
+             DevicePath,\r
+             NULL,\r
+             0\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+  FreePool (DevicePath);\r
+\r
+  Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  OptionNumber = NewOption.OptionNumber;\r
+\r
+  EfiBootManagerFreeLoadOption (&NewOption);\r
+\r
+  return OptionNumber;\r
+}\r
+\r
+/**\r
+  Check if it's a Device Path pointing to BootManagerMenuApp.\r
+\r
+  @param  DevicePath     Input device path.\r
+\r
+  @retval TRUE   The device path is BootManagerMenuApp File Device Path.\r
+  @retval FALSE  The device path is NOT BootManagerMenuApp File Device Path.\r
+**/\r
+BOOLEAN\r
+IsBootManagerMenuAppFilePath (\r
+  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
+)\r
+{\r
+  EFI_HANDLE                      FvHandle;\r
+  VOID                            *NameGuid;\r
+  EFI_STATUS                      Status;\r
+\r
+  Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);\r
+  if (!EFI_ERROR (Status)) {\r
+    NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);\r
+    if (NameGuid != NULL) {\r
+      return CompareGuid (NameGuid, &mBootMenuFile);\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Return the boot option number to the BootManagerMenuApp.\r
+\r
+  If not found it in the current boot option, create a new one.\r
+\r
+  @retval OptionNumber   Return the boot option number to the BootManagerMenuApp.\r
+\r
+**/\r
+UINTN\r
+GetBootManagerMenuAppOption (\r
+  VOID\r
+  )\r
+{\r
+  UINTN                        BootOptionCount;\r
+  EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;\r
+  UINTN                        Index;\r
+  UINTN                        OptionNumber;\r
+\r
+  OptionNumber = 0;\r
+\r
+  BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
+\r
+  for (Index = 0; Index < BootOptionCount; Index++) {\r
+    if (IsBootManagerMenuAppFilePath (BootOptions[Index].FilePath)) {\r
+      OptionNumber = BootOptions[Index].OptionNumber;\r
+      break;\r
+    }\r
+  }\r
+\r
+  EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);\r
+\r
+  if (Index >= BootOptionCount) {\r
+    //\r
+    // If not found the BootManagerMenuApp, create it.\r
+    //\r
+    OptionNumber = (UINT16) RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN) -1, FALSE);\r
+  }\r
+\r
+  return OptionNumber;\r
+}\r
+\r
+/**\r
+  Platform Bds init. Include the platform firmware vendor, revision\r
+  and so crc check.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerBeforeConsole (\r
+  VOID\r
+  )\r
+{\r
+  UINTN       Index;\r
+\r
+  SetupVariableInit ();\r
+\r
+  EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r
+\r
+  Index   = 0;\r
+  while (gPlatformConsole[Index].DevicePath != NULL) {\r
+    //\r
+    // Update the console variable with the connect type\r
+    //\r
+    if ((gPlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
+      EfiBootManagerUpdateConsoleVariable (ConIn, gPlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    if ((gPlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
+      EfiBootManagerUpdateConsoleVariable (ConOut, gPlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    if ((gPlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
+      EfiBootManagerUpdateConsoleVariable (ErrOut, gPlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    Index++;\r
+  }\r
+}\r
+\r
+/**\r
+  Connect with predefined platform connect sequence,\r
+  the OEM/IBV can customize with their own connect sequence.\r
+**/\r
+VOID\r
+PlatformBdsConnectSequence (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Just use the simple policy to connect all devices\r
+  //\r
+  EfiBootManagerConnectAll ();\r
+}\r
+\r
+/**\r
+  Perform the platform diagnostic, such like test memory. OEM/IBV also\r
+  can customize this fuction to support specific platform diagnostic.\r
+\r
+  @param MemoryTestLevel The memory test intensive level\r
+  @param QuietBoot       Indicate if need to enable the quiet boot\r
+**/\r
+VOID\r
+PlatformBdsDiagnostics (\r
+  IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,\r
+  IN BOOLEAN                     QuietBoot\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Here we can decide if we need to show\r
+  // the diagnostics screen\r
+  //\r
+  if (QuietBoot) {\r
+    BootLogoEnableLogo ();\r
+\r
+    //\r
+    // Perform system diagnostic\r
+    //\r
+    Status = PlatformBootManagerMemoryTest (MemoryTestLevel);\r
+    if (EFI_ERROR (Status)) {\r
+      BootLogoDisableLogo ();\r
+    }\r
+\r
+    return;\r
+  }\r
+\r
+  //\r
+  // Perform system diagnostic\r
+  //\r
+  PlatformBootManagerMemoryTest (MemoryTestLevel);\r
+}\r
+\r
+/**\r
+  Register the static boot options.\r
+**/\r
+VOID\r
+PlatformBdsRegisterStaticBootOptions (\r
+  VOID\r
+  )\r
+{\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Black;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  White;\r
+  EFI_INPUT_KEY                  Enter;\r
+  EFI_INPUT_KEY                  F2;\r
+  EFI_INPUT_KEY                  F7;\r
+  EFI_BOOT_MANAGER_LOAD_OPTION   BootOption;\r
+  UINTN                          OptionNumber;\r
+\r
+  Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;\r
+  White.Blue = White.Green = White.Red = White.Reserved = 0xFF;\r
+\r
+  //\r
+  // Register ENTER as CONTINUE key\r
+  //\r
+  Enter.ScanCode    = SCAN_NULL;\r
+  Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;\r
+  EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);\r
+  //\r
+  // Map F2 to Boot Manager Menu\r
+  //\r
+  F2.ScanCode    = SCAN_F2;\r
+  F2.UnicodeChar = CHAR_NULL;\r
+  EfiBootManagerGetBootManagerMenu (&BootOption);\r
+  EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);\r
+\r
+  //\r
+  // 3. Boot Device List menu\r
+  //\r
+  F7.ScanCode     = SCAN_F7;\r
+  F7.UnicodeChar  = CHAR_NULL;\r
+  OptionNumber    = GetBootManagerMenuAppOption ();\r
+  EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL);\r
+\r
+  PrintXY (10, 10, &White, &Black, L"F2    to enter Setup.                              ");\r
+  PrintXY (10, 30, &White, &Black, L"F7    to enter Boot Manager Menu.");\r
+  PrintXY (10, 50, &White, &Black, L"Enter to boot directly.");\r
+}\r
+\r
+/**\r
+  Do the platform specific action after the console is connected.\r
+\r
+  Such as:\r
+    Dynamically switch output mode;\r
+    Signal console ready platform customized event;\r
+    Run diagnostics like memory testing;\r
+    Connect certain devices;\r
+    Dispatch aditional option roms.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerAfterConsole (\r
+  VOID\r
+  )\r
+{\r
+\r
+  //\r
+  // Go the different platform policy with different boot mode\r
+  // Notes: this part code can be change with the table policy\r
+  //\r
+  switch (GetBootModeHob ()) {\r
+\r
+  case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
+  case BOOT_WITH_MINIMAL_CONFIGURATION:\r
+    PlatformBdsDiagnostics (IGNORE, TRUE);\r
+\r
+    //\r
+    // Perform some platform specific connect sequence\r
+    //\r
+    PlatformBdsConnectSequence ();\r
+    break;\r
+\r
+  case BOOT_IN_RECOVERY_MODE:\r
+    PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
+    break;\r
+\r
+  case BOOT_WITH_FULL_CONFIGURATION:\r
+  case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
+  case BOOT_WITH_DEFAULT_SETTINGS:\r
+  default:\r
+    PlatformBdsDiagnostics (IGNORE, TRUE);\r
+    PlatformBdsRegisterStaticBootOptions ();\r
+    PlatformBdsConnectSequence ();\r
+    EfiBootManagerRefreshAllBootOption ();\r
+    break;\r
+  }\r
+}\r
+\r
+/**\r
+  This function is called each second during the boot manager waits the timeout.\r
+\r
+  @param TimeoutRemain  The remaining timeout.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerWaitCallback (\r
+  UINT16          TimeoutRemain\r
+  )\r
+{\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;\r
+  UINT16                              Timeout;\r
+\r
+  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+\r
+  Black.Raw = 0x00000000;\r
+  White.Raw = 0x00FFFFFF;\r
+\r
+  BootLogoUpdateProgress (\r
+    White.Pixel,\r
+    Black.Pixel,\r
+    L"Start boot option",\r
+    White.Pixel,\r
+    (Timeout - TimeoutRemain) * 100 / Timeout,\r
+    0\r
+    );\r
+}\r
+\r
+/**\r
+  The function is called when no boot option could be launched,\r
+  including platform recovery options and options pointing to applications\r
+  built into firmware volumes.\r
+\r
+  If this function returns, BDS attempts to enter an infinite loop.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerUnableToBoot (\r
+  VOID\r
+  )\r
+{\r
+  return;\r
+}\r
+\r
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.h b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
new file mode 100644 (file)
index 0000000..323a8bd
--- /dev/null
@@ -0,0 +1,98 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PLATFORM_BM_H\r
+#define _PLATFORM_BM_H\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/EmuSystemConfig.h>\r
+#include <Guid/EventGroup.h>\r
+#include <Protocol/EmuThunk.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/EmuGraphicsWindow.h>\r
+#include <Protocol/GenericMemoryTest.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/FirmwareVolume2.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/UefiBootManagerLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BootLogoLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/HiiLib.h>\r
+\r
+#define CONSOLE_OUT 0x00000001\r
+#define STD_ERROR   0x00000002\r
+#define CONSOLE_IN  0x00000004\r
+#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINTN                     ConnectType;\r
+} BDS_CONSOLE_CONNECT_ENTRY;\r
+\r
+extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];\r
+\r
+#define gEndEntire \\r
+  { \\r
+    END_DEVICE_PATH_TYPE,\\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\\r
+    { \\r
+      END_DEVICE_PATH_LENGTH,\\r
+      0\\r
+    }\\r
+  }\r
+\r
+\r
+typedef struct {\r
+  EMU_VENDOR_DEVICE_PATH_NODE     EmuBus;\r
+  EMU_VENDOR_DEVICE_PATH_NODE     EmuGraphicsWindow;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} EMU_PLATFORM_UGA_DEVICE_PATH;\r
+\r
+\r
+//\r
+// Platform BDS Functions\r
+//\r
+\r
+/**\r
+  Perform the memory test base on the memory test intensive level,\r
+  and update the memory resource.\r
+\r
+  @param  Level         The memory test intensive level.\r
+\r
+  @retval EFI_STATUS    Success test all the system memory and update\r
+                        the memory resource\r
+\r
+**/\r
+EFI_STATUS\r
+PlatformBootManagerMemoryTest (\r
+  IN EXTENDMEM_COVERAGE_LEVEL Level\r
+  );\r
+\r
+\r
+VOID\r
+PlatformBdsConnectSequence (\r
+  VOID\r
+  );\r
+\r
+#endif // _PLATFORM_BM_H\r
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
new file mode 100644 (file)
index 0000000..bb9d7ff
--- /dev/null
@@ -0,0 +1,64 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "PlatformBm.h"\r
+\r
+\r
+\r
+EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {\r
+  {\r
+    {\r
+      {\r
+        HARDWARE_DEVICE_PATH,\r
+        HW_VENDOR_DP,\r
+        {\r
+          (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
+          (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+        }\r
+      },\r
+      EMU_THUNK_PROTOCOL_GUID\r
+    },\r
+    0\r
+  },\r
+  {\r
+    {\r
+      {\r
+        HARDWARE_DEVICE_PATH,\r
+        HW_VENDOR_DP,\r
+        {\r
+          (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
+          (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+        },\r
+      },\r
+      EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,\r
+    },\r
+    0\r
+  },\r
+  gEndEntire\r
+};\r
+\r
+//\r
+// Predefined platform default console device path\r
+//\r
+BDS_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {\r
+  {\r
+    (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,\r
+    (CONSOLE_OUT | CONSOLE_IN)\r
+  },\r
+  {\r
+    NULL,\r
+    0\r
+  }\r
+};\r
+\r
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf b/EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
new file mode 100644 (file)
index 0000000..af074c3
--- /dev/null
@@ -0,0 +1,73 @@
+## @file\r
+# Platfrom Boot Manager library\r
+#\r
+# Do platform action customized by IBV/OEM.\r
+# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PlatformBmLib\r
+  FILE_GUID                      = 59569181-CBF8-2E44-9C3E-C2AB2F5608E1\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PlatformBootManagerLib|DXE_DRIVER\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  PlatformBm.c\r
+  PlatformBm.h\r
+  PlatformBmData.c\r
+  PlatformBmMemoryTest.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  MemoryAllocationLib\r
+  UefiBootServicesTableLib\r
+  UefiRuntimeServicesTableLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  PcdLib\r
+  UefiBootManagerLib\r
+  DevicePathLib\r
+  UefiLib\r
+  BootLogoLib\r
+  HobLib\r
+  HiiLib\r
+\r
+[Guids]\r
+  gEmuSystemConfigGuid\r
+  gEfiEndOfDxeEventGroupGuid\r
+\r
+[Protocols]\r
+  gEfiGenericMemTestProtocolGuid\r
+\r
+[Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn\r
+  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand\r
+\r
+[Depex]\r
+  gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid\r
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
new file mode 100644 (file)
index 0000000..5b39776
--- /dev/null
@@ -0,0 +1,133 @@
+/** @file\r
+  Perform the platform memory test\r
+\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "PlatformBm.h"\r
+\r
+//\r
+// BDS Platform Functions\r
+//\r
+\r
+/**\r
+  Perform the memory test base on the memory test intensive level,\r
+  and update the memory resource.\r
+\r
+  @param  Level         The memory test intensive level.\r
+\r
+  @retval EFI_STATUS    Success test all the system memory and update\r
+                        the memory resource\r
+\r
+**/\r
+EFI_STATUS\r
+PlatformBootManagerMemoryTest (\r
+  IN EXTENDMEM_COVERAGE_LEVEL Level\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_STATUS                        KeyStatus;\r
+  EFI_STATUS                        InitStatus;\r
+  EFI_STATUS                        ReturnStatus;\r
+  BOOLEAN                           RequireSoftECCInit;\r
+  EFI_GENERIC_MEMORY_TEST_PROTOCOL  *GenMemoryTest;\r
+  UINT64                            TestedMemorySize;\r
+  UINT64                            TotalMemorySize;\r
+  UINT64                            PreviousValue;\r
+  BOOLEAN                           ErrorOut;\r
+  BOOLEAN                           TestAbort;\r
+  EFI_INPUT_KEY                     Key;\r
+  CHAR16                            *StrTotalMemory;\r
+  CHAR16                            *Pos;\r
+  UINTN                             StrTotalMemorySize;\r
+\r
+  ReturnStatus = EFI_SUCCESS;\r
+  ZeroMem (&Key, sizeof (EFI_INPUT_KEY));\r
+\r
+  StrTotalMemorySize = 128;\r
+  Pos = AllocateZeroPool (StrTotalMemorySize);\r
+  ASSERT (Pos != NULL);\r
+\r
+  StrTotalMemory    = Pos;\r
+\r
+  TestedMemorySize  = 0;\r
+  TotalMemorySize   = 0;\r
+  PreviousValue     = 0;\r
+  ErrorOut          = FALSE;\r
+  TestAbort         = FALSE;\r
+\r
+  RequireSoftECCInit = FALSE;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiGenericMemTestProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) &GenMemoryTest\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    FreePool (Pos);\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  InitStatus = GenMemoryTest->MemoryTestInit (\r
+                                GenMemoryTest,\r
+                                Level,\r
+                                &RequireSoftECCInit\r
+                                );\r
+  if (InitStatus == EFI_NO_MEDIA) {\r
+    //\r
+    // The PEI codes also have the relevant memory test code to check the memory,\r
+    // it can select to test some range of the memory or all of them. If PEI code\r
+    // checks all the memory, this BDS memory test will has no not-test memory to\r
+    // do the test, and then the status of EFI_NO_MEDIA will be returned by\r
+    // "MemoryTestInit". So it does not need to test memory again, just return.\r
+    //\r
+    FreePool (Pos);\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  DEBUG ((DEBUG_INFO, "Enter memory test.\n"));\r
+  do {\r
+    Status = GenMemoryTest->PerformMemoryTest (\r
+                              GenMemoryTest,\r
+                              &TestedMemorySize,\r
+                              &TotalMemorySize,\r
+                              &ErrorOut,\r
+                              TestAbort\r
+                              );\r
+    if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {\r
+      PrintXY (10, 10, NULL, NULL, L"Memory Testing failed!");\r
+      ASSERT (0);\r
+    }\r
+\r
+\r
+    DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n"));\r
+\r
+    if (!PcdGetBool (PcdConInConnectOnDemand)) {\r
+      KeyStatus     = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+      if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {\r
+        if (!RequireSoftECCInit) {\r
+          Status = GenMemoryTest->Finished (GenMemoryTest);\r
+          goto Done;\r
+        }\r
+\r
+        TestAbort = TRUE;\r
+      }\r
+    }\r
+  } while (Status != EFI_NOT_FOUND);\r
+\r
+  Status = GenMemoryTest->Finished (GenMemoryTest);\r
+\r
+Done:\r
+  DEBUG ((DEBUG_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize));\r
+\r
+  FreePool (Pos);\r
+  return ReturnStatus;\r
+}\r