]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
Per UEFI spec, FORM_OPEN/FORM_CLOSE Callback function should be called for each quest...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / DeviceMngr / DeviceManager.c
index 3fa24ad6d527eaaa85a9a1cdea993d2731a9479d..6965615df31c6cc3aef8de65ea79c74a65662f1b 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   The platform device manager reference implementation\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2010, 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
@@ -69,6 +69,31 @@ HII_VENDOR_DEVICE_PATH  mDeviceManagerHiiVendorDevicePath = {
   }\r
 };\r
 \r
+HII_VENDOR_DEVICE_PATH  mDriverHealthHiiVendorDevicePath = {\r
+  {\r
+    {\r
+      HARDWARE_DEVICE_PATH,\r
+        HW_VENDOR_DP,\r
+      {\r
+        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
+          (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
+      }\r
+    },\r
+    //\r
+    // {D8F76651-1675-4986-BED4-3824B2F1F4C8}\r
+    //\r
+    { 0xd8f76651, 0x1675, 0x4986, { 0xbe, 0xd4, 0x38, 0x24, 0xb2, 0xf1, 0xf4, 0xc8 } }\r
+  },\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+      END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+    { \r
+      (UINT8) (END_DEVICE_PATH_LENGTH),\r
+        (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
+    }\r
+  }\r
+};\r
+\r
 /**\r
   This function is invoked if user selected a interactive opcode from Device Manager's\r
   Formset. The decision by user is saved to gCallbackKey for later processing. If\r
@@ -97,6 +122,13 @@ DeviceManagerCallback (
   OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
   )\r
 {\r
+  if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {\r
+    //\r
+    // Do nothing for UEFI OPEN/CLOSE Action\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
   if ((Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -141,6 +173,8 @@ InitializeDeviceManager (
 \r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &gDeviceManagerPrivate.DriverHealthHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  &mDriverHealthHiiVendorDevicePath,\r
                   &gEfiHiiConfigAccessProtocolGuid,\r
                   &gDeviceManagerPrivate.DriverHealthConfigAccess,\r
                   NULL\r
@@ -267,18 +301,26 @@ ExtractDisplayedHiiFormFromHiiHandle (
         OpCodeData = Package + Offset2;\r
 \r
         if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {\r
-          //\r
-          // Find FormSet OpCode\r
-          //\r
-          ClassGuidNum = ((EFI_IFR_FORM_SET *) OpCodeData)->Flags;\r
-          ClassGuid = (EFI_GUID *) (VOID *)(OpCodeData + sizeof (EFI_IFR_FORM_SET));\r
-          while (ClassGuidNum-- > 0) {\r
-            if (CompareGuid (SetupClassGuid, ClassGuid)) {\r
-              CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
-              CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));\r
-              FreePool (HiiPackageList);\r
-              return TRUE;\r
+          if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {\r
+            //\r
+            // Find FormSet OpCode\r
+            //\r
+            ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);\r
+            ClassGuid = (EFI_GUID *) (VOID *)(OpCodeData + sizeof (EFI_IFR_FORM_SET));\r
+            while (ClassGuidNum-- > 0) {\r
+              if (CompareGuid (SetupClassGuid, ClassGuid)) {\r
+                CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
+                CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));\r
+                FreePool (HiiPackageList);\r
+                return TRUE;\r
+              }\r
+              ClassGuid ++;\r
             }\r
+           } else {\r
+             CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
+             CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));\r
+             FreePool (HiiPackageList);\r
+             return TRUE;\r
           }\r
         }\r
         \r
@@ -429,13 +471,24 @@ CallDeviceManager (
                 &NumHandles,\r
                 &DriverHealthHandles\r
                 );\r
+\r
   //\r
-  // If there are no drivers installed driver health protocol\r
+  // If there are no drivers installed driver health protocol, do not create driver health entry in UI\r
   //\r
-  if (NumHandles == 0) {\r
-    HiiSetString (HiiHandle, STRING_TOKEN (STR_DM_DRIVER_HEALTH_TITLE), GetStringById (STRING_TOKEN (STR_EMPTY_STRING)), NULL);\r
-    HiiSetString (HiiHandle, STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY), GetStringById (STRING_TOKEN (STR_EMPTY_STRING)), NULL);\r
-  } else {\r
+  if (NumHandles != 0) {\r
+    //\r
+    // If driver health protocol is installed, create Driver Health subtitle and entry\r
+    //\r
+    HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_DM_DRIVER_HEALTH_TITLE), 0, 0, 0);\r
+    HiiCreateActionOpCode (\r
+      StartOpCodeHandle,                                // Container for dynamic created opcodes\r
+      DEVICE_MANAGER_KEY_DRIVER_HEALTH,                 // Question ID\r
+      STRING_TOKEN(STR_DRIVER_HEALTH_ALL_HEALTHY),      // Prompt text\r
+      STRING_TOKEN(STR_DRIVER_HEALTH_STATUS_HELP),      // Help text\r
+      EFI_IFR_FLAG_CALLBACK,                            // Question flag\r
+      0                                                 // Action String ID\r
+    );\r
+\r
     //\r
     // Check All Driver health status\r
     //\r
@@ -563,6 +616,13 @@ DriverHealthCallback (
   OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
   )\r
 {\r
+  if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {\r
+    //\r
+    // Do nothing for UEFI OPEN/CLOSE Action\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
   if ((Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -951,22 +1011,19 @@ CallDriverHealth (
 }\r
 \r
 \r
-/*\r
+/**\r
   Check the Driver Health status of a single controller and try to process it if not healthy.\r
 \r
   This function called by CheckAllControllersHealthStatus () function in order to process a specify\r
   contoller's health state.\r
 \r
-  @param DriverHealth       A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r
+  @param DriverHealthList   A Pointer to the list contain all of the platform driver health information. \r
+  @param DriverHandle       The handle of driver.\r
   @param ControllerHandle   The class guid specifies which form set will be displayed.\r
   @param ChildHandle        The handle of the child controller to retrieve the health \r
-                           status on.  This is an optional parameter that may be NULL. \r
+                            status on.  This is an optional parameter that may be NULL. \r
+  @param DriverHealth       A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r
   @param HealthStatus       The health status of the controller.\r
-  @param MessageList        An array of warning or error messages associated \r
-                           with the controller specified by ControllerHandle and \r
-                           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
 \r
   @retval EFI_INVALID_PARAMETER   HealthStatus or DriverHealth is NULL.\r
   @retval HealthStatus            The Health status of specify controller.\r
@@ -974,7 +1031,7 @@ CallDriverHealth (
   @retval EFI_NOT_FOUND           No controller in the platform install Driver Health Protocol.\r
   @retval EFI_SUCCESS             The Health related operation has been taken successfully.\r
 \r
-*/\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GetSingleControllerHealthStatus (\r
@@ -1279,14 +1336,14 @@ Done:
 }\r
 \r
 \r
-/*\r
+/**\r
   Check the healthy status of the platform, this function will return immediately while found one driver \r
   in the platform are not healthy.\r
 \r
   @retval FALSE      at least one driver in the platform are not healthy.\r
   @retval TRUE       No controller install Driver Health Protocol,\r
                      or all controllers in the platform are in healthy status.\r
-*/\r
+**/\r
 BOOLEAN\r
 PlaformHealthStatusCheck (\r
   VOID\r
@@ -1543,7 +1600,7 @@ ProcessMessages (
 \r
 }\r
 \r
-/*\r
+/**\r
   Repair the whole platform.\r
 \r
   This function is the main entry for user choose "Repair All" in the front page.\r
@@ -1553,7 +1610,7 @@ ProcessMessages (
   @param DriverHealthList   A Pointer to the list contain all of the platform driver health\r
                             information.\r
 \r
-*/\r
+**/\r
 VOID\r
 PlatformRepairAll (\r
   IN LIST_ENTRY  *DriverHealthList\r
@@ -1644,10 +1701,10 @@ DriverHealthSelectBestLanguage (
   @param  SupportedLanguage    The best suitable language that matches the SupportedLangues interface for the \r
                                located Component Name (2) instance.\r
 \r
-  @param  EFI_SUCCESS          The Component Name (2) protocol instance is successfully located and we find\r
+  @retval EFI_SUCCESS          The Component Name (2) protocol instance is successfully located and we find\r
                                the best matching language it support.\r
-  @param  EFI_UNSUPPORTED      The input Language is not supported by the Component Name (2) protocol.\r
-  @param  Other                Some error occurs when locating Component Name (2) protocol instance or finding\r
+  @retval EFI_UNSUPPORTED      The input Language is not supported by the Component Name (2) protocol.\r
+  @retval Other                Some error occurs when locating Component Name (2) protocol instance or finding\r
                                the supported language.\r
 \r
 **/\r
@@ -1866,7 +1923,6 @@ GetControllerNameWorker (
                                It will also be NULL for bus drivers that attempt to retrieve the name\r
                                of the bus controller. It will not be NULL for a bus driver that attempts\r
                                to retrieve the name of a child controller.\r
-  @param  Language             An ASCII string that represents the language command line option.\r
   @param  ControllerName       A pointer to the Unicode string to return. This Unicode string\r
                                is the name of the controller specified by ControllerHandle and ChildHandle.\r
 \r