public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Saqib Khan <saqib.khan2011@gmail.com>
To: edk2-devel@lists.01.org
Subject: Re: EFI hanging at EfiBootManagerRefreshAllBootOption
Date: Wed, 5 Oct 2016 17:36:53 +0500	[thread overview]
Message-ID: <CAF=YJJ_bpfNXYqNAv+Zgd6hnkpxg0fBpFaFwDvpz7oYccr-F7w@mail.gmail.com> (raw)
In-Reply-To: <CAF=YJJ-R6qCkDriRP8otvy71R0cYTOYi0FtSiC=ABfFcBE=dkQ@mail.gmail.com>

[Packages]
  MdePkg/MdePkg.dec
  MdeModulePkg/MdeModulePkg.dec
  IntelFrameworkPkg/IntelFrameworkPkg.dec
  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
  ShellPkg/ShellPkg.dec

[LibraryClasses]
  HiiLib
  DebugLib
  UefiLib
  MemoryAllocationLib
  UefiBootServicesTableLib
  UefiApplicationEntryPoint
  UefiBootManagerLib
  LegacyBootManagerLib


I have figured out that if I add LegacyBootManagerLib it hangs at
EfiBootManagerRefreshAllBootOption() . any idea why this behaviour?

I want to boot legacy so i need legacyBootManagerLib...

On Wed, Oct 5, 2016 at 4:35 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote:

