/* This function will connect all current system handles recursively. The connection will finish until every handle's child handle created if it have. */
EFI_STATUS ConnectAllEfi(VOID)
/* This function will connect all current system handles recursively. The connection will finish until every handle's child handle created if it have. */
EFI_STATUS ConnectAllEfi(VOID)
{
  EFI_STATUS  Status;
  UINTN       HandleCount;
  EFI_HANDLE  *HandleBuffer;
  UINTN       Index;
  Status = gBS->LocateHandleBuffer (
                  AllHandles,
                  NULL,
                  NULL,
                  &HandleCount,
                  &HandleBuffer
                  );
  if (EFI_ERROR (Status)) {
    return Status;
  }
  for (Index = 0; Index < HandleCount; Index++) {
    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
  }
  if (HandleBuffer != NULL) {
    FreePool (HandleBuffer);
  }
  return EFI_SUCCESS;
}