diff options
author | czhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-08-17 07:36:56 +0000 |
---|---|---|
committer | czhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-08-17 07:36:56 +0000 |
commit | bc79c731b4eaec270bfb62d32b9fc2cc321eee61 (patch) | |
tree | 7fe94ae7b13bd1252a0ff5187f1d1b322fe2f36b | |
parent | db1126d218ff92fa324350d077f1a610560260c7 (diff) | |
download | edk2-platforms-bc79c731b4eaec270bfb62d32b9fc2cc321eee61.tar.xz |
Fix the issue that consplitter should not touch ConIn variable & do ConIn connection
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
4 files changed, 241 insertions, 93 deletions
diff --git a/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h b/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h index 422666abe0..b1887b60ca 100644 --- a/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h +++ b/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h @@ -386,9 +386,10 @@ BdsLibConnectAll ( );
/**
- This function creates all handles associated with the given device
- path node. If the handle associated with one device path node cannot
- be created, then it tries to execute the dispatch to load the missing drivers.
+ 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 to be connected. Can be
a multi-instance device path.
@@ -507,17 +508,21 @@ BdsLibUpdateConsoleVariable ( );
/**
- Connect the console device base on the variable ConVarName. If
- ConVarName is a multi-instance device path, and at least one
- instance connects successfully, then this function
+ 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.
+ 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 ConVarName The console related variable name: ConIn, ConOut,
+ @param ConVarName Console related variable name, ConIn, ConOut,
ErrOut.
- @retval EFI_NOT_FOUND No console devices were connected successfully
- @retval EFI_SUCCESS Connected at least one instance of the console
- device path based on the variable ConVarName.
+ @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
@@ -526,6 +531,30 @@ BdsLibConnectConsoleVariable ( 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
//
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c index fe96e2c098..0e456dd516 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c @@ -1,7 +1,7 @@ /** @file
BDS Lib functions which relate with connect the device
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2012, 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
@@ -69,11 +69,13 @@ BdsLibGenericConnectAll ( /**
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 success, then still give one chance to do the dispatch,
- which load the missing drivers if possible.
+ 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.
@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
@@ -83,9 +85,9 @@ BdsLibGenericConnectAll ( **/
EFI_STATUS
-EFIAPI
-BdsLibConnectDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
+ConnectDevicePathInternal (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect,
+ IN BOOLEAN NeedDispatch
)
{
EFI_STATUS Status;
@@ -150,7 +152,15 @@ BdsLibConnectDevicePath ( // Status == EFI_SUCCESS means a driver was dispatched
// Status == EFI_NOT_FOUND means no new drivers were dispatched
//
- Status = gDS->Dispatch ();
+ if (NeedDispatch) {
+ Status = gDS->Dispatch ();
+ } else {
+ //
+ // Always return EFI_NOT_FOUND here
+ // to prevent dead loop when control handle is found but connection failded case
+ //
+ Status = EFI_NOT_FOUND;
+ }
}
if (!EFI_ERROR (Status)) {
@@ -191,6 +201,31 @@ BdsLibConnectDevicePath ( /**
+ 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.
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c index 280b1697b6..782c4a5ce1 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c @@ -172,6 +172,114 @@ UpdateSystemTableConsole ( }
/**
+ 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
@@ -307,9 +415,12 @@ BdsLibUpdateConsoleVariable ( /**
Connect the console device base on the variable ConVarName, if
- device path of the ConVarName is multi-instance device path, 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.
+ 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 ConVarName Console related variable name, ConIn, ConOut,
ErrOut.
@@ -326,88 +437,37 @@ BdsLibConnectConsoleVariable ( IN CHAR16 *ConVarName
)
{
- 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;
+ return ConnectConsoleVariableInternal(ConVarName, TRUE);
+}
- //
- // Check if the console variable exist
- //
- StartDevicePath = BdsLibGetVariableAndSize (
- ConVarName,
- &gEfiGlobalVariableGuid,
- &VariableSize
- );
- if (StartDevicePath == NULL) {
- return EFI_UNSUPPORTED;
- }
+/**
+ 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.
- 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 = BdsLibConnectDevicePath (Instance);
- 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);
+ @param ConVarName Console related variable name, ConIn, ConOut,
+ ErrOut.
- if (!DeviceExist) {
- return EFI_NOT_FOUND;
- }
+ @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.
- return EFI_SUCCESS;
+**/
+EFI_STATUS
+EFIAPI
+BdsLibConnectConsoleVariableWithOutDispatch (
+ IN CHAR16 *ConVarName
+ )
+{
+ return ConnectConsoleVariableInternal(ConVarName, FALSE);
}
-
/**
This function will search every simpletext device in current system,
and make every simpletext device as pertantial console device.
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h index 7381670bf2..d5b5b3bd02 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h @@ -158,4 +158,28 @@ ValidateOption ( 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_
|