public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* EFI hanging at EfiBootManagerRefreshAllBootOption
@ 2016-10-05 11:35 Saqib Khan
  2016-10-05 12:36 ` Saqib Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Saqib Khan @ 2016-10-05 11:35 UTC (permalink / raw)
  To: edk2-devel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-05 12:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-05 11:35 EFI hanging at EfiBootManagerRefreshAllBootOption Saqib Khan
2016-10-05 12:36 ` Saqib Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox