public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* UEFI Shell Lib Constructor and Shell Parameters Protocol
@ 2017-04-05 14:07 Jim.Dailey
  2017-04-05 15:08 ` Carsey, Jaben
  0 siblings, 1 reply; 5+ messages in thread
From: Jim.Dailey @ 2017-04-05 14:07 UTC (permalink / raw)
  To: jaben.carsey, ruiyu.ni; +Cc: edk2-devel


A question or two for all shell experts:

In the UEFI Shell Lib constructor code, if the Shell protocol cannot
be opened, then an attempt is made to locate it before "giving up".

However, if the Shell parameters protocol cannot be opened, no attempt
is made to locate it---the code simply leaves the parameters protocol
pointer set to NULL. Can anyone explain why this is?

I came across an app that crashes because of this behavior, but if I
add code to try and locate the parameters protocol, then the app works
as designed WRT accessing command line parameters.  Is there some
lurking issue if an attempt to locate the parameters protocol is made
and is successful?

Thanks,
Jim

-------
Here is the relevant code:

EFI_STATUS
ShellLibConstructorWorker (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  EFI_STATUS  Status;

  //
  // UEFI 2.0 shell interfaces (used preferentially)
  //
  Status = gBS->OpenProtocol(
    ImageHandle,
    &gEfiShellProtocolGuid,
    (VOID **)&gEfiShellProtocol,
    ImageHandle,
    NULL,
    EFI_OPEN_PROTOCOL_GET_PROTOCOL
   );
  if (EFI_ERROR(Status)) {
    //
    // Search for the shell protocol
    //
    Status = gBS->LocateProtocol(
      &gEfiShellProtocolGuid,
      NULL,
      (VOID **)&gEfiShellProtocol
     );
    if (EFI_ERROR(Status)) {
      gEfiShellProtocol = NULL;
    }
  }
  Status = gBS->OpenProtocol(
    ImageHandle,
    &gEfiShellParametersProtocolGuid,
    (VOID **)&gEfiShellParametersProtocol,
    ImageHandle,
    NULL,
    EFI_OPEN_PROTOCOL_GET_PROTOCOL
   );
  if (EFI_ERROR(Status)) {
#if 1 // _Dell_ : Search for the parameters protocol too!
    //
    // Search for the shell parameters protocol
    //
    Status = gBS->LocateProtocol(
      &gEfiShellParametersProtocolGuid,
      NULL,
      (VOID **)&gEfiShellParametersProtocol
     );
    if (EFI_ERROR(Status)) {
      gEfiShellParametersProtocol = NULL;
    }
#else
    gEfiShellParametersProtocol = NULL;
#endif
  }
...


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

end of thread, other threads:[~2017-04-05 16:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-05 14:07 UEFI Shell Lib Constructor and Shell Parameters Protocol Jim.Dailey
2017-04-05 15:08 ` Carsey, Jaben
2017-04-05 15:21   ` Jim.Dailey
2017-04-05 16:08     ` Carsey, Jaben
2017-04-05 16:39     ` Tim Lewis

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