Add a BDS platform hook function PlatformBootManagerDefaultBootFail to 
PlatformBootManagerLib

Why we need this hook function :
 1) According to UEFI 2.5 Section 3.4.3, the 3rd paragraph, It seems we need to 
have a hook function (PlatformBootManagerDefaultBootFail) for platform firmware 
to do platform action like recovering or setting to a known set of boot options.
 2) This hook function is similar to IntelFrameworkModulePkg's PlatformBdsLib's 
PlatformBdsBootFail function which was used in several platforms in EDK2, so it 
would be helpful for other platforms to change their BDS platform library from 
IntelFrameworkModulePkg's PlatformBdsLib to MdeModulePkg's 
PlatformBootManagerLib in the future.

Where we call/run this hook function:
 1) According to UEFI 2.5 Section 3.1.1, the 5th paragraph, we need to present 
a boot manager menu to the user for the successful boot attempt, so we only 
call PlatformBootManagerDefaultBootFail when booting enumerated boot options 
fails.

Reference:
 1) UEFI 2.5 Section 3.4.3, the 3rd paragraph:
    - It is expected that this default boot will load an operating system or a 
maintenance utility. If this is an operating system setup program it is then 
responsible for setting the requisite environment variables for subsequent 
boots. The platform firmware may also decide to recover or set to a known set 
of boot
options.
 2) UEFI 2.5 Section 3.1.1, the 5th paragraph:
    - If the boot via Boot#### returns with a status of EFI_SUCCESS, platform 
firmware supports boot manager menu, and if firmware is configured to boot in 
an interactive mode, the boot manager will stop processing the BootOrder 
variable and present a boot manager menu to the user.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Sunny Wang <[email protected]>
---
 MdeModulePkg/Include/Library/PlatformBootManagerLib.h  | 15 +++++++++++++++
 .../PlatformBootManagerLibNull/PlatformBootManager.c   | 18 ++++++++++++++++++
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c               | 18 ++++++++++++++++--
 .../PlatformBootManagerLib/PlatformBootManager.c       | 18 ++++++++++++++++++
 4 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Include/Library/PlatformBootManagerLib.h 
b/MdeModulePkg/Include/Library/PlatformBootManagerLib.h
index 5274503..974dcc5 100644
--- a/MdeModulePkg/Include/Library/PlatformBootManagerLib.h
+++ b/MdeModulePkg/Include/Library/PlatformBootManagerLib.h
@@ -3,6 +3,7 @@
   instances to support platform-specific behavior.
 
 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -59,4 +60,18 @@ PlatformBootManagerWaitCallback (
   UINT16          TimeoutRemain
   );
 
+/**
+  Do the platform specific action after all the boot attempts are failed to 
boot.
+
+  Such as:
+    Print specific string
+    Show the Boot Manager Menu
+
+**/
+VOID
+EFIAPI
+PlatformBootManagerDefaultBootFail (
+  VOID
+  );
+
 #endif
diff --git 
a/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c 
b/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c
index 1390e19..b9e5a71 100644
--- a/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c
+++ b/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c
@@ -3,6 +3,7 @@
   by IBV/OEM.
 
 Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -65,3 +66,20 @@ PlatformBootManagerWaitCallback (
 {
   return;
 }
+
+/**
+  Do the platform specific action after all the boot attempts are failed to 
boot.
+
+  Such as:
+    Print specific string
+    Show the Boot Manager Menu
+
+**/
+VOID
+EFIAPI
+PlatformBootManagerDefaultBootFail (
+  VOID
+  )
+{
+  return;
+}
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c 
b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index c889892..729a220 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -5,8 +5,8 @@
   After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be 
invoked
   to enter BDS phase.
 
-(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -532,6 +532,12 @@ DefaultBootBehavior (
     //
     // Show the Boot Manager Menu after successful boot
     //
+    // If the boot via Boot#### returns with a status of EFI_SUCCESS, platform 
firmware 
+    // supports boot manager menu, and if firmware is configured to boot in an 
interactive 
+    // mode, the boot manager will stop processing the BootOrder variable and 
present a 
+    // boot manager menu to the user.
+    //                 -- UEFI 2.5 Section 3.1.1 Boot Manager Programming, the 
5th paragraph
+    //
     EfiBootManagerBoot (&BootManagerMenu);
   } else {
     EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
@@ -542,13 +548,21 @@ DefaultBootBehavior (
     // devices followed by all fixed media devices. The order within each 
group is undefined.
     // These new default boot options are not saved to non volatile 
storage.The boot manger
     // will then attempt toboot from each boot option.
-    //                            -- Chapter 3.3 Boot Manager Programming, the 
2nd paragraph
+    //                   -- UEFI 2.4 Section 3.3 Boot Manager Programming, the 
2nd paragraph
     //
     EfiBootManagerConnectAll ();
     BootOptions = BdsEnumerateBootOptions (&BootOptionCount);
 
     if (!BootAllBootOptions (BootOptions, BootOptionCount)) {
       DEBUG ((EFI_D_ERROR, "[Bds]No bootable device!\n"));
+      //
+      // The platform firmware may decide to recover or set to a known set of 
boot options.
+      //
+      PlatformBootManagerDefaultBootFail ();
+    } else {
+      //
+      // Show the Boot Manager Menu after successful boot.
+      //
       EfiBootManagerBoot (&BootManagerMenu);
     }
   }
diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c 
b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index e944105..db973c0 100644
--- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -3,6 +3,7 @@
   by IBV/OEM.
 
 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -280,3 +281,20 @@ PlatformBootManagerWaitCallback (
     0
     );
 }
+
+/**
+  Do the platform specific action after all the boot attempts are failed to 
boot.
+
+  Such as:
+    Print specific string
+    Show the Boot Manager Menu
+
+**/
+VOID
+EFIAPI
+PlatformBootManagerDefaultBootFail (
+  VOID
+  )
+{
+  return;
+}
-- 
2.5.0.windows.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to