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
  }
...
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to