Revision: 14211
          http://edk2.svn.sourceforge.net/edk2/?rev=14211&view=rev
Author:   niruiyu
Date:     2013-03-19 07:10:51 +0000 (Tue, 19 Mar 2013)
Log Message:
-----------
Remove BdsLibConnectConsoleVariableWithoutDispatch() and enhance 
BdsLibConnectDevicePath() to only call gDS->Dispatch() when the current TPL is 
TPL_APPLICATION

Signed-off-by: Ruiyu Ni <[email protected]>
Reviewed-by: Chao B Zhang <[email protected]>

Modified Paths:
--------------
    trunk/edk2/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
    trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c
    trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
    trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h

Modified: trunk/edk2/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
===================================================================
--- trunk/edk2/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h  
2013-03-15 07:43:16 UTC (rev 14210)
+++ trunk/edk2/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h  
2013-03-19 07:10:51 UTC (rev 14211)
@@ -4,7 +4,7 @@
     2) BDS boot device connect interface.
     3) BDS Misc interfaces for mainting boot variable, ouput string.
 
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials are licensed and made available 
under 
 the terms and conditions of the BSD License that accompanies this 
distribution.  
 The full text of the license may be found at
@@ -531,30 +531,6 @@
   IN  CHAR16                 *ConVarName
   );
 
-/**
-  Connect the console device base on the variable ConVarName, if
-  device path of the ConVarName is multi-instance device path and
-  anyone of the instances is connected success, then this function
-  will return success. 
-  Dispatch service is not called when the handle associate with one 
-  device path node can not be created successfully. Here no driver 
-  dependency is assumed exist, so need not to call this service.
-
-  @param  ConVarName               Console related variable name, ConIn, 
ConOut,
-                                   ErrOut.
-
-  @retval EFI_NOT_FOUND            There is not any console devices connected
-                                   success
-  @retval EFI_SUCCESS              Success connect any one instance of the 
console
-                                   device path base on the variable ConVarName.
-
-**/
-EFI_STATUS
-EFIAPI
-BdsLibConnectConsoleVariableWithOutDispatch (
-  IN  CHAR16                 *ConVarName
-  );
-
 //
 // Bds device path related lib functions
 //

Modified: trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c
===================================================================
--- trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c       
2013-03-15 07:43:16 UTC (rev 14210)
+++ trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c       
2013-03-19 07:10:51 UTC (rev 14211)
@@ -1,7 +1,7 @@
 /** @file
   BDS Lib functions which relate with connect the device
 
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -65,17 +65,14 @@
   BdsLibConnectAllConsoles ();
 }
 
-
 /**
   This function will create all handles associate with every device
   path node. If the handle associate with one device path node can not
-  be created successfully, Dispatch service which load the missing drivers
-  is called according to input parameter, since in some cases no driver 
-  dependency is assumed exist, so may need not to call this service.
+  be created successfully, then still give chance to do the dispatch,
+  which load the missing drivers if possible.
 
   @param  DevicePathToConnect   The device path which will be connected, it 
can be
                                 a multi-instance device path
-  @param  NeedDispatch          Whether requires dispatch service during 
connection 
 
   @retval EFI_SUCCESS           All handles associate with every device path  
node
                                 have been created
@@ -85,9 +82,9 @@
 
 **/
 EFI_STATUS
