/* The ConnectDevicePath() function allows the caller to connect a DevicePath using the same policy as the EFI Boot Manger. */
EFI_STATUS EFIAPI BootManagerPolicyConnectDevicePath(IN EFI_BOOT_MANAGER_POLICY_PROTOCOL *This, IN EFI_DEVICE_PATH *DevicePath, IN BOOLEAN Recursive)
/* The ConnectDevicePath() function allows the caller to connect a DevicePath using the same policy as the EFI Boot Manger. */
EFI_STATUS EFIAPI BootManagerPolicyConnectDevicePath(IN EFI_BOOT_MANAGER_POLICY_PROTOCOL *This, IN EFI_DEVICE_PATH *DevicePath, IN BOOLEAN Recursive)
{
  EFI_STATUS  Status;
  EFI_HANDLE  Controller;
  if (EfiGetCurrentTpl () != TPL_APPLICATION) {
    return EFI_UNSUPPORTED;
  }
  if (DevicePath == NULL) {
    EfiBootManagerConnectAll ();
    return EFI_SUCCESS;
  }
  if (Recursive) {
    Status = EfiBootManagerConnectDevicePath (DevicePath, NULL);
  } else {
    Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, &Controller);
    if (!EFI_ERROR (Status)) {
      Status = gBS->ConnectController (Controller, NULL, DevicePath, FALSE);
    }
  }
  return Status;
}