Hi,

Using the SafeOpenProtocolLib in an application which basically does a
BY_DRIVER open if it can, if not then a BY_DRIVER | EXCLUSIVE to force
things off if it can, if that works then when it closes the protocol it
also calls reconnect().  A few things based on that...

1 - Media Paths Can't be opened (BY_HANDLE they can) - no big deal for me.

2 - Opening Disk IO Protocol fails (Block IO opened prior ok)

3 - Having a system lock up when reconnect is called if you don't do the
LocateHandleBuffer first.  See the following proof (z can be set to
different values but failure is always there at the reopen).  The same type
of issue occurs if you disconnect then reconnect a USB drive after the
following if it the reopen is commented out.  So what's going on here???

// MotherBoard: Intel DH77KC
// BIOS: KCH7710H,86A,0108.2013.0305.1638
// ALSO NOTE: No ATA Pass Thru protocol seems to be available for a SATA HD.

#define UEFI_BS gBS
void ScanDevicesProof()
{
  EFI_HANDLE savehandle;
  SAFE_OPEN_PROTOCOL_LIB_HANDLE *safeblockhandle;
  EFI_BLOCK_IO_PROTOCOL *blkio;
  UINTN handlecount;
  EFI_HANDLE *handlepointer;
  EFI_STATUS status;
  UINT z;
  UINT i;

  for (z=0;z<2;z++) {
    printf("***Next Z****\n");
    status=UEFI_BS->LocateHandleBuffer(ByProtocol,
&gEfiBlockIoProtocolGuid, NULL, &handlecount, &handlepointer);
    if (!EFI_ERROR(status)) {
      for (i=0; i<handlecount; i++) {
        printf("open %p...", handlepointer[i]);
        if ((safeblockhandle=SafeOpenProtocol(handlepointer[i],
&gEfiBlockIoProtocolGuid, (void**) &blkio, NULL))!=NULL) {
          // save first handle for reopen
          if (i==0) {
            savehandle=handlepointer[i];
          }
          printf("ok  closing...");
          SafeCloseProtocol(safeblockhandle);
          printf("ok\n");
        }
        else printf("fail\n");
      }
      UEFI_BS->FreePool(handlepointer);
    }
  }

  // open it and close it now
  printf(">>>>>>> reopen (%p)...", savehandle);
  if ((safeblockhandle=SafeOpenProtocol(savehandle,
&gEfiBlockIoProtocolGuid, (void**) &blkio, NULL))!=NULL) {
    printf("ok  closing...");
    SafeCloseProtocol(safeblockhandle);  // <<<<<<<<<<<<<<< HANG ON
RECONNECT
    printf("ok\n");
  }
  else printf("fail\n");
  printf("done\n");
}
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to