-ConnectDevicePathInternal (
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect,
-  IN BOOLEAN                   NeedDispatch
+EFIAPI
+BdsLibConnectDevicePath (
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect
   )
 {
   EFI_STATUS                Status;
@@ -99,11 +96,14 @@
   EFI_HANDLE                Handle;
   EFI_HANDLE                PreviousHandle;
   UINTN                     Size;
+  EFI_TPL                   CurrentTpl;
 
   if (DevicePathToConnect == NULL) {
     return EFI_SUCCESS;
   }
 
+  CurrentTpl  = EfiGetCurrentTpl ();
+
   DevicePath        = DuplicateDevicePath (DevicePathToConnect);
   if (DevicePath == NULL) {
     return EFI_OUT_OF_RESOURCES;
@@ -152,7 +152,10 @@
           // Status == EFI_SUCCESS means a driver was dispatched
           // Status == EFI_NOT_FOUND means no new drivers were dispatched
           //
-          if (NeedDispatch) {
+          if (CurrentTpl == TPL_APPLICATION) {
+            //
+            // Dispatch calls LoadImage/StartImage which cannot run at TPL > 
TPL_APPLICATION
+            //
             Status = gDS->Dispatch ();
           } else {
             //
@@ -199,33 +202,7 @@
   return Status;
 }
 
-
 /**
-  This function will create all handles associate with every device
-  path node. If the handle associate with one device path node can not
-  be created successfully, then still give chance to do the dispatch,
-  which load the missing drivers if possible.
-
-  @param  DevicePathToConnect   The device path which will be connected, it 
can be
-                                a multi-instance device path
-
-  @retval EFI_SUCCESS           All handles associate with every device path  
node
-                                have been created
-  @retval EFI_OUT_OF_RESOURCES  There is no resource to create new handles
-  @retval EFI_NOT_FOUND         Create the handle associate with one device  
path
-                                node failed
-
-**/
-EFI_STATUS
-EFIAPI
-BdsLibConnectDevicePath (
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect
-  )
-{
-  return ConnectDevicePathInternal(DevicePathToConnect, TRUE);
-}
-
-/**
   This function will connect all current system handles recursively. 
   
   gBS->ConnectController() service is invoked for each handle exist in system 
handler buffer.

Modified: trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
===================================================================
--- trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c       
2013-03-15 07:43:16 UTC (rev 14210)
+++ trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c       
2013-03-19 07:10:51 UTC (rev 14211)
@@ -182,114 +182,6 @@
 }
 
 /**
-  Connect the console device base on the variable ConVarName, if
-  device path of the ConVarName is multi-instance device path and
-  anyone of the instances is connected success, this function will
-  return success. 
-  Dispatch service is called basing on input when the handle associate
-  with one device path node can not be created successfully. Since in
-  some cases we assume driver dependency does not exist and do not 
-  need to call this service.
-
-  @param  ConVarName               Console related variable name, ConIn, 
ConOut,
-                                   ErrOut.
-  @param  NeedDispatch              Whether requires dispatch service during 
connection 
-
-  @retval EFI_NOT_FOUND            There is not any console devices connected
-                                   success
-  @retval EFI_SUCCESS              Success connect any one instance of the 
console
-                                   device path base on the variable ConVarName.
-
-**/
-EFI_STATUS
-ConnectConsoleVariableInternal (
-  IN  CHAR16                 *ConVarName,
-  IN  BOOLEAN                NeedDispatch
-  )
-{
-  EFI_STATUS                Status;
-  EFI_DEVICE_PATH_PROTOCOL  *StartDevicePath;
-  UINTN                     VariableSize;
-  EFI_DEVICE_PATH_PROTOCOL  *Instance;
-  EFI_DEVICE_PATH_PROTOCOL  *Next;
-  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;
-  UINTN                     Size;
-  BOOLEAN                   DeviceExist;
-
-  Status      = EFI_SUCCESS;
-  DeviceExist = FALSE;
-
-  //
-  // Check if the console variable exist
-  //
-  StartDevicePath = BdsLibGetVariableAndSize (
-                      ConVarName,
-                      &gEfiGlobalVariableGuid,
-                      &VariableSize
-                      );
-  if (StartDevicePath == NULL) {
-    return EFI_UNSUPPORTED;
-  }
-
-  CopyOfDevicePath = StartDevicePath;
-  do {
-    //
-    // Check every instance of the console variable
-    //
-    Instance  = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
-    if (Instance == NULL) {
-      FreePool (StartDevicePath);
-      return EFI_UNSUPPORTED;
-    }
-    
-    Next      = Instance;
-    while (!IsDevicePathEndType (Next)) {
-      Next = NextDevicePathNode (Next);
-    }
-
-    SetDevicePathEndNode (Next);
-    //
-    // Connect the USB console
-    // USB console device path is a short-form device path that 
-    //  starts with the first element being a USB WWID
-    //  or a USB Class device path
-    //
-    if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
-       ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
-       || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
-       )) {
-      Status = BdsLibConnectUsbDevByShortFormDP (0xFF, Instance);
-      if (!EFI_ERROR (Status)) {
-        DeviceExist = TRUE;
-      }
-    } else {
-      //
-      // Connect the instance device path
-      //
-      Status = ConnectDevicePathInternal (Instance, NeedDispatch);
-
-      if (EFI_ERROR (Status)) {
-        //
-        // Delete the instance from the console varialbe
-        //
-        BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);
-      } else {
-        DeviceExist = TRUE;
-      }
-    }
-    FreePool(Instance);
-  } while (CopyOfDevicePath != NULL);
-
-  FreePool (StartDevicePath);
-
-  if (!DeviceExist) {
-    return EFI_NOT_FOUND;
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
   This function update console variable based on ConVarName, it can
   add or remove one specific console device path from the variable
 
@@ -447,35 +339,86 @@
   IN  CHAR16                 *ConVarName
   )
 {
-  return ConnectConsoleVariableInternal(ConVarName, TRUE);
-}
+  EFI_STATUS                Status;
+  EFI_DEVICE_PATH_PROTOCOL  *StartDevicePath;
+  UINTN                     VariableSize;
+  EFI_DEVICE_PATH_PROTOCOL  *Instance;
+  EFI_DEVICE_PATH_PROTOCOL  *Next;
+  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;
+  UINTN                     Size;
+  BOOLEAN                   DeviceExist;
 
-/**
-  Connect the console device base on the variable ConVarName, if
-  device path of the ConVarName is multi-instance device path and
-  anyone of the instances is connected success, then this function
-  will return success.
-  Dispatch service is not called when the handle associate with one 
-  device path node can not be created successfully. Here no driver 
-  dependency is assumed exist, so need not to call this service.
+  Status      = EFI_SUCCESS;
+  DeviceExist = FALSE;
 
+  //
+  // Check if the console variable exist
+  //
+  StartDevicePath = BdsLibGetVariableAndSize (
+                      ConVarName,
+                      &gEfiGlobalVariableGuid,
+                      &VariableSize
+                      );
+  if (StartDevicePath == NULL) {
+    return EFI_UNSUPPORTED;
+  }
 
-  @param  ConVarName               Console related variable name, ConIn, 
ConOut,
-                                   ErrOut.
+  CopyOfDevicePath = StartDevicePath;
+  do {
+    //
+    // Check every instance of the console variable
+    //
+    Instance  = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
+    if (Instance == NULL) {
+      FreePool (StartDevicePath);
+      return EFI_UNSUPPORTED;
+    }
+    
+    Next      = Instance;
+    while (!IsDevicePathEndType (Next)) {
+      Next = NextDevicePathNode (Next);
+    }
 
-  @retval EFI_NOT_FOUND            There is not any console devices connected
-                                   success
-  @retval EFI_SUCCESS              Success connect any one instance of the 
console
-                                   device path base on the variable ConVarName.
+    SetDevicePathEndNode (Next);
+    //
+    // Connect the USB console
+    // USB console device path is a short-form device path that 
+    //  starts with the first element being a USB WWID
+    //  or a USB Class device path
+    //
+    if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
+       ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
+       || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
+       )) {
+      Status = BdsLibConnectUsbDevByShortFormDP (0xFF, Instance);
+      if (!EFI_ERROR (Status)) {
+        DeviceExist = TRUE;
+      }
+    } else {
+      //
+      // Connect the instance device path
+      //
+      Status = BdsLibConnectDevicePath (Instance);
 
-**/
-EFI_STATUS
-EFIAPI
-BdsLibConnectConsoleVariableWithOutDispatch (
-  IN  CHAR16                 *ConVarName
-  )
-{
-  return ConnectConsoleVariableInternal(ConVarName, FALSE);
+      if (EFI_ERROR (Status)) {
+        //
+        // Delete the instance from the console varialbe
+        //
+        BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);
+      } else {
+        DeviceExist = TRUE;
+      }
+    }
+    FreePool(Instance);
+  } while (CopyOfDevicePath != NULL);
+
+  FreePool (StartDevicePath);
+
+  if (!DeviceExist) {
+    return EFI_NOT_FOUND;
+  }
+
+  return EFI_SUCCESS;
 }
 
 /**

Modified: 
trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h
===================================================================
--- trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h   
2013-03-15 07:43:16 UTC (rev 14210)
+++ trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h   
2013-03-19 07:10:51 UTC (rev 14211)
@@ -1,7 +1,7 @@
 /** @file
   BDS library definition, include the file and data structure
 
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -158,28 +158,4 @@
   UINTN                     VariableSize
   );
 
-/**
-  This function will create all handles associate with every device
-  path node. If the handle associate with one device path node can not
-  be created successfully, Dispatch service which load the missing drivers
-  is called basing on input parameter, since in some cases no driver 
-  dependency is assumed exist, so may need not to call this service.
-
-  @param  DevicePathToConnect   The device path which will be connected, it 
can be
-                                a multi-instance device path
-  @param  NeedDispatch          Whether requires dispatch service during 
connection 
-
-  @retval EFI_SUCCESS           All handles associate with every device path  
node
-                                have been created
-  @retval EFI_OUT_OF_RESOURCES  There is no resource to create new handles
-  @retval EFI_NOT_FOUND         Create the handle associate with one device  
path
-                                node failed
-
-**/
-EFI_STATUS
-ConnectDevicePathInternal (
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect,
-  IN BOOLEAN                   NeedDispatch
-  );
-
 #endif // _BDS_LIB_H_

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to