> Hi ,
> I am working on a Boot manager
> I have following set-up
> in USB i have directory  EFI->BOOT->Bootx64.efi(my EFI)
>
>
> My EFI does load an image, before that I am trying to
> EfiBootManagerRefreshAllBootOption () I am trying to refresh all but
> option .but it hangs on  EfiBootManagerRefreshAllBootOption () .
>
> I have shared code  I have bold and underlined where it is hanging, any
> idea what might be the reason?
>
>
> Here is Code :
>
> EFI_STATUS
> EFIAPI
> BootManagerMenuEntry (
>   IN EFI_HANDLE                            ImageHandle,
>   IN EFI_SYSTEM_TABLE                      *SystemTable
>   )
> {
>
>     EFI_BOOT_MANAGER_LOAD_OPTION    *BootOption;
>     UINTN                           BootOptionCount;
>     EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;
>     EFI_BOOT_LOGO_PROTOCOL          *BootLogo;
>     EFI_STATUS    Status;
>     UINTN         BootVariableSize;
>
>       CHAR16        *Name;
>       UINTN         NewNameSize;
>       UINTN         NameSize;
>      UINTN         i;
>
>     EFI_GUID VarGuid;
>     VOID* Value;
>         UINTN Index;
>
>         EFI_DEVICE_PATH_PROTOCOL *DevicePathProtocol;
>
>         EFI_LOADED_IMAGE_PROTOCOL* LoadedImageProtocol;
>
>
>
>   BootLogo = NULL;
>   Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)
> &BootLogo);
>   if (!EFI_ERROR (Status) && (BootLogo != NULL)) {
>     Status = BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);
>     ASSERT_EFI_ERROR (Status);
>   }
>
>   gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);
>
>   gStringPackHandle = HiiAddPackages (
>                          &gEfiCallerIdGuid,
>                          gImageHandle,
>                          BootManagerMenuAppStrings,
>                          NULL
>                          );
>   ASSERT (gStringPackHandle != NULL);
>
>
>
>     Print(L"ConnectBootManager\n");
>     EfiBootManagerConnectAll ();
>     Print(L"Connected BootManager\n");
>
> *----->EfiBootManagerRefreshAllBootOption ();   *//Here it gets hang
>       Print(L"All option refreshed\n");
>
>       BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount,
> LoadOptionTypeBoot);
>       Print(L"Alloption refreshed fdfdf\n");
>       //legacybootoptionrefresh();
>       //LegacyBootManager(BootOption);
>       //EfiBootManagerRegisterLegacyBootSupport(legacybootoptionrefresh,
> LegacyBootManager
>
>
>
>     Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID
> **) &LegacyBios);
>   if (EFI_ERROR (Status)) {
>     //
>     // If no LegacyBios protocol we do not support legacy boot
>     //
>     Print(L"Boot not suported [%X]\n",Status);
>     //BootOption->Status = EFI_UNSUPPORTED;
>    // return;
>   }
>
>
>
>
>
>
>
>
>     //UINTN         ExitDataSizePtr;
>     //UINTN HandleCount;
>     //UINTN ScratchBufferSize = 0;
>     //EFI_HANDLE *HandleBuffer;
>
>     //EFI_BOOT_LOGO_PROTOCOL          *BootLogo;
>
>     Status=gBS->HandleProtocol(
>         ImageHandle,
>         &gEfiLoadedImageProtocolGuid,
>         (VOID**)&LoadedImageProtocol
>         );
>
>
>     Status=gBS->HandleProtocol(
>         LoadedImageProtocol->DeviceHandle,
>         &gEfiDevicePathProtocolGuid,
>         (VOID**)&DevicePathProtocol
>         );
>     Print (L"Image device : %s\n",ConvertDevicePathToText
> (DevicePathProtocol,TRUE,TRUE));
>     Print (L"Image file: %s\n",ConvertDevicePathToText
> (LoadedImageProtocol->FilePath,TRUE,TRUE));
>     Print (L"Image Base: %X\n",LoadedImageProtocol->ImageBase);
>     Print (L"Image Size: %X\n",LoadedImageProtocol->ImageSize);
>
>     Value =NULL ;
>     /*Print All Boot option*/
>
>      //Print all BOOT#### Load Options
>   NameSize = sizeof(CHAR16);
>   Name     = AllocateZeroPool(NameSize);
>   for (i=0; ;i++ ){
>       NewNameSize = NameSize;
>       //search all EFI variables
>       Status = gRT->GetNextVariableName (&NewNameSize, Name, &VarGuid);
>         if (Status == EFI_BUFFER_TOO_SMALL) {
>       Name = ReallocatePool (NameSize, NewNameSize, Name);
>       Status = gRT->GetNextVariableName (&NewNameSize, Name, &VarGuid);
>       NameSize = NewNameSize;
>     }
>     //
>     if (Status == EFI_NOT_FOUND) {
>       break;
>     }
>     //skip if not Global variable
>     if (!CompareGuid(&VarGuid, &gEfiGlobalVariableGuid))
>         continue;
>     //check BOOT#### variable
>     if(!StrnCmp(Name, L"Boot", 4) &&
>         isitDigit(Name[4]) && isitDigit(Name[5]) &&
>         isitDigit(Name[6]) && isitDigit(Name[7]))
>     {
>         Print(L"%s:", Name);
>         //get BOOT####
>        // Status = gRT->GetVariable((CHAR16 *)Name,
> &gEfiGlobalVariableGuid, &BootVariableSize, NULL);
>         Status = gRT->GetVariable ((CHAR16 *)Name,
> &gEfiGlobalVariableGuid, NULL, &BootVariableSize, Value);
>         //print attribute
>
>         //print EFI_LOAD_OPTION description
>         Print(L" %s",(CHAR16 *)(Name+3));
>         Print(L"\n");
>
> }
>   }
>
>
>     LoadImageFromFile (L"\\Hello.efi");
>
>     SystemTable->ConOut->OutputString (
>         SystemTable->ConOut,
>         L"\n\r\n\r\n\rHit any key to exit\n\r");
>     SystemTable->BootServices->WaitForEvent (
>         1,
>         &(SystemTable->ConIn->WaitForKey),
>         &Index);
>
>
>
>
>   return Status;
>
> }
>
>
> --
> Regards
> Saqib Ahmed Khanzada
>



-- 
Regards
Saqib Ahmed Khanzada


      reply	other threads:[~2016-10-05 12:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 11:35 EFI hanging at EfiBootManagerRefreshAllBootOption Saqib Khan
2016-10-05 12:36 ` Saqib Khan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAF=YJJ_bpfNXYqNAv+Zgd6hnkpxg0fBpFaFwDvpz7oYccr-F7w@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox