EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;\r
EFI_STATUS Status;\r
EFI_HANDLE Handle;\r
+ EFI_HANDLE PreviousHandle;\r
\r
if (DevicePathToConnect == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- \r
- do{\r
+\r
+ PreviousHandle = NULL;\r
+ do{ \r
RemainingDevicePath = DevicePathToConnect;\r
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);\r
+ \r
if (!EFI_ERROR (Status) && (Handle != NULL)) {\r
- Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);\r
+ if (PreviousHandle == Handle) {\r
+ Status = EFI_NOT_FOUND;\r
+ } else {\r
+ PreviousHandle = Handle;\r
+ Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);\r
+ }\r
}\r
- } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));\r
-\r
+ \r
+ } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath) );\r
+ \r
return Status;\r
\r
}\r
)\r
{\r
EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
- EFI_DEVICE_PATH_PROTOCOL *DevPathWalker;\r
- EFI_DEVICE_PATH_PROTOCOL *Instance;\r
+ EFI_DEVICE_PATH_PROTOCOL *CopyOfDevPath;\r
+ EFI_DEVICE_PATH_PROTOCOL *Instance; \r
+ EFI_DEVICE_PATH_PROTOCOL *Next;\r
UINTN Length;\r
UINTN Index;\r
UINTN HandleArrayCount;\r
+ UINTN Size;\r
EFI_HANDLE *HandleArray;\r
EFI_STATUS Status;\r
BOOLEAN AtLeastOneConnected;\r
DevPath = NULL;\r
Length = 0;\r
AtLeastOneConnected = FALSE;\r
- \r
+\r
//\r
// Get the DevicePath buffer from the variable...\r
//\r
return EFI_OUT_OF_RESOURCES;\r
}\r
Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);\r
+ if (EFI_ERROR (Status)) {\r
+ if (DevPath != NULL) {\r
+ FreePool (DevPath);\r
+ }\r
+ return Status;\r
+ }\r
+ } else if (EFI_ERROR (Status)) {\r
+ return Status;\r
}\r
\r
Status = EFI_NOT_FOUND;\r
+\r
+ CopyOfDevPath = DevPath;\r
//\r
// walk the list of devices and connect them\r
//\r
- for (DevPathWalker = DevPath\r
- ; DevPathWalker < (DevPath + Length) && EFI_ERROR(Status) && DevPath != NULL\r
- ; DevPathWalker += GetDevicePathSize(DevPathWalker)\r
- ){\r
+ do {\r
+ //\r
+ // Check every instance of the console variable\r
+ //\r
+ Instance = GetNextDevicePathInstance (&CopyOfDevPath, &Size);\r
+ if (Instance == NULL) {\r
+ if (DevPath != NULL) {\r
+ FreePool (DevPath);\r
+ }\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Next = Instance;\r
+ while (!IsDevicePathEndType (Next)) {\r
+ Next = NextDevicePathNode (Next);\r
+ }\r
+\r
+ SetDevicePathEndNode (Next);\r
//\r
// connect short form device path\r
//\r
- if ((DevicePathType (DevPathWalker) == MESSAGING_DEVICE_PATH) &&\r
- ((DevicePathSubType (DevPathWalker) == MSG_USB_CLASS_DP)\r
- || (DevicePathSubType (DevPathWalker) == MSG_USB_WWID_DP)\r
+ if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&\r
+ ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)\r
+ || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)\r
)) {\r
- Instance = DuplicateDevicePath (DevPathWalker);\r
- if (Instance == NULL) {\r
- FreePool(DevPath);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
\r
Status = ShellConnectPciRootBridge ();\r
if (EFI_ERROR(Status)) {\r
+ FreePool(Instance);\r
FreePool(DevPath);\r
return Status;\r
}\r
if (HandleArray != NULL) {\r
FreePool (HandleArray);\r
}\r
- FreePool (Instance); \r
} else { \r
//\r
// connect the entire device path\r
//\r
- Instance = DuplicateDevicePath (DevPathWalker); \r
- if (Instance == NULL) {\r
- FreePool(DevPath);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
Status = ShellConnectDevicePath (Instance);\r
if (!EFI_ERROR (Status)) {\r
AtLeastOneConnected = TRUE;\r
}\r
- \r
- FreePool (Instance);\r
}\r
+ FreePool (Instance);\r
\r
- }\r
+ } while (CopyOfDevPath != NULL);\r
\r
if (DevPath != NULL) {\r
FreePool(DevPath);\r
UINT64 Intermediate;\r
\r
ShellStatus = SHELL_SUCCESS;\r
-\r
//\r
// initialize the shell lib (we must be in non-auto-init...)\r
//\r