EFI_STATUS Status;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r
+ BOOLEAN IsInConInVariable;\r
\r
//\r
// Get the Device Path Protocol so the environment variables can be updated\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+ //\r
+ // Check if the device path is in ConIn Variable\r
+ //\r
+ IsInConInVariable = FALSE;\r
+ Status = ConPlatformUpdateDeviceVariable (\r
+ L"ConIn",\r
+ DevicePath,\r
+ CHECK\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ IsInConInVariable = TRUE;\r
+ }\r
+\r
//\r
// Check the device path, if it is a hot plug device,\r
// do not put the device path into ConInDev, and install\r
NULL,\r
NULL\r
);\r
+ //\r
+ // Append the device path to ConInDev only if it is in ConIn variable.\r
+ //\r
+ if (IsInConInVariable) {\r
+ ConPlatformUpdateDeviceVariable (\r
+ L"ConInDev",\r
+ DevicePath,\r
+ APPEND\r
+ );\r
+ }\r
} else {\r
//\r
// If it is not a hot-plug device, append the device path to the\r
// If the device path is an instance in the ConIn environment variable,\r
// then install EfiConsoleInDeviceGuid onto ControllerHandle\r
//\r
- Status = ConPlatformUpdateDeviceVariable (\r
- L"ConIn",\r
- DevicePath,\r
- CHECK\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
+ if (IsInConInVariable) {\r
gBS->InstallMultipleProtocolInterfaces (\r
&ControllerHandle,\r
&gEfiConsoleInDeviceGuid,\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
BOOLEAN NeedClose;\r
+ BOOLEAN IsInConOutVariable;\r
+ BOOLEAN IsInErrOutVariable;\r
\r
NeedClose = TRUE;\r
\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+ //\r
+ // Check if the device path is in ConOut & ErrOut Variable\r
+ //\r
+ IsInConOutVariable = FALSE;\r
+ Status = ConPlatformUpdateDeviceVariable (\r
+ L"ConOut",\r
+ DevicePath,\r
+ CHECK\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ IsInConOutVariable = TRUE;\r
+ }\r
+\r
+ IsInErrOutVariable = FALSE;\r
+ Status = ConPlatformUpdateDeviceVariable (\r
+ L"ErrOut",\r
+ DevicePath,\r
+ CHECK\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ IsInErrOutVariable = TRUE;\r
+ }\r
+\r
//\r
// Check the device path, if it is a hot plug device,\r
// do not put the device path into ConOutDev and ErrOutDev,\r
NULL,\r
NULL\r
);\r
+ //\r
+ // Append the device path to ConOutDev only if it is in ConOut variable.\r
+ //\r
+ if (IsInConOutVariable) {\r
+ ConPlatformUpdateDeviceVariable (\r
+ L"ConOutDev",\r
+ DevicePath,\r
+ APPEND\r
+ );\r
+ }\r
+ //\r
+ // Append the device path to ErrOutDev only if it is in ErrOut variable.\r
+ //\r
+ if (IsInErrOutVariable) {\r
+ ConPlatformUpdateDeviceVariable (\r
+ L"ErrOutDev",\r
+ DevicePath,\r
+ APPEND\r
+ );\r
+ }\r
} else {\r
//\r
// If it is not a hot-plug device, first append the device path to the\r
// If the device path is an instance in the ConOut environment variable,\r
// then install EfiConsoleOutDeviceGuid onto ControllerHandle\r
//\r
- Status = ConPlatformUpdateDeviceVariable (\r
- L"ConOut",\r
- DevicePath,\r
- CHECK\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
+ if (IsInConOutVariable) {\r
NeedClose = FALSE;\r
Status = gBS->InstallMultipleProtocolInterfaces (\r
&ControllerHandle,\r
// If the device path is an instance in the ErrOut environment variable,\r
// then install EfiStandardErrorDeviceGuid onto ControllerHandle\r
//\r
- Status = ConPlatformUpdateDeviceVariable (\r
- L"ErrOut",\r
- DevicePath,\r
- CHECK\r
- );\r
- if (!EFI_ERROR (Status)) {\r
+ if (IsInErrOutVariable) {\r
NeedClose = FALSE;\r
gBS->InstallMultipleProtocolInterfaces (\r
&ControllerHandle,\r
//\r
if (!EFI_ERROR (Status)) {\r
//\r
- // If it is not a hot-plug device, first delete it from the ConInDev variable.\r
+ // Remove DevicePath from ConInDev if exists.\r
//\r
- if (!IsHotPlugDevice (DevicePath)) {\r
- //\r
- // Remove DevicePath from ConInDev\r
- //\r
- ConPlatformUpdateDeviceVariable (\r
- L"ConInDev",\r
- DevicePath,\r
- DELETE\r
- );\r
- }\r
+ ConPlatformUpdateDeviceVariable (\r
+ L"ConInDev",\r
+ DevicePath,\r
+ DELETE\r
+ );\r
}\r
\r
//\r
// Close the Simple Text Input Protocol\r
//\r
gBS->CloseProtocol (\r
- ControllerHandle,\r
- &gEfiSimpleTextInProtocolGuid,\r
- This->DriverBindingHandle,\r
- ControllerHandle\r
- );\r
+ ControllerHandle,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
\r
return EFI_SUCCESS;\r
}\r
);\r
if (!EFI_ERROR (Status)) {\r
//\r
- // If it is not a hot-plug device, first delete it from the ConOutDev and ErrOutDev variable.\r
+ // Remove DevicePath from ConOutDev and ErrOutDev if exists.\r
//\r
- if (!IsHotPlugDevice (DevicePath)) {\r
- //\r
- // Remove DevicePath from ConOutDev, and ErrOutDev\r
- //\r
- ConPlatformUpdateDeviceVariable (\r
- L"ConOutDev",\r
- DevicePath,\r
- DELETE\r
- );\r
- ConPlatformUpdateDeviceVariable (\r
- L"ErrOutDev",\r
- DevicePath,\r
- DELETE\r
- );\r
- }\r
+ ConPlatformUpdateDeviceVariable (\r
+ L"ConOutDev",\r
+ DevicePath,\r
+ DELETE\r
+ );\r
+ ConPlatformUpdateDeviceVariable (\r
+ L"ErrOutDev",\r
+ DevicePath,\r
+ DELETE\r
+ );\r
}\r
\r
//\r