]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
> When GetHealthStatus() returns NULL FormHiiHandle, DeviceManager shouldn't call...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / DeviceMngr / DeviceManager.c
index 7da685103330c26c7f0369034122e418e6e49e56..8ee345e8a7ff642e8e460c33e9a3fdfc49be2d67 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The platform device manager reference implementation\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -1168,6 +1168,7 @@ CallDriverHealth (
   LIST_ENTRY                  *Link;\r
   EFI_DEVICE_PATH_PROTOCOL    *DriverDevicePath;\r
   UINTN                       Length;\r
+  BOOLEAN                     RebootRequired;\r
 \r
   Index               = 0;\r
   Length              = 0;\r
@@ -1304,30 +1305,31 @@ CallDriverHealth (
       //\r
       switch(DriverHealthInfo->HealthStatus) {\r
       case EfiDriverHealthStatusRepairRequired:\r
-        Length = StrLen (GetStringById (STRING_TOKEN (STR_REPAIR_REQUIRED)));\r
-        StrnCat (String, GetStringById (STRING_TOKEN (STR_REPAIR_REQUIRED)), Length);\r
+        TmpString = GetStringById (STRING_TOKEN (STR_REPAIR_REQUIRED));\r
+        StrCat (String, TmpString);\r
         break;\r
       case EfiDriverHealthStatusConfigurationRequired:\r
-        Length = StrLen (GetStringById (STRING_TOKEN (STR_CONFIGURATION_REQUIRED)));\r
-        StrnCat (String, GetStringById (STRING_TOKEN (STR_CONFIGURATION_REQUIRED)), Length);\r
+        TmpString = GetStringById (STRING_TOKEN (STR_CONFIGURATION_REQUIRED));\r
+        StrCat (String, TmpString);\r
         break;\r
       case EfiDriverHealthStatusFailed:\r
-        Length = StrLen (GetStringById (STRING_TOKEN (STR_OPERATION_FAILED)));\r
-        StrnCat (String, GetStringById (STRING_TOKEN (STR_OPERATION_FAILED)), Length);\r
+        TmpString = GetStringById (STRING_TOKEN (STR_OPERATION_FAILED));\r
+        StrCat (String, TmpString);\r
         break;\r
       case EfiDriverHealthStatusReconnectRequired:\r
-        Length = StrLen (GetStringById (STRING_TOKEN (STR_RECONNECT_REQUIRED)));\r
-        StrnCat (String, GetStringById (STRING_TOKEN (STR_RECONNECT_REQUIRED)), Length);\r
+        TmpString = GetStringById (STRING_TOKEN (STR_RECONNECT_REQUIRED));\r
+        StrCat (String, TmpString);\r
         break;\r
       case EfiDriverHealthStatusRebootRequired:\r
-        Length = StrLen (GetStringById (STRING_TOKEN (STR_REBOOT_REQUIRED)));\r
-        StrnCat (String, GetStringById (STRING_TOKEN (STR_REBOOT_REQUIRED)), Length);\r
+        TmpString = GetStringById (STRING_TOKEN (STR_REBOOT_REQUIRED));\r
+        StrCat (String, TmpString);\r
         break;\r
       default:\r
-        Length = StrLen (GetStringById (STRING_TOKEN (STR_DRIVER_HEALTH_HEALTHY)));\r
-        StrnCat (String, GetStringById (STRING_TOKEN (STR_DRIVER_HEALTH_HEALTHY)), Length);\r
+        TmpString = GetStringById (STRING_TOKEN (STR_DRIVER_HEALTH_HEALTHY));\r
+        StrCat (String, TmpString);\r
         break;\r
       }\r
+      FreePool (TmpString);\r
     }\r
 \r
     Token = HiiSetString (HiiHandle, 0, String, NULL);\r
@@ -1439,15 +1441,20 @@ CallDriverHealth (
         //\r
         // Process the driver's healthy status for the specify module\r
         //\r
+        RebootRequired = FALSE;\r
         ProcessSingleControllerHealth (\r
           DriverHealthInfo->DriverHealth,\r
           DriverHealthInfo->ControllerHandle,      \r
           DriverHealthInfo->ChildHandle,\r
           DriverHealthInfo->HealthStatus,\r
           &(DriverHealthInfo->MessageList),\r
-          DriverHealthInfo->HiiHandle\r
-       );  \r
-       break;\r
+          DriverHealthInfo->HiiHandle,\r
+          &RebootRequired\r
+          );\r
+        if (RebootRequired) {\r
+          gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+        }\r
+        break;\r
       }\r
       Index++;\r
       Link = GetNextNode (&DriverHealthList, Link);\r
