MdePkg:
[mirror_edk2.git] / EdkModulePkg / Universal / ConPlatform / Dxe / ConPlatform.c
index 15e7693..1972e0c 100644 (file)
@@ -22,7 +22,7 @@ Abstract:
 EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding = {\r
   ConPlatformTextInDriverBindingSupported,\r
   ConPlatformTextInDriverBindingStart,\r
-  ConPlatformDriverBindingStop,\r
+  ConPlatformTextInDriverBindingStop,\r
   0xa,\r
   NULL,\r
   NULL\r
@@ -31,7 +31,7 @@ EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding = {
 EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding = {\r
   ConPlatformTextOutDriverBindingSupported,\r
   ConPlatformTextOutDriverBindingStart,\r
-  ConPlatformDriverBindingStop,\r
+  ConPlatformTextOutDriverBindingStop,\r
   0xa,\r
   NULL,\r
   NULL\r
@@ -287,7 +287,6 @@ Returns:
   EFI_STATUS                    Status;\r
   EFI_DEVICE_PATH_PROTOCOL      *DevicePath;\r
   EFI_SIMPLE_TEXT_OUT_PROTOCOL  *TextOut;\r
-\r
   BOOLEAN                       NeedClose;\r
 \r
   NeedClose = TRUE;\r
@@ -360,6 +359,7 @@ Returns:
               DevicePath,\r
               CHECK\r
               );\r
+\r
     if (!EFI_ERROR (Status)) {\r
       NeedClose = FALSE;\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
@@ -403,7 +403,7 @@ Returns:
 \r
 EFI_STATUS\r
 EFIAPI\r
-ConPlatformDriverBindingStop (\r
+ConPlatformTextInDriverBindingStop (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN  EFI_HANDLE                   ControllerHandle,\r
   IN  UINTN                        NumberOfChildren,\r
@@ -443,13 +443,81 @@ Returns:
                     );\r
     if (!EFI_ERROR (Status)) {\r
       //\r
-      // Remove DevicePath from ConInDev, ConOutDev, and StdErrDev\r
+      // Remove DevicePath from ConInDev\r
       //\r
       ConPlatformUpdateDeviceVariable (\r
         VarConsoleInpDev,\r
         DevicePath,\r
         DELETE\r
         );\r
+    }\r
+  }\r
+  //\r
+  // Uninstall the Console Device GUIDs from Controller Handle\r
+  //\r
+  ConPlatformUnInstallProtocol (\r
+    This,\r
+    ControllerHandle,\r
+    &gEfiConsoleInDeviceGuid\r
+    );\r
+\r
+  //\r
+  // Close the Simple Input Protocol\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEfiSimpleTextInProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ConPlatformTextOutDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+  (Standard DriverBinding Protocol Stop() function)\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  //\r
+  // hot plug device is not included into the console associated variables,\r
+  // so no need to check variable for those hot plug devices.\r
+  //\r
+  if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+    //\r
+    // Get the Device Path Protocol so the environment variables can be updated\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    ControllerHandle,\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    (VOID **) &DevicePath,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      //\r
+      // Remove DevicePath from ConOutDev, and StdErrDev\r
+      //\r
       ConPlatformUpdateDeviceVariable (\r
         VarConsoleOutDev,\r
         DevicePath,\r
@@ -465,12 +533,6 @@ Returns:
   //\r
   // Uninstall the Console Device GUIDs from Controller Handle\r
   //\r
-  ConPlatformUnInstallProtocol (\r
-    This,\r
-    ControllerHandle,\r
-    &gEfiConsoleInDeviceGuid\r
-    );\r
-\r
   ConPlatformUnInstallProtocol (\r
     This,\r
     ControllerHandle,\r
@@ -484,15 +546,8 @@ Returns:
     );\r
 \r
   //\r
-  // Close the Simple Input and Simple Text Output Protocols\r
+  // Close the Simple Text Output Protocol\r
   //\r
-  gBS->CloseProtocol (\r
-        ControllerHandle,\r
-        &gEfiSimpleTextInProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        ControllerHandle\r
-        );\r
-\r
   gBS->CloseProtocol (\r
         ControllerHandle,\r
         &gEfiSimpleTextOutProtocolGuid,\r
@@ -503,6 +558,7 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+\r
 VOID\r
 ConPlatformUnInstallProtocol (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r