]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update ConPlatform to ensure console dev variable is correct.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 4 Mar 2009 05:48:09 +0000 (05:48 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 4 Mar 2009 05:48:09 +0000 (05:48 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7796 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c

index 6c72c8d126ed7b55ccec47ae27642b95206e1568..9fccfc0cad81b174ceb84c500a0cf3174020263e 100644 (file)
@@ -226,6 +226,7 @@ ConPlatformTextInDriverBindingStart (
   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
@@ -255,6 +256,19 @@ ConPlatformTextInDriverBindingStart (
   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
@@ -268,6 +282,16 @@ ConPlatformTextInDriverBindingStart (
            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
@@ -283,13 +307,7 @@ ConPlatformTextInDriverBindingStart (
     // 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
@@ -341,6 +359,8 @@ ConPlatformTextOutDriverBindingStart (
   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
@@ -372,6 +392,29 @@ ConPlatformTextOutDriverBindingStart (
   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
@@ -385,6 +428,26 @@ ConPlatformTextOutDriverBindingStart (
            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
@@ -408,13 +471,7 @@ ConPlatformTextOutDriverBindingStart (
     // 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
@@ -427,12 +484,7 @@ ConPlatformTextOutDriverBindingStart (
     // 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
@@ -497,18 +549,13 @@ ConPlatformTextInDriverBindingStop (
   //\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
@@ -524,11 +571,11 @@ ConPlatformTextInDriverBindingStop (
   // 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
@@ -573,23 +620,18 @@ ConPlatformTextOutDriverBindingStop (
                   );\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