* [PATCH 0/2] fix boot order bugs @ 2019-04-29 5:24 Zhiguang Liu 2019-04-29 5:24 ` [PATCH 1/2] EmulatorPkg: Make the shell be the first boot option Zhiguang Liu 2019-04-29 5:24 ` [PATCH 2/2] EmulatorPkg: Save the modified order after rebooting Zhiguang Liu 0 siblings, 2 replies; 5+ messages in thread From: Zhiguang Liu @ 2019-04-29 5:24 UTC (permalink / raw) To: devel; +Cc: Jordan Justen, Andrew Fish, Ray Ni this series will fix boot order bugs and make shell be the first by default. Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Andrew Fish <afish@apple.com> Cc: Ray Ni <ray.ni@intel.com> Zhiguang Liu (2): EmulatorPkg: Make the shell be the first boot option EmulatorPkg: Save the modified order after rebooting -- 2.21.0.windows.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] EmulatorPkg: Make the shell be the first boot option 2019-04-29 5:24 [PATCH 0/2] fix boot order bugs Zhiguang Liu @ 2019-04-29 5:24 ` Zhiguang Liu 2019-05-05 3:23 ` Ni, Ray 2019-04-29 5:24 ` [PATCH 2/2] EmulatorPkg: Save the modified order after rebooting Zhiguang Liu 1 sibling, 1 reply; 5+ messages in thread From: Zhiguang Liu @ 2019-04-29 5:24 UTC (permalink / raw) To: devel; +Cc: Jordan Justen, Andrew Fish, Ray Ni REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1649 Make the shell be the first boot option by default, So it can boot into UEFI Internal Shell directly, when run the emulator if user don't change boot order. Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Andrew Fish <afish@apple.com> Cc: Ray Ni <ray.ni@intel.com> --- EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c index 2a97e385be..459ac5c4b5 100644 --- a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c +++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c @@ -388,6 +388,34 @@ PlatformBootManagerChangeDevicePath ( } } } +/** + Returns the priority number. + + @param BootOption +**/ +UINTN +BootOptionPriority ( + CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption + ) +{ + // + // Make sure Shell is first + // + if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) { + return 0; + } + return 100; +} + +INTN +EFIAPI +CompareBootOption ( + CONST EFI_BOOT_MANAGER_LOAD_OPTION *Left, + CONST EFI_BOOT_MANAGER_LOAD_OPTION *Right + ) +{ + return BootOptionPriority (Left) - BootOptionPriority (Right); +} /** Do the platform specific action after the console is connected. @@ -432,9 +460,10 @@ PlatformBootManagerAfterConsole ( default: PlatformBdsDiagnostics (IGNORE, TRUE); PlatformBootManagerChangeDevicePath(&FirstBoot); - PlatformBdsRegisterStaticBootOptions (); PlatformBdsConnectSequence (); EfiBootManagerRefreshAllBootOption (); + PlatformBdsRegisterStaticBootOptions (); + if(FirstBoot)EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE) CompareBootOption); break; } } -- 2.21.0.windows.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] EmulatorPkg: Make the shell be the first boot option 2019-04-29 5:24 ` [PATCH 1/2] EmulatorPkg: Make the shell be the first boot option Zhiguang Liu @ 2019-05-05 3:23 ` Ni, Ray 0 siblings, 0 replies; 5+ messages in thread From: Ni, Ray @ 2019-05-05 3:23 UTC (permalink / raw) To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Justen, Jordan L, Andrew Fish Please run ecc to make sure your coding style is proper. > -----Original Message----- > From: Liu, Zhiguang <zhiguang.liu@intel.com> > Sent: Monday, April 29, 2019 1:25 PM > To: devel@edk2.groups.io > Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Andrew Fish > <afish@apple.com>; Ni, Ray <ray.ni@intel.com> > Subject: [PATCH 1/2] EmulatorPkg: Make the shell be the first boot option > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1649 > > Make the shell be the first boot option by default, > So it can boot into UEFI Internal Shell directly, > when run the emulator if user don't change boot order. > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > > Cc: Jordan Justen <jordan.l.justen@intel.com> > Cc: Andrew Fish <afish@apple.com> > Cc: Ray Ni <ray.ni@intel.com> > --- > EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 31 > ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > index 2a97e385be..459ac5c4b5 100644 > --- a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > +++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > @@ -388,6 +388,34 @@ PlatformBootManagerChangeDevicePath ( > } > } > } > +/** > + Returns the priority number. > + > + @param BootOption > +**/ > +UINTN > +BootOptionPriority ( > + CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption > + ) > +{ > + // > + // Make sure Shell is first > + // > + if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) { > + return 0; > + } > + return 100; > +} > + > +INTN > +EFIAPI > +CompareBootOption ( > + CONST EFI_BOOT_MANAGER_LOAD_OPTION *Left, > + CONST EFI_BOOT_MANAGER_LOAD_OPTION *Right > + ) > +{ > + return BootOptionPriority (Left) - BootOptionPriority (Right); > +} > > /** > Do the platform specific action after the console is connected. > @@ -432,9 +460,10 @@ PlatformBootManagerAfterConsole ( > default: > PlatformBdsDiagnostics (IGNORE, TRUE); > PlatformBootManagerChangeDevicePath(&FirstBoot); > - PlatformBdsRegisterStaticBootOptions (); > PlatformBdsConnectSequence (); > EfiBootManagerRefreshAllBootOption (); > + PlatformBdsRegisterStaticBootOptions (); > + if(FirstBoot)EfiBootManagerSortLoadOptionVariable > (LoadOptionTypeBoot, (SORT_COMPARE) CompareBootOption); > break; > } > } > -- > 2.21.0.windows.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] EmulatorPkg: Save the modified order after rebooting 2019-04-29 5:24 [PATCH 0/2] fix boot order bugs Zhiguang Liu 2019-04-29 5:24 ` [PATCH 1/2] EmulatorPkg: Make the shell be the first boot option Zhiguang Liu @ 2019-04-29 5:24 ` Zhiguang Liu 2019-05-05 3:22 ` [edk2-devel] " Ni, Ray 1 sibling, 1 reply; 5+ messages in thread From: Zhiguang Liu @ 2019-04-29 5:24 UTC (permalink / raw) To: devel; +Cc: Jordan Justen, Andrew Fish, Ray Ni REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1650 The reason why boot order changed is that everytime Emulator restarts, the memory mapped address will change. This patch correct the device path to the right one. Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Andrew Fish <afish@apple.com> Cc: Ray Ni <ray.ni@intel.com> --- EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c index 191ce58cfb..28329e4f52 100644 --- a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c +++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c @@ -332,6 +332,63 @@ PlatformBdsRegisterStaticBootOptions ( PrintXY (10, 50, &White, &Black, L"Enter to boot directly."); } +/** + Change the device path of the boot options to the correct one. + and return whether it is the first time to start up emulator since last build. + @param FirstBoot Return 1 if it is the first time to start up emulator since last build. +**/ +VOID +EFIAPI +PlatformBootManagerChangeDevicePath ( + OUT UINTN *FirstBoot + ) +{ + UINTN BootOptionCount; + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; + UINTN Index,LastIndex; + UINTN Flag=0; + *FirstBoot=1; + BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot); + for (Index = 0; Index < BootOptionCount; Index++) + { + if ((!StrCmp(L"UEFI Enter Setup", BootOptions[Index].Description)) || + (!StrCmp(L"UEFI BootManagerMenuApp", BootOptions[Index].Description)) || + (!StrCmp(L"UEFI Shell", BootOptions[Index].Description))) + { + EFI_DEVICE_PATH_PROTOCOL *mypath; + EFI_DEVICE_PATH_PROTOCOL *mynextnode; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + gBS->HandleProtocol( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **)&LoadedImage); + mynextnode = NextDevicePathNode(BootOptions[Index].FilePath); + mypath = DevicePathFromHandle(LoadedImage->DeviceHandle); + while (!IsDevicePathEndType(mynextnode)) + { + mypath = AppendDevicePathNode( + mypath, + mynextnode); + mynextnode = NextDevicePathNode(mynextnode); + } + BootOptions[Index].FilePath = DuplicateDevicePath(mypath); + FreePool(mypath); + EfiBootManagerLoadOptionToVariable(&BootOptions[Index]); + if(!StrCmp(L"UEFI Enter Setup", BootOptions[Index].Description)){ + if (Flag!=0){ + EfiBootManagerDeleteLoadOptionVariable(BootOptions[LastIndex].OptionNumber, LoadOptionTypeBoot); + } + Flag++; + LastIndex=Index; + } + if(!StrCmp(L"UEFI Shell", BootOptions[Index].Description)){ + *FirstBoot=0; + } + + } + } +} + /** Do the platform specific action after the console is connected. @@ -348,7 +405,7 @@ PlatformBootManagerAfterConsole ( VOID ) { - + UINTN FirstBoot=1; // // Go the different platform policy with different boot mode // Notes: this part code can be change with the table policy @@ -374,9 +431,10 @@ PlatformBootManagerAfterConsole ( case BOOT_WITH_DEFAULT_SETTINGS: default: PlatformBdsDiagnostics (IGNORE, TRUE); - PlatformBdsRegisterStaticBootOptions (); + PlatformBootManagerChangeDevicePath(&FirstBoot); PlatformBdsConnectSequence (); EfiBootManagerRefreshAllBootOption (); + PlatformBdsRegisterStaticBootOptions (); break; } } -- 2.21.0.windows.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH 2/2] EmulatorPkg: Save the modified order after rebooting 2019-04-29 5:24 ` [PATCH 2/2] EmulatorPkg: Save the modified order after rebooting Zhiguang Liu @ 2019-05-05 3:22 ` Ni, Ray 0 siblings, 0 replies; 5+ messages in thread From: Ni, Ray @ 2019-05-05 3:22 UTC (permalink / raw) To: devel@edk2.groups.io, Liu, Zhiguang; +Cc: Justen, Jordan L, Andrew Fish Zhiguang, You could avoid using memory mapped FV device path (guided FV device path) by adding FvNameGuid to EmulatorPkg.fdf file under [FV.RvRecovery] section. [FV.FvRecovery] FvNameGuid = 6D99E806-3D38-42c2-A095-5F4300BFD7DC Thanks, Ray > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of > Zhiguang Liu > Sent: Monday, April 29, 2019 1:25 PM > To: devel@edk2.groups.io > Cc: Justen, Jordan L <jordan.l.justen@intel.com>; Andrew Fish > <afish@apple.com>; Ni, Ray <ray.ni@intel.com> > Subject: [edk2-devel] [PATCH 2/2] EmulatorPkg: Save the modified order > after rebooting > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1650 > > The reason why boot order changed is that everytime Emulator > restarts, the memory mapped address will change. > This patch correct the device path to the right one. > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > > Cc: Jordan Justen <jordan.l.justen@intel.com> > Cc: Andrew Fish <afish@apple.com> > Cc: Ray Ni <ray.ni@intel.com> > --- > EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 62 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++-- > 1 file changed, 60 insertions(+), 2 deletions(-) > > diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > index 191ce58cfb..28329e4f52 100644 > --- a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > +++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > @@ -332,6 +332,63 @@ PlatformBdsRegisterStaticBootOptions ( > PrintXY (10, 50, &White, &Black, L"Enter to boot directly."); > } > > +/** > + Change the device path of the boot options to the correct one. > + and return whether it is the first time to start up emulator since last build. > + @param FirstBoot Return 1 if it is the first time to start up emulator since > last build. > +**/ > +VOID > +EFIAPI > +PlatformBootManagerChangeDevicePath ( > + OUT UINTN *FirstBoot > + ) > +{ > + UINTN BootOptionCount; > + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > + UINTN Index,LastIndex; > + UINTN Flag=0; > + *FirstBoot=1; > + BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, > LoadOptionTypeBoot); > + for (Index = 0; Index < BootOptionCount; Index++) > + { > + if ((!StrCmp(L"UEFI Enter Setup", BootOptions[Index].Description)) || > + (!StrCmp(L"UEFI BootManagerMenuApp", > BootOptions[Index].Description)) || > + (!StrCmp(L"UEFI Shell", BootOptions[Index].Description))) > + { > + EFI_DEVICE_PATH_PROTOCOL *mypath; > + EFI_DEVICE_PATH_PROTOCOL *mynextnode; > + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; > + gBS->HandleProtocol( > + gImageHandle, > + &gEfiLoadedImageProtocolGuid, > + (VOID **)&LoadedImage); > + mynextnode = NextDevicePathNode(BootOptions[Index].FilePath); > + mypath = DevicePathFromHandle(LoadedImage->DeviceHandle); > + while (!IsDevicePathEndType(mynextnode)) > + { > + mypath = AppendDevicePathNode( > + mypath, > + mynextnode); > + mynextnode = NextDevicePathNode(mynextnode); > + } > + BootOptions[Index].FilePath = DuplicateDevicePath(mypath); > + FreePool(mypath); > + EfiBootManagerLoadOptionToVariable(&BootOptions[Index]); > + if(!StrCmp(L"UEFI Enter Setup", BootOptions[Index].Description)){ > + if (Flag!=0){ > + > EfiBootManagerDeleteLoadOptionVariable(BootOptions[LastIndex].OptionN > umber, LoadOptionTypeBoot); > + } > + Flag++; > + LastIndex=Index; > + } > + if(!StrCmp(L"UEFI Shell", BootOptions[Index].Description)){ > + *FirstBoot=0; > + } > + > + } > + } > +} > + > /** > Do the platform specific action after the console is connected. > > @@ -348,7 +405,7 @@ PlatformBootManagerAfterConsole ( > VOID > ) > { > - > + UINTN FirstBoot=1; > // > // Go the different platform policy with different boot mode > // Notes: this part code can be change with the table policy > @@ -374,9 +431,10 @@ PlatformBootManagerAfterConsole ( > case BOOT_WITH_DEFAULT_SETTINGS: > default: > PlatformBdsDiagnostics (IGNORE, TRUE); > - PlatformBdsRegisterStaticBootOptions (); > + PlatformBootManagerChangeDevicePath(&FirstBoot); > PlatformBdsConnectSequence (); > EfiBootManagerRefreshAllBootOption (); > + PlatformBdsRegisterStaticBootOptions (); > break; > } > } > -- > 2.21.0.windows.1 > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-05-05 3:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-04-29 5:24 [PATCH 0/2] fix boot order bugs Zhiguang Liu 2019-04-29 5:24 ` [PATCH 1/2] EmulatorPkg: Make the shell be the first boot option Zhiguang Liu 2019-05-05 3:23 ` Ni, Ray 2019-04-29 5:24 ` [PATCH 2/2] EmulatorPkg: Save the modified order after rebooting Zhiguang Liu 2019-05-05 3:22 ` [edk2-devel] " Ni, Ray
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox