]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issue that consplitter should not touch ConIn variable & do ConIn connection
authorczhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Aug 2012 07:36:56 +0000 (07:36 +0000)
committerczhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Aug 2012 07:36:56 +0000 (07:36 +0000)
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by  : Hot Tian <hot.tian@intel.com>
Reviewed-by  : Ni, Ruiyu <ruiyu.ni@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13644 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c
IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h

index 422666abe0bf8f7e5fe10b8fe31f7d2f6f730eaa..b1887b60cae0ca34e5009cca49d84efe4c343b73 100644 (file)
@@ -386,9 +386,10 @@ BdsLibConnectAll (
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
-  This function creates all handles associated with the given device\r
-  path node. If the handle associated with one device path node cannot\r
-  be created, then it tries to execute the dispatch to load the missing drivers.  \r
+  This function will create all handles associate with every device\r
+  path node. If the handle associate with one device path node can not\r
+  be created successfully, then still give chance to do the dispatch,\r
+  which load the missing drivers if possible.\r
 \r
   @param  DevicePathToConnect   The device path to be connected. Can be\r
                                 a multi-instance device path.\r
 \r
   @param  DevicePathToConnect   The device path to be connected. Can be\r
                                 a multi-instance device path.\r
@@ -507,17 +508,21 @@ BdsLibUpdateConsoleVariable (
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
-  Connect the console device base on the variable ConVarName. If\r
-  ConVarName is a multi-instance device path, and at least one\r
-  instance connects successfully, then this function\r
+  Connect the console device base on the variable ConVarName, if\r
+  device path of the ConVarName is multi-instance device path and\r
+  anyone of the instances is connected success, then this function\r
   will return success.\r
   will return success.\r
+  If the handle associate with one device path node can not\r
+  be created successfully, then still give chance to do the dispatch,\r
+  which load the missing drivers if possible.\r
 \r
 \r
-  @param  ConVarName               The console related variable name: ConIn, ConOut,\r
+  @param  ConVarName               Console related variable name, ConIn, ConOut,\r
                                    ErrOut.\r
 \r
                                    ErrOut.\r
 \r
-  @retval EFI_NOT_FOUND            No console devices were connected successfully\r
-  @retval EFI_SUCCESS              Connected at least one instance of the console\r
-                                   device path based on the variable ConVarName.\r
+  @retval EFI_NOT_FOUND            There is not any console devices connected\r
+                                   success\r
+  @retval EFI_SUCCESS              Success connect any one instance of the console\r
+                                   device path base on the variable ConVarName.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -526,6 +531,30 @@ BdsLibConnectConsoleVariable (
   IN  CHAR16                 *ConVarName\r
   );\r
 \r
   IN  CHAR16                 *ConVarName\r
   );\r
 \r
+/**\r
+  Connect the console device base on the variable ConVarName, if\r
+  device path of the ConVarName is multi-instance device path and\r
+  anyone of the instances is connected success, then this function\r
+  will return success. \r
+  Dispatch service is not called when the handle associate with one \r
+  device path node can not be created successfully. Here no driver \r
+  dependency is assumed exist, so need not to call this service.\r
+\r
+  @param  ConVarName               Console related variable name, ConIn, ConOut,\r
+                                   ErrOut.\r
+\r
+  @retval EFI_NOT_FOUND            There is not any console devices connected\r
+                                   success\r
+  @retval EFI_SUCCESS              Success connect any one instance of the console\r
+                                   device path base on the variable ConVarName.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectConsoleVariableWithOutDispatch (\r
+  IN  CHAR16                 *ConVarName\r
+  );\r
+\r
 //\r
 // Bds device path related lib functions\r
 //\r
 //\r
 // Bds device path related lib functions\r
 //\r
index fe96e2c098cc2269b5950544ac4e0461de022e5f..0e456dd516ae83609b6e242cc1b9988cd879844b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   BDS Lib functions which relate with connect the device\r
 \r
 /** @file\r
   BDS Lib functions which relate with connect the device\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -69,11 +69,13 @@ BdsLibGenericConnectAll (
 /**\r
   This function will create all handles associate with every device\r
   path node. If the handle associate with one device path node can not\r
 /**\r
   This function will create all handles associate with every device\r
   path node. If the handle associate with one device path node can not\r
-  be created success, then still give one chance to do the dispatch,\r
-  which load the missing drivers if possible.\r
+  be created successfully, Dispatch service which load the missing drivers\r
+  is called according to input parameter, since in some cases no driver \r
+  dependency is assumed exist, so may need not to call this service.\r
 \r
   @param  DevicePathToConnect   The device path which will be connected, it can be\r
                                 a multi-instance device path\r
 \r
   @param  DevicePathToConnect   The device path which will be connected, it can be\r
                                 a multi-instance device path\r
+  @param  NeedDispatch          Whether requires dispatch service during connection \r
 \r
   @retval EFI_SUCCESS           All handles associate with every device path  node\r
                                 have been created\r
 \r
   @retval EFI_SUCCESS           All handles associate with every device path  node\r
                                 have been created\r
@@ -83,9 +85,9 @@ BdsLibGenericConnectAll (
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
+ConnectDevicePathInternal (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect,\r
+  IN BOOLEAN                   NeedDispatch\r
   )\r
 {\r
   EFI_STATUS                Status;\r
   )\r
 {\r
   EFI_STATUS                Status;\r
@@ -150,7 +152,15 @@ BdsLibConnectDevicePath (
           // Status == EFI_SUCCESS means a driver was dispatched\r
           // Status == EFI_NOT_FOUND means no new drivers were dispatched\r
           //\r
           // Status == EFI_SUCCESS means a driver was dispatched\r
           // Status == EFI_NOT_FOUND means no new drivers were dispatched\r
           //\r
-          Status = gDS->Dispatch ();\r
+          if (NeedDispatch) {\r
+            Status = gDS->Dispatch ();\r
+          } else {\r
+            //\r
+            // Always return EFI_NOT_FOUND here\r
+            // to prevent dead loop when control handle is found but connection failded case\r
+            //\r
+            Status = EFI_NOT_FOUND;\r
+          }\r
         }\r
 \r
         if (!EFI_ERROR (Status)) {\r
         }\r
 \r
         if (!EFI_ERROR (Status)) {\r
@@ -190,6 +200,31 @@ BdsLibConnectDevicePath (
 }\r
 \r
 \r
 }\r
 \r
 \r
+/**\r
+  This function will create all handles associate with every device\r
+  path node. If the handle associate with one device path node can not\r
+  be created successfully, then still give chance to do the dispatch,\r
+  which load the missing drivers if possible.\r
+\r
+  @param  DevicePathToConnect   The device path which will be connected, it can be\r
+                                a multi-instance device path\r
+\r
+  @retval EFI_SUCCESS           All handles associate with every device path  node\r
+                                have been created\r
+  @retval EFI_OUT_OF_RESOURCES  There is no resource to create new handles\r
+  @retval EFI_NOT_FOUND         Create the handle associate with one device  path\r
+                                node failed\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
+  )\r
+{\r
+  return ConnectDevicePathInternal(DevicePathToConnect, TRUE);\r
+}\r
+\r
 /**\r
   This function will connect all current system handles recursively. \r
   \r
 /**\r
   This function will connect all current system handles recursively. \r
   \r
index 280b1697b6421733dccbfa2ee502e4bd741ae47a..782c4a5ce1ecfd36d4a8ee606434891276b94429 100644 (file)
@@ -171,6 +171,114 @@ UpdateSystemTableConsole (
   return FALSE;\r
 }\r
 \r
   return FALSE;\r
 }\r
 \r
+/**\r
+  Connect the console device base on the variable ConVarName, if\r
+  device path of the ConVarName is multi-instance device path and\r
+  anyone of the instances is connected success, this function will\r
+  return success. \r
+  Dispatch service is called basing on input when the handle associate\r
+  with one device path node can not be created successfully. Since in\r
+  some cases we assume driver dependency does not exist and do not \r
+  need to call this service.\r
+\r
+  @param  ConVarName               Console related variable name, ConIn, ConOut,\r
+                                   ErrOut.\r
+  @param  NeedDispatch              Whether requires dispatch service during connection \r
+\r
+  @retval EFI_NOT_FOUND            There is not any console devices connected\r
+                                   success\r
+  @retval EFI_SUCCESS              Success connect any one instance of the console\r
+                                   device path base on the variable ConVarName.\r
+\r
+**/\r
+EFI_STATUS\r
+ConnectConsoleVariableInternal (\r
+  IN  CHAR16                 *ConVarName,\r
+  IN  BOOLEAN                NeedDispatch\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *StartDevicePath;\r
+  UINTN                     VariableSize;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Next;\r
+  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;\r
+  UINTN                     Size;\r
+  BOOLEAN                   DeviceExist;\r
+\r
+  Status      = EFI_SUCCESS;\r
+  DeviceExist = FALSE;\r
+\r
+  //\r
+  // Check if the console variable exist\r
+  //\r
+  StartDevicePath = BdsLibGetVariableAndSize (\r
+                      ConVarName,\r
+                      &gEfiGlobalVariableGuid,\r
+                      &VariableSize\r
+                      );\r
+  if (StartDevicePath == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  CopyOfDevicePath = StartDevicePath;\r
+  do {\r
+    //\r
+    // Check every instance of the console variable\r
+    //\r
+    Instance  = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);\r
+    if (Instance == NULL) {\r
+      FreePool (StartDevicePath);\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 the USB console\r
+    // USB console device path is a short-form device path that \r
+    //  starts with the first element being a USB WWID\r
+    //  or a USB Class device path\r
+    //\r
+    if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&\r
+       ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)\r
+       || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)\r
+       )) {\r
+      Status = BdsLibConnectUsbDevByShortFormDP (0xFF, Instance);\r
+      if (!EFI_ERROR (Status)) {\r
+        DeviceExist = TRUE;\r
+      }\r
+    } else {\r
+      //\r
+      // Connect the instance device path\r
+      //\r
+      Status = ConnectDevicePathInternal (Instance, NeedDispatch);\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        //\r
+        // Delete the instance from the console varialbe\r
+        //\r
+        BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);\r
+      } else {\r
+        DeviceExist = TRUE;\r
+      }\r
+    }\r
+    FreePool(Instance);\r
+  } while (CopyOfDevicePath != NULL);\r
+\r
+  FreePool (StartDevicePath);\r
+\r
+  if (!DeviceExist) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   This function update console variable based on ConVarName, it can\r
   add or remove one specific console device path from the variable\r
 /**\r
   This function update console variable based on ConVarName, it can\r
   add or remove one specific console device path from the variable\r
@@ -307,9 +415,12 @@ BdsLibUpdateConsoleVariable (
 \r
 /**\r
   Connect the console device base on the variable ConVarName, if\r
 \r
 /**\r
   Connect the console device base on the variable ConVarName, if\r
-  device path of the ConVarName is multi-instance device path, if\r
+  device path of the ConVarName is multi-instance device path and\r
   anyone of the instances is connected success, then this function\r
   will return success.\r
   anyone of the instances is connected success, then this function\r
   will return success.\r
+  If the handle associate with one device path node can not\r
+  be created successfully, then still give chance to do the dispatch,\r
+  which load the missing drivers if possible..\r
 \r
   @param  ConVarName               Console related variable name, ConIn, ConOut,\r
                                    ErrOut.\r
 \r
   @param  ConVarName               Console related variable name, ConIn, ConOut,\r
                                    ErrOut.\r
@@ -326,88 +437,37 @@ BdsLibConnectConsoleVariable (
   IN  CHAR16                 *ConVarName\r
   )\r
 {\r
   IN  CHAR16                 *ConVarName\r
   )\r
 {\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *StartDevicePath;\r
-  UINTN                     VariableSize;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Next;\r
-  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;\r
-  UINTN                     Size;\r
-  BOOLEAN                   DeviceExist;\r
-\r
-  Status      = EFI_SUCCESS;\r
-  DeviceExist = FALSE;\r
+  return ConnectConsoleVariableInternal(ConVarName, TRUE);\r
+}\r
 \r
 \r
-  //\r
-  // Check if the console variable exist\r
-  //\r
-  StartDevicePath = BdsLibGetVariableAndSize (\r
-                      ConVarName,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &VariableSize\r
-                      );\r
-  if (StartDevicePath == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
+/**\r
+  Connect the console device base on the variable ConVarName, if\r
+  device path of the ConVarName is multi-instance device path and\r
+  anyone of the instances is connected success, then this function\r
+  will return success.\r
+  Dispatch service is not called when the handle associate with one \r
+  device path node can not be created successfully. Here no driver \r
+  dependency is assumed exist, so need not to call this service.\r
 \r
 \r
-  CopyOfDevicePath = StartDevicePath;\r
-  do {\r
-    //\r
-    // Check every instance of the console variable\r
-    //\r
-    Instance  = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);\r
-    if (Instance == NULL) {\r
-      FreePool (StartDevicePath);\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    \r
-    Next      = Instance;\r
-    while (!IsDevicePathEndType (Next)) {\r
-      Next = NextDevicePathNode (Next);\r
-    }\r
 \r
 \r
-    SetDevicePathEndNode (Next);\r
-    //\r
-    // Connect the USB console\r
-    // USB console device path is a short-form device path that \r
-    //  starts with the first element being a USB WWID\r
-    //  or a USB Class device path\r
-    //\r
-    if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&\r
-       ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)\r
-       || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)\r
-       )) {\r
-      Status = BdsLibConnectUsbDevByShortFormDP (0xFF, Instance);\r
-      if (!EFI_ERROR (Status)) {\r
-        DeviceExist = TRUE;\r
-      }\r
-    } else {\r
-      //\r
-      // Connect the instance device path\r
-      //\r
-      Status = BdsLibConnectDevicePath (Instance);\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // Delete the instance from the console varialbe\r
-        //\r
-        BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);\r
-      } else {\r
-        DeviceExist = TRUE;\r
-      }\r
-    }\r
-    FreePool(Instance);\r
-  } while (CopyOfDevicePath != NULL);\r
-\r
-  FreePool (StartDevicePath);\r
+  @param  ConVarName               Console related variable name, ConIn, ConOut,\r
+                                   ErrOut.\r
 \r
 \r
-  if (!DeviceExist) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
+  @retval EFI_NOT_FOUND            There is not any console devices connected\r
+                                   success\r
+  @retval EFI_SUCCESS              Success connect any one instance of the console\r
+                                   device path base on the variable ConVarName.\r
 \r
 \r
-  return EFI_SUCCESS;\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectConsoleVariableWithOutDispatch (\r
+  IN  CHAR16                 *ConVarName\r
+  )\r
+{\r
+  return ConnectConsoleVariableInternal(ConVarName, FALSE);\r
 }\r
 \r
 }\r
 \r
-\r
 /**\r
   This function will search every simpletext device in current system,\r
   and make every simpletext device as pertantial console device.\r
 /**\r
   This function will search every simpletext device in current system,\r
   and make every simpletext device as pertantial console device.\r
index 7381670bf296e185a400a273ad06b45e31750e49..d5b5b3bd0208c5384dd73779562952f506f7a776 100644 (file)
@@ -158,4 +158,28 @@ ValidateOption (
   UINTN                     VariableSize\r
   );\r
 \r
   UINTN                     VariableSize\r
   );\r
 \r
+/**\r
+  This function will create all handles associate with every device\r
+  path node. If the handle associate with one device path node can not\r
+  be created successfully, Dispatch service which load the missing drivers\r
+  is called basing on input parameter, since in some cases no driver \r
+  dependency is assumed exist, so may need not to call this service.\r
+\r
+  @param  DevicePathToConnect   The device path which will be connected, it can be\r
+                                a multi-instance device path\r
+  @param  NeedDispatch          Whether requires dispatch service during connection \r
+\r
+  @retval EFI_SUCCESS           All handles associate with every device path  node\r
+                                have been created\r
+  @retval EFI_OUT_OF_RESOURCES  There is no resource to create new handles\r
+  @retval EFI_NOT_FOUND         Create the handle associate with one device  path\r
+                                node failed\r
+\r
+**/\r
+EFI_STATUS\r
+ConnectDevicePathInternal (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect,\r
+  IN BOOLEAN                   NeedDispatch\r
+  );\r
+\r
 #endif // _BDS_LIB_H_\r
 #endif // _BDS_LIB_H_\r