+/**\r
+ Create all handles associate with every device path node.\r
+\r
+ @param DevicePathToConnect The device path which will be connected.\r
+\r
+ @retval EFI_SUCCESS All handles associate with every device path node\r
+ have been created.\r
+ @retval EFI_INVALID_PARAMETER DevicePathToConnect is NULL.\r
+ @retval EFI_NOT_FOUND Create the handle associate with one device path\r
+ node failed\r
+\r
+**/\r
+EFI_STATUS\r
+ShellConnectDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect\r
+ )\r
+{\r
+ 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
+ PreviousHandle = NULL;\r
+ do{ \r
+ RemainingDevicePath = DevicePathToConnect;\r
+ Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);\r
+ \r
+ if (!EFI_ERROR (Status) && (Handle != NULL)) {\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
+ \r
+ } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath) );\r
+ \r
+ return Status;\r
+ \r
+}\r
+\r
+/**\r
+ Connect drivers for PCI root bridge.\r
+ \r
+ @retval EFI_SUCCESS Connect drivers successfully.\r
+ @retval EFI_NOT_FOUND Cannot find PCI root bridge device.\r
+\r
+**/\r
+EFI_STATUS\r
+ShellConnectPciRootBridge (\r
+ VOID\r
+ )\r
+{ \r
+ UINTN RootBridgeHandleCount;\r
+ EFI_HANDLE *RootBridgeHandleBuffer;\r
+ UINTN RootBridgeIndex;\r
+ EFI_STATUS Status;\r
+ \r
+ RootBridgeHandleCount = 0;\r
+ \r
+ Status = gBS->LocateHandleBuffer ( \r
+ ByProtocol, \r
+ &gEfiPciRootBridgeIoProtocolGuid, \r
+ NULL, \r
+ &RootBridgeHandleCount, \r
+ &RootBridgeHandleBuffer \r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ \r
+ for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) { \r
+ gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, FALSE); \r
+ } \r
+\r
+ FreePool (RootBridgeHandleBuffer);\r
+ \r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r