@@ -1934,15 +1941,17 @@ PlaformHealthStatusCheck (
                             ChildHandle.  This is an optional parameter that may be NULL.\r
   @param FormHiiHandle      The HII handle for an HII form associated with the \r
                             controller specified by ControllerHandle and ChildHandle.\r
+  @param RebootRequired     Indicate whether a reboot is required to repair the controller.\r
 **/\r
 VOID\r
 ProcessSingleControllerHealth (\r
-    IN  EFI_DRIVER_HEALTH_PROTOCOL         *DriverHealth,\r
-    IN  EFI_HANDLE                         ControllerHandle, OPTIONAL\r
-    IN  EFI_HANDLE                         ChildHandle,      OPTIONAL\r
-    IN  EFI_DRIVER_HEALTH_STATUS           HealthStatus,\r
-    IN  EFI_DRIVER_HEALTH_HII_MESSAGE      **MessageList,    OPTIONAL\r
-    IN  EFI_HII_HANDLE                     FormHiiHandle\r
+  IN  EFI_DRIVER_HEALTH_PROTOCOL         *DriverHealth,\r
+  IN  EFI_HANDLE                         ControllerHandle, OPTIONAL\r
+  IN  EFI_HANDLE                         ChildHandle,      OPTIONAL\r
+  IN  EFI_DRIVER_HEALTH_STATUS           HealthStatus,\r
+  IN  EFI_DRIVER_HEALTH_HII_MESSAGE      **MessageList,    OPTIONAL\r
+  IN  EFI_HII_HANDLE                     FormHiiHandle,\r
+  IN OUT BOOLEAN                         *RebootRequired\r
   )\r
 {\r
   EFI_STATUS                         Status;\r
@@ -1954,8 +1963,8 @@ ProcessSingleControllerHealth (
   // reach a terminal status. The status from EfiDriverHealthStatusRepairRequired after repair \r
   // will be in (Health, Failed, Configuration Required).\r
   //\r
-  while( LocalHealthStatus == EfiDriverHealthStatusConfigurationRequired ||\r
-         LocalHealthStatus == EfiDriverHealthStatusRepairRequired) {\r
+  while(LocalHealthStatus == EfiDriverHealthStatusConfigurationRequired ||\r
+        LocalHealthStatus == EfiDriverHealthStatusRepairRequired) {\r
 \r
     if (LocalHealthStatus == EfiDriverHealthStatusRepairRequired) {\r
       Status = DriverHealth->Repair (\r
@@ -1971,16 +1980,23 @@ ProcessSingleControllerHealth (
     // (Healthy, Reboot Required, Failed, Reconnect Required, Repair Required).   \r
     //\r
     if (LocalHealthStatus == EfiDriverHealthStatusConfigurationRequired) {\r
-      Status = gFormBrowser2->SendForm (\r
-                                gFormBrowser2,\r
-                                &FormHiiHandle,\r
-                                1,\r
-                                &gEfiHiiDriverHealthFormsetGuid,\r
-                                0,\r
-                                NULL,\r
-                                NULL\r
-                                );\r
-      ASSERT( !EFI_ERROR (Status));\r
+      if (FormHiiHandle != NULL) {\r
+        Status = gFormBrowser2->SendForm (\r
+                                  gFormBrowser2,\r
+                                  &FormHiiHandle,\r
+                                  1,\r
+                                  &gEfiHiiDriverHealthFormsetGuid,\r
+                                  0,\r
+                                  NULL,\r
+                                  NULL\r
+                                  );\r
+        ASSERT( !EFI_ERROR (Status));\r
+      } else {\r
+        //\r
+        // Exit the loop in case no FormHiiHandle is supplied to prevent dead-loop\r
+        //\r
+        break;\r
+      }\r
     }\r
 \r
     Status = DriverHealth->GetHealthStatus (\r
@@ -1991,11 +2007,11 @@ ProcessSingleControllerHealth (
                               NULL,\r
                               &FormHiiHandle\r
                               );\r
-   ASSERT_EFI_ERROR (Status);\r
+    ASSERT_EFI_ERROR (Status);\r
 \r
-   if (*MessageList != NULL) {\r
+    if (*MessageList != NULL) {\r
       ProcessMessages (*MessageList);\r
-   }  \r
+    }  \r
   }\r
   \r
   //\r
@@ -2010,7 +2026,7 @@ ProcessSingleControllerHealth (
   // Check for RebootRequired or ReconnectRequired\r
   //\r
   if (LocalHealthStatus == EfiDriverHealthStatusRebootRequired) {\r
-    gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+    *RebootRequired = TRUE;\r
   }\r
   \r
   //\r
@@ -2019,12 +2035,13 @@ ProcessSingleControllerHealth (
   if (LocalHealthStatus == EfiDriverHealthStatusReconnectRequired) {\r
     Status = gBS->DisconnectController (ControllerHandle, NULL, NULL);\r
     if (EFI_ERROR (Status)) {\r
-        //\r
-        // Disconnect failed.  Need to promote reconnect to a reboot.\r
-        //\r
-        gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+      //\r
+      // Disconnect failed.  Need to promote reconnect to a reboot.\r
+      //\r
+      *RebootRequired = TRUE;\r
+    } else {\r
+      gBS->ConnectController (ControllerHandle, NULL, NULL, TRUE);\r
     }\r
-    gBS->ConnectController (ControllerHandle, NULL, NULL, TRUE);\r
   }\r
 }\r
 \r
@@ -2117,12 +2134,16 @@ PlatformRepairAll (
 { \r
   DRIVER_HEALTH_INFO          *DriverHealthInfo;\r
   LIST_ENTRY                  *Link;\r
+  BOOLEAN                     RebootRequired;\r
 \r
   ASSERT (DriverHealthList != NULL);\r
 \r
-  Link = GetFirstNode (DriverHealthList);\r
+  RebootRequired = FALSE;\r
 \r
-  while (!IsNull (DriverHealthList, Link)) {   \r
+  for ( Link = GetFirstNode (DriverHealthList)\r
+      ; !IsNull (DriverHealthList, Link)\r
+      ; Link = GetNextNode (DriverHealthList, Link)\r
+      ) {\r
     DriverHealthInfo = DEVICE_MANAGER_HEALTH_INFO_FROM_LINK (Link);\r
     //\r
     // Do driver health status operation by each link node\r
@@ -2130,15 +2151,18 @@ PlatformRepairAll (
     ASSERT (DriverHealthInfo != NULL);\r
 \r
     ProcessSingleControllerHealth ( \r
-        DriverHealthInfo->DriverHealth,\r
-        DriverHealthInfo->ControllerHandle,\r
-        DriverHealthInfo->ChildHandle,\r
-        DriverHealthInfo->HealthStatus,\r
-        &(DriverHealthInfo->MessageList),\r
-        DriverHealthInfo->HiiHandle\r
-        );\r
+      DriverHealthInfo->DriverHealth,\r
+      DriverHealthInfo->ControllerHandle,\r
+      DriverHealthInfo->ChildHandle,\r
+      DriverHealthInfo->HealthStatus,\r
+      &(DriverHealthInfo->MessageList),\r
+      DriverHealthInfo->HiiHandle,\r
+      &RebootRequired\r
+      );\r
+  }\r
 \r
-    Link = GetNextNode (DriverHealthList, Link);\r
+  if (RebootRequired) {\r
+    gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
   }\r
 }\r
 \r