* UefiBootManagerLib and LegacyBootManagerLib issue @ 2016-10-05 12:51 Saqib Khan 2016-10-05 16:05 ` Saqib Khan 0 siblings, 1 reply; 8+ messages in thread From: Saqib Khan @ 2016-10-05 12:51 UTC (permalink / raw) To: edk2-devel Hi, when i import both lib in my project my EFI hangs at EfiRefreshAllBootOptions, i removed LegacyBootManager and it worked fine .i need both lib as i need to boot legacy from EFI, how this issue can be resolved? here is piece of inf file [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 -- Regards Saqib Ahmed Khanzada ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: UefiBootManagerLib and LegacyBootManagerLib issue 2016-10-05 12:51 UefiBootManagerLib and LegacyBootManagerLib issue Saqib Khan @ 2016-10-05 16:05 ` Saqib Khan 2016-10-05 21:23 ` Urgent help -UefiBootManagerLib " Saqib Khan 0 siblings, 1 reply; 8+ messages in thread From: Saqib Khan @ 2016-10-05 16:05 UTC (permalink / raw) To: edk2-devel I have found that it just dont return from *mBmRefreshLegacyBootOption (); .* have a look at code. let me know the possible cause of it ... I need urgent help EfiBootManagerRefreshAllBootOption ( VOID ) { EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; UINTN NvBootOptionCount; EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; UINTN BootOptionCount; UINTN Index; Print(L"indside refresh\n"); // // Optionally refresh the legacy boot option // if (mBmRefreshLegacyBootOption != NULL) { Print(L"Before legacy refresh \n"); *mBmRefreshLegacyBootOption (); *//this method does not return Print(L"legacy refresh complete\n"); } On Wed, Oct 5, 2016 at 5:51 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote: > Hi, > > when i import both lib in my project my EFI hangs at > EfiRefreshAllBootOptions, i removed LegacyBootManager and it worked fine .i > need both lib as i need to boot legacy from EFI, how this issue can be > resolved? > > > here is piece of inf file > > [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 > > > -- > Regards > Saqib Ahmed Khanzada > -- Regards Saqib Ahmed Khanzada ^ permalink raw reply [flat|nested] 8+ messages in thread
* Urgent help -UefiBootManagerLib and LegacyBootManagerLib issue 2016-10-05 16:05 ` Saqib Khan @ 2016-10-05 21:23 ` Saqib Khan 2016-10-05 21:37 ` Andrew Fish 0 siblings, 1 reply; 8+ messages in thread From: Saqib Khan @ 2016-10-05 21:23 UTC (permalink / raw) To: edk2-devel Hi all,i need urgent help regarding this issue. > On 05-Oct-2016, at 9:05 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote: > > > I have found that it just dont return from mBmRefreshLegacyBootOption (); . > > have a look at code. let me know the possible cause of it ... > I need urgent help > > EfiBootManagerRefreshAllBootOption ( > VOID > ) > { > EFI_STATUS Status; > EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; > UINTN NvBootOptionCount; > EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > UINTN BootOptionCount; > UINTN Index; > Print(L"indside refresh\n"); > // > // Optionally refresh the legacy boot option > // > if (mBmRefreshLegacyBootOption != NULL) { > Print(L"Before legacy refresh \n"); > mBmRefreshLegacyBootOption (); //this method does not return > Print(L"legacy refresh complete\n"); > } > >> On Wed, Oct 5, 2016 at 5:51 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote: >> Hi, >> >> when i import both lib in my project my EFI hangs at EfiRefreshAllBootOptions, i removed LegacyBootManager and it worked fine .i need both lib as i need to boot legacy from EFI, how this issue can be resolved? >> >> >> here is piece of inf file >> >> [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 >> >> >> -- >> Regards >> Saqib Ahmed Khanzada > > > > -- > Regards > Saqib Ahmed Khanzada ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Urgent help -UefiBootManagerLib and LegacyBootManagerLib issue 2016-10-05 21:23 ` Urgent help -UefiBootManagerLib " Saqib Khan @ 2016-10-05 21:37 ` Andrew Fish 2016-10-06 7:28 ` Saqib Khan 0 siblings, 1 reply; 8+ messages in thread From: Andrew Fish @ 2016-10-05 21:37 UTC (permalink / raw) To: Saqib Khan; +Cc: edk2-devel > On Oct 5, 2016, at 2:23 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote: > > > > Hi all,i need urgent help regarding this issue. > Saqib, You likely have a bug in your CSM. So that is your gEfiLegacyBiosProtocolGuid implementation and all the 16-bit legacy BIOS code. So you should contact the people you got your CSM from. Thanks, Andrew Fish >> On 05-Oct-2016, at 9:05 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote: >> >> >> I have found that it just dont return from mBmRefreshLegacyBootOption (); . >> >> have a look at code. let me know the possible cause of it ... >> I need urgent help >> >> EfiBootManagerRefreshAllBootOption ( >> VOID >> ) >> { >> EFI_STATUS Status; >> EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; >> UINTN NvBootOptionCount; >> EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; >> UINTN BootOptionCount; >> UINTN Index; >> Print(L"indside refresh\n"); >> // >> // Optionally refresh the legacy boot option >> // >> if (mBmRefreshLegacyBootOption != NULL) { >> Print(L"Before legacy refresh \n"); >> mBmRefreshLegacyBootOption (); //this method does not return >> Print(L"legacy refresh complete\n"); >> } >> >>> On Wed, Oct 5, 2016 at 5:51 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote: >>> Hi, >>> >>> when i import both lib in my project my EFI hangs at EfiRefreshAllBootOptions, i removed LegacyBootManager and it worked fine .i need both lib as i need to boot legacy from EFI, how this issue can be resolved? >>> >>> >>> here is piece of inf file >>> >>> [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 >>> >>> >>> -- >>> Regards >>> Saqib Ahmed Khanzada >> >> >> >> -- >> Regards >> Saqib Ahmed Khanzada > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Urgent help -UefiBootManagerLib and LegacyBootManagerLib issue 2016-10-05 21:37 ` Andrew Fish @ 2016-10-06 7:28 ` Saqib Khan 2016-10-06 8:41 ` Laszlo Ersek 0 siblings, 1 reply; 8+ messages in thread From: Saqib Khan @ 2016-10-06 7:28 UTC (permalink / raw) To: Andrew Fish; +Cc: edk2-devel Hi Andrew, I think I did not address my problem well in my previous email.Please take a minute again to understand my problem. here is my scenario have following lib added to my *.inf file [LibraryClasses] HiiLib DebugLib UefiLib MemoryAllocationLib UefiBootServicesTableLib UefiApplicationEntryPoint *UefiBootManagerLib LegacyBootManagerLib* UefiShellLib And here is piece of code I am trying to compile EfiBootManagerConnectAll (); EfiBootManagerRefreshAllBootOption (); BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot); Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios); it Compiles successfully but EFI hangs at *EfiBootManagerRefreshAllBootOption () * When I remove * LegacyBootManagerLib* Libraries it does not hang I think I missing something in it may be i need to add CSM libraries in my EFI? I also tried NULL library resolution in DuetPkgx64.dsc like this MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf { <LibraryClasses> NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf } If you still think that is a CSM issue then i will be go for another system as i am doing my development on physical system. *Thank you* On Thu, Oct 6, 2016 at 2:37 AM, Andrew Fish <afish@apple.com> wrote: > > > On Oct 5, 2016, at 2:23 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote: > > > > > > > > Hi all,i need urgent help regarding this issue. > > > > > Saqib, > > You likely have a bug in your CSM. So that is your > gEfiLegacyBiosProtocolGuid implementation and all the 16-bit legacy BIOS > code. > > So you should contact the people you got your CSM from. > > Thanks, > > Andrew Fish > > >> On 05-Oct-2016, at 9:05 PM, Saqib Khan <saqib.khan2011@gmail.com> > wrote: > >> > >> > >> I have found that it just dont return from mBmRefreshLegacyBootOption > (); . > >> > >> have a look at code. let me know the possible cause of it ... > >> I need urgent help > >> > >> EfiBootManagerRefreshAllBootOption ( > >> VOID > >> ) > >> { > >> EFI_STATUS Status; > >> EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; > >> UINTN NvBootOptionCount; > >> EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > >> UINTN BootOptionCount; > >> UINTN Index; > >> Print(L"indside refresh\n"); > >> // > >> // Optionally refresh the legacy boot option > >> // > >> if (mBmRefreshLegacyBootOption != NULL) { > >> Print(L"Before legacy refresh \n"); > >> mBmRefreshLegacyBootOption (); //this method does not return > >> Print(L"legacy refresh complete\n"); > >> } > >> > >>> On Wed, Oct 5, 2016 at 5:51 PM, Saqib Khan <saqib.khan2011@gmail.com> > wrote: > >>> Hi, > >>> > >>> when i import both lib in my project my EFI hangs at > EfiRefreshAllBootOptions, i removed LegacyBootManager and it worked fine .i > need both lib as i need to boot legacy from EFI, how this issue can be > resolved? > >>> > >>> > >>> here is piece of inf file > >>> > >>> [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 > >>> > >>> > >>> -- > >>> Regards > >>> Saqib Ahmed Khanzada > >> > >> > >> > >> -- > >> Regards > >> Saqib Ahmed Khanzada > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > > -- Regards Saqib Ahmed Khanzada ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Urgent help -UefiBootManagerLib and LegacyBootManagerLib issue 2016-10-06 7:28 ` Saqib Khan @ 2016-10-06 8:41 ` Laszlo Ersek 2016-10-17 9:46 ` Saqib Khan 0 siblings, 1 reply; 8+ messages in thread From: Laszlo Ersek @ 2016-10-06 8:41 UTC (permalink / raw) To: Saqib Khan, Andrew Fish; +Cc: edk2-devel On 10/06/16 09:28, Saqib Khan wrote: > Hi Andrew, > > I think I did not address my problem well in my previous email.Please take > a minute again to understand my problem. > > here is my scenario > > have following lib added to my *.inf file > [LibraryClasses] > HiiLib > DebugLib > UefiLib > MemoryAllocationLib > UefiBootServicesTableLib > UefiApplicationEntryPoint > > *UefiBootManagerLib LegacyBootManagerLib* > UefiShellLib > > And here is piece of code I am trying to compile > > EfiBootManagerConnectAll (); > EfiBootManagerRefreshAllBootOption (); > > BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, > LoadOptionTypeBoot); > > Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) > &LegacyBios); > > it Compiles successfully but EFI hangs at > > *EfiBootManagerRefreshAllBootOption () * > When I remove * LegacyBootManagerLib* Libraries it does not hang > > I think I missing something in it may be i need to add CSM libraries in my > EFI? > > I also tried NULL library resolution in DuetPkgx64.dsc like this > > MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf { > <LibraryClasses> > > NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf > > } > > > If you still think that is a CSM issue then i will be go for another system > as i am doing my development on physical system. > > > *Thank you* Andrew understood your problem just fine, and gave the correct answer. (1) As I explained to you in one of my previous emails (or, well, I at least alluded to it), namely in https://lists.01.org/pipermail/edk2-devel/2016-September/001799.html LegacyBootManagerLib is a *plugin* for UefiBootManagerLib. That is, a library to be used with NULL library class resolution in whatever driver or application that you already use UefiBootManagerLib in. (If you know that your module will always need LegacyBootManagerLib, then you can explicitly specify it in your INF file too.) (2) If you do not add LegacyBootManagerLib to your application like explained above, then the following will happen: - UefiBootManagerLib's EfiBootManagerRegisterLegacyBootSupport() function will never be called, - therefore UefiBootManagerLib's mBmRefreshLegacyBootOption global variable will remain NULL, - therefore EfiBootManagerRefreshAllBootOption() will never call (*mBmRefreshLegacyBootOption)(). (3) In comprison, if you *do* add LegacyBootManagerLib to your application, then the following will happen: - LegacyBootManagerLib's constructor function, namely LegacyBootManagerLibConstructor(), will call EfiBootManagerRegisterLegacyBootSupport(), with the following two function pointers: - LegacyBmRefreshAllBootOption - LegacyBmBoot - In turn, UefiBootManagerLib's mBmRefreshLegacyBootOption will be set to LegacyBmRefreshAllBootOption - In turn, EfiBootManagerRefreshAllBootOption() will call LegacyBmRefreshAllBootOption(), through the mBmRefreshLegacyBootOption function pointer. This is exactly what's happening in your case; it's just that LegacyBmRefreshAllBootOption() -- in file "IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c" -- does not return. (4) Why not? You can find out simply by adding DEBUG statements to the function, and see how far it proceeds. But, as Andrew already said, the only real suspect in that function is Status = LegacyBios->CheckPciRom ( LegacyBios, HandleBuffer[Index], NULL, NULL, &Flags ); which calls into your CSM. So, if that's the function call that doesn't return -- and it likely is --, then the CSM you use has the bug. (5) For the future: please don't give up tracking down bugs so easily. This time you stopped as early as > mBmRefreshLegacyBootOption (); //this method does not return - Well, did you try to see what mBmRefreshLegacyBootOption was? Is there a function declared with this name, somewhere in the tree? Well, no. - Is mBmRefreshLegacyBootOption a function pointer? Yes. - Okay, where is the function pointer set then? In EfiBootManagerRegisterLegacyBootSupport(). - So what calls EfiBootManagerRegisterLegacyBootSupport()? The LegacyBootManagerLibConstructor() function, in file "IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c". - What arguments does LegacyBootManagerLibConstructor() pass? In particular, it passes the address of the function LegacyBmRefreshAllBootOption(). - And now you know what the function call > mBmRefreshLegacyBootOption (); //this method does not return *actually* does, you can add DEBUG statements to it, and track it to the LegacyBios->CheckPciRom() call that invokes your CSM. Laszlo > > On Thu, Oct 6, 2016 at 2:37 AM, Andrew Fish <afish@apple.com> wrote: > >> >>> On Oct 5, 2016, at 2:23 PM, Saqib Khan <saqib.khan2011@gmail.com> wrote: >>> >>> >>> >>> Hi all,i need urgent help regarding this issue. >>> >> >> >> Saqib, >> >> You likely have a bug in your CSM. So that is your >> gEfiLegacyBiosProtocolGuid implementation and all the 16-bit legacy BIOS >> code. >> >> So you should contact the people you got your CSM from. >> >> Thanks, >> >> Andrew Fish >> >>>> On 05-Oct-2016, at 9:05 PM, Saqib Khan <saqib.khan2011@gmail.com> >> wrote: >>>> >>>> >>>> I have found that it just dont return from mBmRefreshLegacyBootOption >> (); . >>>> >>>> have a look at code. let me know the possible cause of it ... >>>> I need urgent help >>>> >>>> EfiBootManagerRefreshAllBootOption ( >>>> VOID >>>> ) >>>> { >>>> EFI_STATUS Status; >>>> EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; >>>> UINTN NvBootOptionCount; >>>> EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; >>>> UINTN BootOptionCount; >>>> UINTN Index; >>>> Print(L"indside refresh\n"); >>>> // >>>> // Optionally refresh the legacy boot option >>>> // >>>> if (mBmRefreshLegacyBootOption != NULL) { >>>> Print(L"Before legacy refresh \n"); >>>> mBmRefreshLegacyBootOption (); //this method does not return >>>> Print(L"legacy refresh complete\n"); >>>> } >>>> >>>>> On Wed, Oct 5, 2016 at 5:51 PM, Saqib Khan <saqib.khan2011@gmail.com> >> wrote: >>>>> Hi, >>>>> >>>>> when i import both lib in my project my EFI hangs at >> EfiRefreshAllBootOptions, i removed LegacyBootManager and it worked fine .i >> need both lib as i need to boot legacy from EFI, how this issue can be >> resolved? >>>>> >>>>> >>>>> here is piece of inf file >>>>> >>>>> [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 >>>>> >>>>> >>>>> -- >>>>> Regards >>>>> Saqib Ahmed Khanzada >>>> >>>> >>>> >>>> -- >>>> Regards >>>> Saqib Ahmed Khanzada >>> _______________________________________________ >>> edk2-devel mailing list >>> edk2-devel@lists.01.org >>> https://lists.01.org/mailman/listinfo/edk2-devel >> >> > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Urgent help -UefiBootManagerLib and LegacyBootManagerLib issue 2016-10-06 8:41 ` Laszlo Ersek @ 2016-10-17 9:46 ` Saqib Khan 2016-10-17 10:57 ` Laszlo Ersek 0 siblings, 1 reply; 8+ messages in thread From: Saqib Khan @ 2016-10-17 9:46 UTC (permalink / raw) To: Laszlo Ersek; +Cc: Andrew Fish, edk2-devel hi,Thank Laszlo and Andrew, here are my findings Below loop in LegacyBM.c iterate 16 times out which 2 times it return success and 14 times it return error code 3 *for (Index = 0; Index < HandleCount; Index++) { // // Start the thunk driver so that the legacy option rom gets dispatched. // Note: We don't directly call InstallPciRom because some thunk drivers // (e.g. BlockIo thunk driver) depend on the immediate result after dispatching // // Print(L"LegacyBmRefreshAllBootOption....: %d\n",Index); Status = LegacyBios->CheckPciRom ( LegacyBios, HandleBuffer[Index], NULL, NULL, &Flags ); if (!EFI_ERROR (Status)) { Print(L"PCI Successfull [%X]\n",Status); gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE); } else { Print(L"PCI fail [%X]\n",Status); } }* should *LegacyBios->CheckPciRom *return always Successful in above loop? After this LegacyBmUpdateDevOrder () is called and inside this method system hang in loop below Ptr = DevOrder; NewPtr = NewDevOrder; NewPtr->BbsType = Ptr->BbsType; NewPtr->Length = (UINT16) (sizeof (UINT16) + FDCount * sizeof (UINT16)); for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) { if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) || LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_FLOPPY ) { // * Print(L"Continure %d\n",Index); it keeps in this loop some time in loop below* continue; } Print(L" \n"); NewPtr->Data[FDIndex] = Ptr->Data[Index]; FDIndex++; } NewFDPtr = NewPtr->Data; On Thu, Oct 6, 2016 at 1:41 PM, Laszlo Ersek <lersek@redhat.com> wrote: > On 10/06/16 09:28, Saqib Khan wrote: > > Hi Andrew, > > > > I think I did not address my problem well in my previous email.Please > take > > a minute again to understand my problem. > > > > here is my scenario > > > > have following lib added to my *.inf file > > [LibraryClasses] > > HiiLib > > DebugLib > > UefiLib > > MemoryAllocationLib > > UefiBootServicesTableLib > > UefiApplicationEntryPoint > > > > *UefiBootManagerLib LegacyBootManagerLib* > > UefiShellLib > > > > And here is piece of code I am trying to compile > > > > EfiBootManagerConnectAll (); > > EfiBootManagerRefreshAllBootOption (); > > > > BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, > > LoadOptionTypeBoot); > > > > Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID > **) > > &LegacyBios); > > > > it Compiles successfully but EFI hangs at > > > > *EfiBootManagerRefreshAllBootOption () * > > When I remove * LegacyBootManagerLib* Libraries it does not hang > > > > I think I missing something in it may be i need to add CSM libraries in > my > > EFI? > > > > I also tried NULL library resolution in DuetPkgx64.dsc like this > > > > MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf { > > <LibraryClasses> > > > > NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/ > LegacyBootManagerLib.inf > > > > } > > > > > > If you still think that is a CSM issue then i will be go for another > system > > as i am doing my development on physical system. > > > > > > *Thank you* > > Andrew understood your problem just fine, and gave the correct answer. > > (1) As I explained to you in one of my previous emails (or, well, I at > least alluded to it), namely in > > https://lists.01.org/pipermail/edk2-devel/2016-September/001799.html > > LegacyBootManagerLib is a *plugin* for UefiBootManagerLib. That is, a > library to be used with NULL library class resolution in whatever driver > or application that you already use UefiBootManagerLib in. (If you know > that your module will always need LegacyBootManagerLib, then you can > explicitly specify it in your INF file too.) > > (2) If you do not add LegacyBootManagerLib to your application like > explained above, then the following will happen: > > - UefiBootManagerLib's EfiBootManagerRegisterLegacyBootSupport() > function will never be called, > > - therefore UefiBootManagerLib's mBmRefreshLegacyBootOption global > variable will remain NULL, > > - therefore EfiBootManagerRefreshAllBootOption() will never call > (*mBmRefreshLegacyBootOption)(). > > (3) In comprison, if you *do* add LegacyBootManagerLib to your > application, then the following will happen: > > - LegacyBootManagerLib's constructor function, namely > LegacyBootManagerLibConstructor(), will call > EfiBootManagerRegisterLegacyBootSupport(), with the following two > function pointers: > - LegacyBmRefreshAllBootOption > - LegacyBmBoot > > - In turn, UefiBootManagerLib's mBmRefreshLegacyBootOption will be set > to LegacyBmRefreshAllBootOption > > - In turn, EfiBootManagerRefreshAllBootOption() will call > LegacyBmRefreshAllBootOption(), through the mBmRefreshLegacyBootOption > function pointer. > > This is exactly what's happening in your case; it's just that > LegacyBmRefreshAllBootOption() -- in file > "IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c" -- > does not return. > > (4) Why not? You can find out simply by adding DEBUG statements to the > function, and see how far it proceeds. But, as Andrew already said, the > only real suspect in that function is > > Status = LegacyBios->CheckPciRom ( > LegacyBios, > HandleBuffer[Index], > NULL, > NULL, > &Flags > ); > > which calls into your CSM. So, if that's the function call that doesn't > return -- and it likely is --, then the CSM you use has the bug. > > (5) For the future: please don't give up tracking down bugs so easily. > This time you stopped as early as > > > mBmRefreshLegacyBootOption (); //this method does not return > > - Well, did you try to see what mBmRefreshLegacyBootOption was? Is there > a function declared with this name, somewhere in the tree? Well, no. > > - Is mBmRefreshLegacyBootOption a function pointer? Yes. > > - Okay, where is the function pointer set then? In > EfiBootManagerRegisterLegacyBootSupport(). > > - So what calls EfiBootManagerRegisterLegacyBootSupport()? The > LegacyBootManagerLibConstructor() function, in file > "IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c". > > - What arguments does LegacyBootManagerLibConstructor() pass? In > particular, it passes the address of the function > LegacyBmRefreshAllBootOption(). > > - And now you know what the function call > > > mBmRefreshLegacyBootOption (); //this method does not return > > *actually* does, you can add DEBUG statements to it, and track it to the > LegacyBios->CheckPciRom() call that invokes your CSM. > > Laszlo > > > > > > On Thu, Oct 6, 2016 at 2:37 AM, Andrew Fish <afish@apple.com> wrote: > > > >> > >>> On Oct 5, 2016, at 2:23 PM, Saqib Khan <saqib.khan2011@gmail.com> > wrote: > >>> > >>> > >>> > >>> Hi all,i need urgent help regarding this issue. > >>> > >> > >> > >> Saqib, > >> > >> You likely have a bug in your CSM. So that is your > >> gEfiLegacyBiosProtocolGuid implementation and all the 16-bit legacy BIOS > >> code. > >> > >> So you should contact the people you got your CSM from. > >> > >> Thanks, > >> > >> Andrew Fish > >> > >>>> On 05-Oct-2016, at 9:05 PM, Saqib Khan <saqib.khan2011@gmail.com> > >> wrote: > >>>> > >>>> > >>>> I have found that it just dont return from > mBmRefreshLegacyBootOption > >> (); . > >>>> > >>>> have a look at code. let me know the possible cause of it ... > >>>> I need urgent help > >>>> > >>>> EfiBootManagerRefreshAllBootOption ( > >>>> VOID > >>>> ) > >>>> { > >>>> EFI_STATUS Status; > >>>> EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; > >>>> UINTN NvBootOptionCount; > >>>> EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > >>>> UINTN BootOptionCount; > >>>> UINTN Index; > >>>> Print(L"indside refresh\n"); > >>>> // > >>>> // Optionally refresh the legacy boot option > >>>> // > >>>> if (mBmRefreshLegacyBootOption != NULL) { > >>>> Print(L"Before legacy refresh \n"); > >>>> mBmRefreshLegacyBootOption (); //this method does not return > >>>> Print(L"legacy refresh complete\n"); > >>>> } > >>>> > >>>>> On Wed, Oct 5, 2016 at 5:51 PM, Saqib Khan <saqib.khan2011@gmail.com > > > >> wrote: > >>>>> Hi, > >>>>> > >>>>> when i import both lib in my project my EFI hangs at > >> EfiRefreshAllBootOptions, i removed LegacyBootManager and it worked > fine .i > >> need both lib as i need to boot legacy from EFI, how this issue can be > >> resolved? > >>>>> > >>>>> > >>>>> here is piece of inf file > >>>>> > >>>>> [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 > >>>>> > >>>>> > >>>>> -- > >>>>> Regards > >>>>> Saqib Ahmed Khanzada > >>>> > >>>> > >>>> > >>>> -- > >>>> Regards > >>>> Saqib Ahmed Khanzada > >>> _______________________________________________ > >>> edk2-devel mailing list > >>> edk2-devel@lists.01.org > >>> https://lists.01.org/mailman/listinfo/edk2-devel > >> > >> > > > > > > -- Regards Saqib Ahmed Khanzada ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Urgent help -UefiBootManagerLib and LegacyBootManagerLib issue 2016-10-17 9:46 ` Saqib Khan @ 2016-10-17 10:57 ` Laszlo Ersek 0 siblings, 0 replies; 8+ messages in thread From: Laszlo Ersek @ 2016-10-17 10:57 UTC (permalink / raw) To: Saqib Khan; +Cc: Andrew Fish, edk2-devel On 10/17/16 11:46, Saqib Khan wrote: > hi,Thank Laszlo and Andrew, here are my findings > > Below loop in LegacyBM.c iterate 16 times out which 2 times it return > success and 14 times it return error code 3 > > *for (Index = 0; Index < HandleCount; Index++) { > // > // Start the thunk driver so that the legacy option rom gets > dispatched. > // Note: We don't directly call InstallPciRom because some thunk > drivers > // (e.g. BlockIo thunk driver) depend on the immediate result > after dispatching > // > // Print(L"LegacyBmRefreshAllBootOption....: %d\n",Index); > Status = LegacyBios->CheckPciRom ( > LegacyBios, > HandleBuffer[Index], > NULL, > NULL, > &Flags > ); > if (!EFI_ERROR (Status)) { > Print(L"PCI Successfull [%X]\n",Status); > gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE); > } > else > { > Print(L"PCI fail [%X]\n",Status); > } > }* > > should *LegacyBios->CheckPciRom *return always Successful in above loop? Value 3 is EFI_UNSUPPORTED, and it means that a legacy PCI ROM does not exist for the device. (See EFI_LEGACY_BIOS_CHECK_ROM in "IntelFrameworkPkg/Include/Protocol/LegacyBios.h".) > After this LegacyBmUpdateDevOrder () is called and inside this method > system hang in loop below > > Ptr = DevOrder; > NewPtr = NewDevOrder; > NewPtr->BbsType = Ptr->BbsType; > NewPtr->Length = (UINT16) (sizeof (UINT16) + FDCount * sizeof (UINT16)); > for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) { > if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) || > LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_FLOPPY > ) { > // *Print(L"Continure %d\n",Index); it keeps in this loop some > time in loop below* > continue; > } > Print(L" \n"); > NewPtr->Data[FDIndex] = Ptr->Data[Index]; > FDIndex++; > } > NewFDPtr = NewPtr->Data; Well, where exactly does it hang in the loop? What are the relevant variable values etc? Thanks Laszlo > > > > On Thu, Oct 6, 2016 at 1:41 PM, Laszlo Ersek <lersek@redhat.com > <mailto:lersek@redhat.com>> wrote: > > On 10/06/16 09:28, Saqib Khan wrote: > > Hi Andrew, > > > > I think I did not address my problem well in my previous email.Please take > > a minute again to understand my problem. > > > > here is my scenario > > > > have following lib added to my *.inf file > > [LibraryClasses] > > HiiLib > > DebugLib > > UefiLib > > MemoryAllocationLib > > UefiBootServicesTableLib > > UefiApplicationEntryPoint > > > > *UefiBootManagerLib LegacyBootManagerLib* > > UefiShellLib > > > > And here is piece of code I am trying to compile > > > > EfiBootManagerConnectAll (); > > EfiBootManagerRefreshAllBootOption (); > > > > BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, > > LoadOptionTypeBoot); > > > > Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) > > &LegacyBios); > > > > it Compiles successfully but EFI hangs at > > > > *EfiBootManagerRefreshAllBootOption () * > > When I remove * LegacyBootManagerLib* Libraries it does not hang > > > > I think I missing something in it may be i need to add CSM libraries in my > > EFI? > > > > I also tried NULL library resolution in DuetPkgx64.dsc like this > > > > MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf { > > <LibraryClasses> > > > > NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf > > > > } > > > > > > If you still think that is a CSM issue then i will be go for another system > > as i am doing my development on physical system. > > > > > > *Thank you* > > Andrew understood your problem just fine, and gave the correct answer. > > (1) As I explained to you in one of my previous emails (or, well, I at > least alluded to it), namely in > > > https://lists.01.org/pipermail/edk2-devel/2016-September/001799.html > <https://lists.01.org/pipermail/edk2-devel/2016-September/001799.html> > > LegacyBootManagerLib is a *plugin* for UefiBootManagerLib. That is, a > library to be used with NULL library class resolution in whatever driver > or application that you already use UefiBootManagerLib in. (If you know > that your module will always need LegacyBootManagerLib, then you can > explicitly specify it in your INF file too.) > > (2) If you do not add LegacyBootManagerLib to your application like > explained above, then the following will happen: > > - UefiBootManagerLib's EfiBootManagerRegisterLegacyBootSupport() > function will never be called, > > - therefore UefiBootManagerLib's mBmRefreshLegacyBootOption global > variable will remain NULL, > > - therefore EfiBootManagerRefreshAllBootOption() will never call > (*mBmRefreshLegacyBootOption)(). > > (3) In comprison, if you *do* add LegacyBootManagerLib to your > application, then the following will happen: > > - LegacyBootManagerLib's constructor function, namely > LegacyBootManagerLibConstructor(), will call > EfiBootManagerRegisterLegacyBootSupport(), with the following two > function pointers: > - LegacyBmRefreshAllBootOption > - LegacyBmBoot > > - In turn, UefiBootManagerLib's mBmRefreshLegacyBootOption will be set > to LegacyBmRefreshAllBootOption > > - In turn, EfiBootManagerRefreshAllBootOption() will call > LegacyBmRefreshAllBootOption(), through the mBmRefreshLegacyBootOption > function pointer. > > This is exactly what's happening in your case; it's just that > LegacyBmRefreshAllBootOption() -- in file > "IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c" -- > does not return. > > (4) Why not? You can find out simply by adding DEBUG statements to the > function, and see how far it proceeds. But, as Andrew already said, the > only real suspect in that function is > > Status = LegacyBios->CheckPciRom ( > LegacyBios, > HandleBuffer[Index], > NULL, > NULL, > &Flags > ); > > which calls into your CSM. So, if that's the function call that doesn't > return -- and it likely is --, then the CSM you use has the bug. > > (5) For the future: please don't give up tracking down bugs so easily. > This time you stopped as early as > > > mBmRefreshLegacyBootOption (); //this method does not return > > - Well, did you try to see what mBmRefreshLegacyBootOption was? Is there > a function declared with this name, somewhere in the tree? Well, no. > > - Is mBmRefreshLegacyBootOption a function pointer? Yes. > > - Okay, where is the function pointer set then? In > EfiBootManagerRegisterLegacyBootSupport(). > > - So what calls EfiBootManagerRegisterLegacyBootSupport()? The > LegacyBootManagerLibConstructor() function, in file > "IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c". > > - What arguments does LegacyBootManagerLibConstructor() pass? In > particular, it passes the address of the function > LegacyBmRefreshAllBootOption(). > > - And now you know what the function call > > > mBmRefreshLegacyBootOption (); //this method does not return > > *actually* does, you can add DEBUG statements to it, and track it to the > LegacyBios->CheckPciRom() call that invokes your CSM. > > Laszlo > > > > > > On Thu, Oct 6, 2016 at 2:37 AM, Andrew Fish <afish@apple.com > <mailto:afish@apple.com>> wrote: > > > >> > >>> On Oct 5, 2016, at 2:23 PM, Saqib Khan <saqib.khan2011@gmail.com > <mailto:saqib.khan2011@gmail.com>> wrote: > >>> > >>> > >>> > >>> Hi all,i need urgent help regarding this issue. > >>> > >> > >> > >> Saqib, > >> > >> You likely have a bug in your CSM. So that is your > >> gEfiLegacyBiosProtocolGuid implementation and all the 16-bit > legacy BIOS > >> code. > >> > >> So you should contact the people you got your CSM from. > >> > >> Thanks, > >> > >> Andrew Fish > >> > >>>> On 05-Oct-2016, at 9:05 PM, Saqib Khan > <saqib.khan2011@gmail.com <mailto:saqib.khan2011@gmail.com>> > >> wrote: > >>>> > >>>> > >>>> I have found that it just dont return from > mBmRefreshLegacyBootOption > >> (); . > >>>> > >>>> have a look at code. let me know the possible cause of it ... > >>>> I need urgent help > >>>> > >>>> EfiBootManagerRefreshAllBootOption ( > >>>> VOID > >>>> ) > >>>> { > >>>> EFI_STATUS Status; > >>>> EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; > >>>> UINTN NvBootOptionCount; > >>>> EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > >>>> UINTN BootOptionCount; > >>>> UINTN Index; > >>>> Print(L"indside refresh\n"); > >>>> // > >>>> // Optionally refresh the legacy boot option > >>>> // > >>>> if (mBmRefreshLegacyBootOption != NULL) { > >>>> Print(L"Before legacy refresh \n"); > >>>> mBmRefreshLegacyBootOption (); //this method does not return > >>>> Print(L"legacy refresh complete\n"); > >>>> } > >>>> > >>>>> On Wed, Oct 5, 2016 at 5:51 PM, Saqib Khan > <saqib.khan2011@gmail.com <mailto:saqib.khan2011@gmail.com>> > >> wrote: > >>>>> Hi, > >>>>> > >>>>> when i import both lib in my project my EFI hangs at > >> EfiRefreshAllBootOptions, i removed LegacyBootManager and it > worked fine .i > >> need both lib as i need to boot legacy from EFI, how this issue > can be > >> resolved? > >>>>> > >>>>> > >>>>> here is piece of inf file > >>>>> > >>>>> [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 > >>>>> > >>>>> > >>>>> -- > >>>>> Regards > >>>>> Saqib Ahmed Khanzada > >>>> > >>>> > >>>> > >>>> -- > >>>> Regards > >>>> Saqib Ahmed Khanzada > >>> _______________________________________________ > >>> edk2-devel mailing list > >>> edk2-devel@lists.01.org <mailto:edk2-devel@lists.01.org> > >>> https://lists.01.org/mailman/listinfo/edk2-devel > <https://lists.01.org/mailman/listinfo/edk2-devel> > >> > >> > > > > > > > > > -- > Regards > Saqib Ahmed Khanzada ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-10-17 10:58 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-10-05 12:51 UefiBootManagerLib and LegacyBootManagerLib issue Saqib Khan 2016-10-05 16:05 ` Saqib Khan 2016-10-05 21:23 ` Urgent help -UefiBootManagerLib " Saqib Khan 2016-10-05 21:37 ` Andrew Fish 2016-10-06 7:28 ` Saqib Khan 2016-10-06 8:41 ` Laszlo Ersek 2016-10-17 9:46 ` Saqib Khan 2016-10-17 10:57 ` Laszlo Ersek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox