/* Create all handles associate with every device path node. */
EFI_STATUS ShellConnectDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect)
/* Create all handles associate with every device path node. */
EFI_STATUS ShellConnectDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect)
{
  EFI_DEVICE_PATH_PROTOCOL  *RemainingDevicePath;
  EFI_STATUS                Status;
  EFI_HANDLE                Handle;
  EFI_HANDLE                PreviousHandle;
  if (DevicePathToConnect == NULL) {
    return EFI_INVALID_PARAMETER;
  }
  PreviousHandle = NULL;
  do {
    RemainingDevicePath = DevicePathToConnect;
    Status              = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
    if (!EFI_ERROR (Status) && (Handle != NULL)) {
      if (PreviousHandle == Handle) {
        Status = EFI_NOT_FOUND;
      } else {
        PreviousHandle = Handle;
        Status         = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
      }
    }
  } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
  return Status;
}