Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and\r
Simple Text Output Protocol upon Serial IO Protocol.\r
\r
-Copyright (c) 2006 - 2017, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
EFI_OPEN_PROTOCOL_BY_DRIVER\r
);\r
ASSERT ((Status == EFI_SUCCESS) || (Status == EFI_ALREADY_STARTED));\r
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
+ return Status;\r
+ }\r
\r
//\r
// Open the Serial I/O Protocol BY_DRIVER. It might already be started.\r
EFI_OPEN_PROTOCOL_BY_DRIVER\r
);\r
ASSERT ((Status == EFI_SUCCESS) || (Status == EFI_ALREADY_STARTED));\r
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
+ return Status;\r
+ }\r
\r
if (!IsHotPlugDevice (ParentDevicePath)) {\r
//\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Compare a device path data structure to that of all the nodes of a\r
+ second device path instance.\r
+\r
+ @param Multi A pointer to a multi-instance device path data structure.\r
+ @param Single A pointer to a single-instance device path data structure.\r
+\r
+ @retval TRUE If the Single is contained within Multi.\r
+ @retval FALSE The Single is not match within Multi.\r
+\r
+**/\r
+BOOLEAN\r
+MatchDevicePaths (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Single\r
+ )\r
+{\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r
+ UINTN Size;\r
+\r
+ DevicePath = Multi;\r
+ DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
+ //\r
+ // Search for the match of 'Single' in 'Multi'\r
+ //\r
+ while (DevicePathInst != NULL) {\r
+ //\r
+ // If the single device path is found in multiple device paths,\r
+ // return success\r
+ //\r
+ if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
+ FreePool (DevicePathInst);\r
+ return TRUE;\r
+ }\r
+\r
+ FreePool (DevicePathInst);\r
+ DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
/**\r
Update terminal device path in Console Device Environment Variables.\r
\r
//\r
// Get global variable and its size according to the name given.\r
//\r
- GetEfiGlobalVariable2 (VariableName, (VOID**)&Variable, NULL);\r
- if (Variable == NULL) {\r
+ Status = GetEfiGlobalVariable2 (VariableName, (VOID**)&Variable, NULL);\r
+ if (Status == EFI_NOT_FOUND) {\r
+ Status = EFI_SUCCESS;\r
+ Variable = NULL;\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
return;\r
}\r
\r
//\r
for (TerminalType = 0; TerminalType < ARRAY_SIZE (mTerminalType); TerminalType++) {\r
SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);\r
- NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);\r
- ASSERT (NewVariable != NULL);\r
- if (Variable != NULL) {\r
- FreePool (Variable);\r
- }\r
\r
if (TempDevicePath != NULL) {\r
+ if (!MatchDevicePaths (Variable, TempDevicePath)) {\r
+ NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);\r
+ if (NewVariable != NULL) {\r
+ if (Variable != NULL) {\r
+ FreePool (Variable);\r
+ }\r
+ Variable = NewVariable;\r
+ }\r
+ }\r
+\r
FreePool (TempDevicePath);\r
}\r
\r
- Variable = NewVariable;\r
}\r
\r
VariableSize = GetDevicePathSize (Variable);\r
ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));\r
Node.Header.Type = MESSAGING_DEVICE_PATH;\r
Node.Header.SubType = MSG_VENDOR_DP;\r
- SetDevicePathNodeLength (&Node, sizeof (VENDOR_DEVICE_PATH));\r
+ SetDevicePathNodeLength (&Node.Header, sizeof (VENDOR_DEVICE_PATH));\r
CopyGuid (&Node.Guid, mTerminalType[TerminalType]);\r
\r
//\r